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

Core: add sniffs to check formatting of increment/decrement operators #2130

Merged
merged 2 commits into from
Dec 7, 2022

Commits on Dec 7, 2022

  1. Core: add sniffs to check formatting of increment/decrement operators

    > 1. There should be no space between an increment/decrement operator and the variable it applies to.
    > 2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements.
    >    “Pre” will in/decrement and then return, “post” will return and then in/decrement.
    >    Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around.
    
    Refs:
    * https://make.wordpress.org/core/2020/03/20/updating-the-coding-standards-for-modern-php/ - Increment/decrement operators section
    * https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#space-usage
    * https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators
    * WordPress/wpcs-docs 112
    * WordPress/WordPress-Coding-Standards 1511
    * squizlabs/PHP_CodeSniffer 2172
    * squizlabs/PHP_CodeSniffer 2174
    * PHPCSStandards/PHPCSExtra 65
    
    Closes 1511
    jrfnl committed Dec 7, 2022
    Configuration menu
    Copy the full SHA
    76cb0db View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fdea379 View commit details
    Browse the repository at this point in the history