Skip to content

Sniff::is_token_in_test_method(): allow for anonymous classes#1456

Merged
GaryJones merged 2 commits intodevelopfrom
feature/test-skipping-allow-for-anonymous-classes
Aug 24, 2018
Merged

Sniff::is_token_in_test_method(): allow for anonymous classes#1456
GaryJones merged 2 commits intodevelopfrom
feature/test-skipping-allow-for-anonymous-classes

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 19, 2018

While since #883, the Sniff::is_test_class() method already allowed for anonymous classes, the Sniff::is_token_in_test_method() did not.

Also, as OO structures can be nested in PHP, all relevant structures within which the test method is nested should be examined, not just the first encountered.

Note: examination of nested extended classes based on the class they extend is currently afflicted by a bug in PHPCS itself. I expect the bugfix I pulled for that to be included in the 3.3.2 release.
See: squizlabs/PHP_CodeSniffer#2127

This PR also adjusts the PrefixAllGlobals sniff to allow for anonymous test classes and traits extending test classes. Includes unit tests for this particular change.

jrfnl added 2 commits August 19, 2018 23:19
* Allow for anonymous classes.
* Examine all OO conditions a function is nested in for whether or not they are or extend test classes.
@GaryJones GaryJones merged commit 679cfc8 into develop Aug 24, 2018
@GaryJones GaryJones deleted the feature/test-skipping-allow-for-anonymous-classes branch August 24, 2018 18:15
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.

3 participants