Closed
Description
The function
and const
keywords used in use
statements are normally tokenized as T_STRING
.
However, when there is a comment between the use
keyword and the function
/const
keyword, this fails and they are tokenized as T_FUNCTION
/T_CONST
.
Example code where the tokenizer correction fails:
use /* comment */ function bar\math\{
Msin,
level\Mcos as BarCos,
Mcosh,
};
use // phpcs:ignore Standard.Category
const
bar\math\{ BGAMMA as BAR_GAMMA, BGOLDEN_RATIO };
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....