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

PHPCS: set the minimum supported WP version via a property #131

Merged

Commits on May 17, 2019

  1. PHPCS: set the minimum supported WP version via a property

    Properties are supposed to be set per sniff, but (bug or feature?) it turns out that setting them for a standard will set them for all sniffs included in that standard.
    
    Sniffs which don't use the property will just ignore it.
    Sniffs which do use it, now have it available as if it were set for the individual sniff.
    
    As this was unknown (and possibly/probably not supported) in the past with older PHPCS versions, WPCS added the ability to set the `minimum_supported_wp_version` for all sniffs in one go via a `config`directive.
    
    The problem with a `config` directive is that it is currently impossible to overrule it from a repo ruleset. It can only be overruled on the command-line, and even then only since PHPCS 3.3.0.
    
    For that reason, the `config` directive was previously set in each individual repo ruleset.
    
    Properties, however, can easily be overruled from within repo rulesets, so this change will allow us to manage the "_minimum supported WP version_" centrally, while still allowing for individual repos to overrule the default value.
    
    Ref:
    * https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters - WPCS documentation about the property/config directive.
    * squizlabs/PHP_CodeSniffer#2501 - PR through which this "feature" was discovered, included unit tests demonstrating it.
    * squizlabs/PHP_CodeSniffer#1821 - Issue which made the config directive possible to be overruled from the command-line.
    * squizlabs/PHP_CodeSniffer#2197 Feature request to allow for config directives to be overruled by other rulesets.
    jrfnl committed May 17, 2019
    Configuration menu
    Copy the full SHA
    0439452 View commit details
    Browse the repository at this point in the history