-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tokenizer/PHP: fix handling of "DNF look-a-likes" in named parameters #507
Tokenizer/PHP: fix handling of "DNF look-a-likes" in named parameters #507
Conversation
The last parameter in a function call using named arguments could be confused with a return type by the tokenizer layer handling type declarations. The net effect of this was that the close parenthesis of the function call would be retokenized to `T_TYPE_CLOSE_PARENTHESIS`, which is incorrect and would lead to sniffs incorrectly acting on that information. Fixed now. Includes tests. Fixes 504 Fixes 505
It would be good to get some tests added as part of this to safeguard that |
@fredden The test method these test cases feed into already does a check for tokens between the parentheses: PHP_CodeSniffer/tests/Core/Tokenizer/PHP/DNFTypesTest.php Lines 31 to 85 in 8f0d8de
Additionally, the original PR added tests with DNF types to both the union type as well as the intersection type test files: https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/461/files#diff-28273165881fe5292d6b2e5599fc0d72b4e80be50e07273d2d96e3a052dfe328 What additional tests did you have in mind ? |
No, but that looks like it covers the concern I had. I was expecting to see some changes to test files named "bitwise" and "parenthesis", but I didn't pause to check what test files already existed. From what I could see, it appeared that this was asserting that the new test cases were not DNF but nothing suggested that they are bitwise operators. I think this is adequately covered now. Thanks for updating this. |
…#507) The last parameter in a function call using named arguments could be confused with a return type by the tokenizer layer handling type declarations. The net effect of this was that the close parenthesis of the function call would be retokenized to `T_TYPE_CLOSE_PARENTHESIS`, which is incorrect and would lead to sniffs incorrectly acting on that information. Fixed now. Includes tests. Fixes 504 Fixes 505
Description
The last parameter in a function call using named arguments could be confused with a return type by the tokenizer layer handling type declarations.
The net effect of this was that the close parenthesis of the function call would be retokenized to
T_TYPE_CLOSE_PARENTHESIS
, which is incorrect and would lead to sniffs incorrectly acting on that information.Fixed now.
Includes tests.
Suggested changelog entry
Related issues/external references
Fixes #504
Fixes #505
Types of changes