You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$lastNonEmptyToken was only used to store the last non-whitespace token. Changing this store the last non-empty token as per the token util class gets this working and doesn't look to break anything.
gsherwood
changed the title
PHP Tokenizer bug: use function/const not always tokenized as T_STRING
Use function/const not tokenized as T_STRING when preceded by comment
Feb 27, 2019
As noted inline:
> In PHPCS < 3.4.1, the class keyword after a double colon + comment may be tokenized as
> `T_CLASS` instead of as `T_STRING`, so registering both.
Adjusted an existing unit test to safeguard this change.
Upstream issue about the tokenizer problem:
* squizlabs/PHP_CodeSniffer#2431
jrfnl
added a commit
to PHPCompatibility/PHPCompatibility
that referenced
this issue
Aug 10, 2020
As noted inline:
> In PHPCS < 3.4.1, the class keyword after a double colon + comment may be tokenized as
> `T_CLASS` instead of as `T_STRING`, so registering both.
Adjusted an existing unit test to safeguard this change.
Upstream issue about the tokenizer problem:
* squizlabs/PHP_CodeSniffer#2431
The
function
andconst
keywords used inuse
statements are normally tokenized asT_STRING
.However, when there is a comment between the
use
keyword and thefunction
/const
keyword, this fails and they are tokenized asT_FUNCTION
/T_CONST
.Example code where the tokenizer correction fails:
Relevant code in the Tokenizer:
PHP_CodeSniffer/src/Tokenizers/PHP.php
Lines 1418 to 1427 in e4da24f
As that code appears to look at the
$lastNonEmptyToken
, I'm not sure how to fix this....The text was updated successfully, but these errors were encountered: