-
Notifications
You must be signed in to change notification settings - Fork 40
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
Do not flag self, static nor this in an anonymous function declared in class scope #82
Comments
@david-binda This is something covered in PHPCompatibility: PHPCompatibility/PHPCompatibility#669 - can we close this Issue out? |
I'm going to presumptively close this out. Can be re-opened if necessary. |
Re-opening because this is flagging false positives for |
Can you give some example code? |
Sure, the one illustrated above throws a false positive. That should not be flagged. |
I updated the OP to fix non-related violations in the demo code. Running it with: .composer/vendor/bin/phpcs --standard=WordPress-Extra,WordPress-VIP-Go ~/test.php -s Gave me:
Which seems correct - there is a I don't see any violation related the |
I believe that this issue should be reported upstream and handled there. The See https://3v4l.org/B43Uj and https://3v4l.org/sdJ6Q with code examples and their processing in different PHP versions (works as expected in PHP 5.4+). The But really, this is more for upstream, which I'll do shortly. Let me copy the code examples here, for more posterity:
and
|
Looks like it's been fixed upstream now but our version is out of sync with upstream. Perhaps it's time for syncing with upstream, @GaryJones? If not (since I see that we already done some of our own modifications inside the sniff), another option would be to make the error message clearer like: Use of `static::$_type` inside closure should not be used outside of class. Manual inspection required. |
Thank you for demos - I now understand that the code works fine, and the violation no longer needs to be reported (for PHP 5.4 and later at least). I think there are more benefits to be gained by pulling in @sirbrillig's package, so let's keep this open until that's done, but no separate action should be needed here. The other ticket can focus on where we might already have made changes to our current version. |
Now that #449 is completed to use VariableAnalysis proper, I've confirmed that the provided examples above don't give an error with the |
Related code: https://github.com/Automattic/VIP-Coding-Standards/blob/master/WordPressVIPMinimum/Sniffs/Variables/VariableAnalysisSniff.php#L853
Example code producing false-positives:
The text was updated successfully, but these errors were encountered: