Skip to content
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

Issue #333: add cross-version support for anonymous classes to the RemovedGlobalVariable sniff #393

Merged
merged 1 commit into from
Apr 15, 2017

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 10, 2017

Prevent false positives for class properties named after removed PHP superglobals in PHPCS 2.4.0-2.7.1.

  • Pre-PHPCS 2.4.0, the T_ANON_CLASS token was recognized as T_CLASS and supported as such which works perfectly for our purposes.
  • PHPCS 2.4.0 - 2.7.1 supported the T_ANON_CLASS token, but did not consistently take it into account in all the relevant methods, like getMemberProperties().
  • This was finally fixed in PHPCS 2.8.0.

As there is another upcoming sniff which will run into the same issue, I've abstracted the code to determine whether a variable is a class property to a method in the PHPCompatibility_Sniff.

Includes unit tests both for anonymous class support in the RemovedGlobalVariable sniff, as well as for the new utility method.

Fixes #333

One of several PRs to fix #351

@coveralls
Copy link

coveralls commented Apr 10, 2017

Coverage Status

Coverage decreased (-0.4%) to 95.519% when pulling 02b727b on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@jrfnl jrfnl force-pushed the feature/fix-issue-333 branch 3 times, most recently from 19df8c8 to 3dfcfc7 Compare April 11, 2017 01:44
@coveralls
Copy link

coveralls commented Apr 11, 2017

Coverage Status

Coverage decreased (-2.9%) to 93.025% when pulling 3dfcfc7 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@coveralls
Copy link

coveralls commented Apr 11, 2017

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling 3dfcfc7 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@jrfnl jrfnl force-pushed the feature/fix-issue-333 branch 2 times, most recently from 70a6d8e to 6e5ef09 Compare April 11, 2017 02:51
@coveralls
Copy link

coveralls commented Apr 11, 2017

Coverage Status

Coverage decreased (-1.7%) to 94.21% when pulling 70a6d8e on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@coveralls
Copy link

coveralls commented Apr 11, 2017

Coverage Status

Coverage decreased (-0.8%) to 95.074% when pulling 6e5ef09 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@coveralls
Copy link

coveralls commented Apr 11, 2017

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling 1a380f3 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

5 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling 1a380f3 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling 1a380f3 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling 1a380f3 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling 1a380f3 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling 1a380f3 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

…lasses to the RemovedGlobalVariable sniff.

Prevent false positives for Class properties named after removed PHP superglobals in PHPCS 2.4.0-2.7.1.

Pre-PHPCS 2.4.0, the `T_ANON_CLASS` token was recognized as T_CLASS and supported as such which works perfectly for our purposes.

PHPCS 2.4.0 - 2.7.1 supported the T_ANON_CLASS *token*, but did not consistently take it into account in all the relevant methods, like `getMemberProperties()`.

This was finally fixed in PHPCS 2.8.0.

As there is another upcoming sniff which will run into the same issue, I've abstracted the code to determine whether a variable is a class property to a method in the `PHPCompatibility_Sniff`.

Includes unit tests both for anonymous class support in the RemovedGlobalVariable sniff, as well as for the new utility method.
@coveralls
Copy link

coveralls commented Apr 12, 2017

Coverage Status

Coverage increased (+0.04%) to 95.937% when pulling e21e3c1 on jrfnl:feature/fix-issue-333 into aabac47 on wimg:master.

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.

Improve sniff support for anonymous classes False positive: Long arrays vs Anonymous classes
3 participants