NewClosure: report usage of self/parent/static for PHP < 5.4 + prevent double notices #669
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NewClosure: prevent double reporting for nested closures
As pointed out by @moorscode, closures can be nested within closures. As the sniff was, that would result in the notices for the inner closure being thrown twice.
The first commit fixes this.
Includes unit test, though this can not be automatically tested with the unit test framework as is.
The unit test is there so manual testing will pick up on it.
PHP 5.4: NewClosure: report on
self/parent/static::
being used in PHP < 5.4Not mentioned in the manual, but both the test sample provided by @asadkn as well as further tests I ran confirmed that this was changed in PHP 5.4
Includes unit tests.
Fixes #668