public function isClassProperty(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== \T_VARIABLE) {
            return false;
        }

        // Note: interfaces can not declare properties.
        $validScopes = array(
            'T_CLASS'      => true,
            'T_ANON_CLASS' => true,
            'T_TRAIT'      => true,
        );

        $scopePtr = $this->validDirectScope($phpcsFile, $stackPtr, $validScopes);
        if ($scopePtr !== false) {
            // Make sure it's not a method parameter.
            if (empty($tokens[$stackPtr]['nested_parenthesis']) === true) {
                return true;
            } else {
                $parenthesis = array_keys($tokens[$stackPtr]['nested_parenthesis']);
                $deepestOpen = array_pop($parenthesis);
                if ($deepestOpen < $scopePtr
                    || isset($tokens[$deepestOpen]['parenthesis_owner']) === false
                    || $tokens[$tokens[$deepestOpen]['parenthesis_owner']]['code'] !== \T_FUNCTION
                ) {
                    return true;
                }
            }
        }

        return false;
    }
public function isClassProperty(File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[$stackPtr]) === false || $tokens[$stackPtr]['code'] !== \T_VARIABLE) {
            return false;
        }

        // Note: interfaces can not declare properties.
        $validScopes = array(
            'T_CLASS'      => true,
            'T_ANON_CLASS' => true,
            'T_TRAIT'      => true,
        );

        $scopePtr = $this->validDirectScope($phpcsFile, $stackPtr, $validScopes);
        if ($scopePtr !== false) {
            // Make sure it's not a method parameter.
            if (empty($tokens[$stackPtr]['nested_parenthesis']) === true) {
                return true;
            } else {
                $parenthesis = array_keys($tokens[$stackPtr]['nested_parenthesis']);
                $deepestOpen = array_pop($parenthesis);
                if ($deepestOpen < $scopePtr
                    || isset($tokens[$deepestOpen]['parenthesis_owner']) === false
                    || $tokens[$tokens[$deepestOpen]['parenthesis_owner']]['code'] !== \T_FUNCTION
                ) {
                    return true;
                }
            }
        }

        return false;
    }
public function isClassProperty ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false || $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_VARIABLE ) { return false ; } // Note: interfaces can not declare properties. $ validScopes = array ( 'T_CLASS' => true , 'T_ANON_CLASS' => true , 'T_TRAIT' => true , ) ; $ scopePtr = $ this -> validDirectScope ( $ phpcsFile , $ stackPtr , $ validScopes ) ; if ( $ scopePtr !== false ) { // Make sure it's not a method parameter. if ( empty ( $ tokens [ $ stackPtr ] [ 'nested_parenthesis' ] ) === true ) { return true ; } else { $ parenthesis = array_keys ( $ tokens [ $ stackPtr ] [ 'nested_parenthesis' ] ) ; $ deepestOpen = array_pop ( $ parenthesis ) ; if ( $ deepestOpen < $ scopePtr || isset ( $ tokens [ $ deepestOpen ] [ 'parenthesis_owner' ] ) === false || $ tokens [ $ tokens [ $ deepestOpen ] [ 'parenthesis_owner' ] ] [ 'code' ] !== \ T_FUNCTION ) { return true ; } } } return false ; }
Check whether a T_VARIABLE token is a class property declaration.

Compatibility layer for PHPCS cross-version compatibility
as PHPCS 2.4.0 - 2.7.1 does not have good enough support for
anonymous classes. Along the same lines, the`getMemberProperties()`
method does not support the `var` prefix.

@param \PHP_CodeSniffer_File $phpcsFile Instance of phpcsFile.
@param int                   $stackPtr  The position in the stack of the
T_VARIABLE token to verify.

@return bool
Check whether a T_VARIABLE token is a class property declaration .