-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Suggestion: make isset, unset and empty parenthesis owners #3118
Comments
PHPCS natively does not consider `isset()`, `unset()`, `empty()`, `exit()`, `die()` and `eval()` as parentheses owners. As of now, the methods in the PHPCSUtils `Parentheses` class will. If effect, this means you can now check whether an arbitrary token is within an `isset()`, `unset()` or `empty()` call by calling: ```php if (Parentheses::hasOwner($phpcsFile, $stackPtr, [\T_ISSET, \T_UNSET, \T_EMPTY]) !== false) { // Do something. } ``` Related issue upstream: squizlabs/PHP_CodeSniffer#3118
Makes sense to me. For the constructs that don't require parenthesis, just need to make sure they don't go hunting for unowned ones and claiming them, although this may already be protected against. |
Eh.. not really... that's part of the problem with closure With that in mind, should this be addressed in PHPCS 3.x or 4.x ? (PR #3104 is for 4.x and includes part of the protection which would need to be added for the above as well.) |
Closing as replaced by PHPCSStandards/PHP_CodeSniffer#23 |
I was just wondering why
isset()
,unset()
andempty()
- all language constructs which require parentheses - are not considered parentheses owners.Would it make sense to change that ? Should be a relatively easy change to make as far as I can see.
Happy to make the changes if there is interest.
[Edit]: Might be useful to include
exit()
,die()
andeval()
as well, though these three don't require parentheses, but are "owners" when the parentheses are present.The text was updated successfully, but these errors were encountered: