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

False positive: Long arrays vs Anonymous classes #333

Closed
jrfnl opened this issue Jan 20, 2017 · 0 comments · Fixed by #393
Closed

False positive: Long arrays vs Anonymous classes #333

jrfnl opened this issue Jan 20, 2017 · 0 comments · Fixed by #393

Comments

@jrfnl
Copy link
Member

jrfnl commented Jan 20, 2017

The following code will trigger a false positive in PHPCS < 2.7.2.

$a = new class {
    // OK.
    private $HTTP_POST_VARS;

    function testing() {
        // Ok.
        self::$HTTP_POST_VARS;
    }
}

Related: #268

Upstream this was fixed in PHPCS 2.7.2(alpha) by adding support for T_ANON_CLASS in the PHP_Codesniffer_File->getMemberProperties() method.
squizlabs/PHP_CodeSniffer@0011d44

jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 10, 2017
…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.

Includes unit tests.
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 11, 2017
…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.
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 11, 2017
…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.
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 11, 2017
…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.
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 11, 2017
…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.
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 11, 2017
…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.
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 11, 2017
…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.
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Apr 12, 2017
…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.
@wimg wimg closed this as completed in #393 Apr 15, 2017
wimg added a commit that referenced this issue Apr 15, 2017
Issue #333: add cross-version support for anonymous classes to the RemovedGlobalVariable sniff
@jrfnl jrfnl added this to the 7.1.4 milestone May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant