diff --git a/src/Files/File.php b/src/Files/File.php index 1a63437ea4..42e1a39f9b 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -1876,6 +1876,10 @@ public function getMemberProperties($stackPtr) throw new RuntimeException('$stackPtr must be of type T_VARIABLE'); } + if (empty($this->tokens[$stackPtr]['conditions']) === true) { + throw new RuntimeException('$stackPtr is not a class member var'); + } + $conditions = array_keys($this->tokens[$stackPtr]['conditions']); $ptr = array_pop($conditions); if (isset($this->tokens[$ptr]) === false diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index dea4438575..b5a7f84ada 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -1468,16 +1468,18 @@ protected function tokenize($string) $newToken['type'] = 'T_ATTRIBUTE'; $newToken['content'] = '#['; $finalTokens[$newStackPtr] = $newToken; + $newStackPtr++; - $tokens[$bracketCloser] = []; - $tokens[$bracketCloser][0] = T_ATTRIBUTE_END; - $tokens[$bracketCloser][1] = ']'; + if ($bracketCloser !== null) { + $tokens[$bracketCloser] = []; + $tokens[$bracketCloser][0] = T_ATTRIBUTE_END; + $tokens[$bracketCloser][1] = ']'; - if (PHP_CODESNIFFER_VERBOSITY > 1) { - echo "\t\t* token $bracketCloser changed from T_CLOSE_SQUARE_BRACKET to T_ATTRIBUTE_END".PHP_EOL; + if (PHP_CODESNIFFER_VERBOSITY > 1) { + echo "\t\t* token $bracketCloser changed from T_CLOSE_SQUARE_BRACKET to T_ATTRIBUTE_END".PHP_EOL; + } } - $newStackPtr++; continue; }//end if @@ -2266,7 +2268,7 @@ protected function tokenize($string) } if ($prevNonEmpty === null - && isset(Tokens::$emptyTokens[$tokenType]) === false + && @isset(Tokens::$emptyTokens[$tokenType]) === false ) { // Found the previous non-empty token. if ($tokenType === ':' || $tokenType === ',' || $tokenType === T_ATTRIBUTE_END) { @@ -2285,8 +2287,8 @@ protected function tokenize($string) if ($tokenType === T_FUNCTION || $tokenType === T_FN - || isset(Tokens::$methodPrefixes[$tokenType]) === true - || isset(Tokens::$scopeModifiers[$tokenType]) === true + || @isset(Tokens::$methodPrefixes[$tokenType]) === true + || @isset(Tokens::$scopeModifiers[$tokenType]) === true || $tokenType === T_VAR || $tokenType === T_READONLY ) { @@ -2309,7 +2311,7 @@ protected function tokenize($string) break; } - if (isset(Tokens::$emptyTokens[$tokenType]) === false) { + if (@isset(Tokens::$emptyTokens[$tokenType]) === false) { $lastSeenNonEmpty = $tokenType; } }//end for