Skip to content
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

Squiz/LowercasePHPFunctions + Generic/ForbiddenFunctions: bug fix for class names in attributes #3779

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Mar 20, 2023

Squiz/LowercasePHPFunctions: bug fix for class names in attributes

Attributes cannot contain function calls and in most cases, T_STRINGs in an attribute will be a class name, not a function name.

As things were, T_STRING's in attributes which looked like function calls (but in actual fact are class instantiations) would lead to false positives.

Fixed now by ignoring all code within attributes.

Includes unit test.

Fixes #3778

Generic/ForbiddenFunctions: bug fix for class names in attributes

Attributes cannot contain function calls and in most cases, T_STRINGs in an attribute will be a class name, not a function name.

As things were, T_STRING's in attributes which looked like function calls (but in actual fact are class instantiations) would lead to false positives.

Fixed now by ignoring all code within attributes.

Includes unit test.

Attributes cannot contain function calls and in most cases, `T_STRING`s in an attribute will be a class name, not a function name.

As things were, `T_STRING`'s in attributes which _looked_ like function calls (but in actual fact are class instantiations) would lead to false positives.

Fixed now by ignoring all code within attributes.

Includes unit test.

Fixes 3778
Attributes cannot contain function calls and in most cases, `T_STRING`s in an attribute will be a class name, not a function name.

As things were, `T_STRING`'s in attributes which _looked_ like function calls (but in actual fact are class instantiations) would lead to false positives.

Fixed now by ignoring all code within attributes.

Includes unit test.
@jrfnl
Copy link
Contributor Author

jrfnl commented Mar 20, 2023

Note: there may be more sniffs which need adjusting for this, but these were the first ones which came to mind when I saw the bug report.

@gsherwood gsherwood added this to the 3.8.0 milestone May 4, 2023
gsherwood added a commit that referenced this pull request May 4, 2023
@gsherwood gsherwood merged commit 033e975 into squizlabs:master May 4, 2023
@jrfnl jrfnl deleted the feature/3778-squiz-lowercasephpfunctions-bugfix branch May 4, 2023 07:47
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 8, 2023

FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.

As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Squiz.PHP.LowercasePHPFunctions incorrectly reports on attribute names
2 participants