-
Notifications
You must be signed in to change notification settings - Fork 545
Add rule checking arguments to unset (#2605) #25
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice :) Also make sure to run vendor/bin/phing locally before submitting a PR next time, thanks.
I found a few points. Also, I'm not sure if we want to report "possibly undefined variable" - it's perfectly fine to unset something that might (but doesn't have to) exist.
I've removed the "possibly undefined variable" check and fixed your other remarks, thanks for reviewing.
Hi, I spent a little bit more time to bring the rule over the finish line. Here are the changes from your PR to mine: https://gist.github.com/ondrejmirtes/1f8b2512798df18baa579a39453946f9
- You forgot to add the rule to a level. It wouldn't run at all.
- Changed namespace.
- I moved the if about iterable key type to IterableType.
- I changed the return type of canBeUnset to
?RuleError. - I added recursion so that this case is reported too:
unset($notSetVariable['a']);
Thanks!
Please feel free to do a similar thing for ?? operator - PhpParser\Node\Expr\BinaryOp\Coalesce node.
Also, similarly, this isn't detected: https://phpstan.org/r/b56820c1-0e96-45b5-9f98-58dc0fe96d58
We only have VariableCertaintyInIssetRule.
Thanks for finishing this up! I just realized I kept missing the Travis warnings when running the build locally (on windows), because it stops somewhere along the way. I'll try to figure out why that is.
Adds a rule for checking the arguments to
unset. Fixes #2605.