-
-
Notifications
You must be signed in to change notification settings - Fork 468
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
Core: add sniffs to check formatting of increment/decrement operators #2130
Conversation
> 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Could be one of the noisier changes for 3.0.0.
True enough, but as it has an auto-fixer, it's a one time switch-over for which I have the commit ready already. |
For the record: in WP Core, the |
…nts. Note: This is enforced by WPCS 3.0.0: 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. References: * [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators] * [WordPress/WordPress-Coding-Standards#2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators] Props jrf. See #59161, #58831. Built from https://develop.svn.wordpress.org/trunk@56549 git-svn-id: https://core.svn.wordpress.org/trunk@56061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…nts. Note: This is enforced by WPCS 3.0.0: 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. References: * [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators] * [WordPress/WordPress-Coding-Standards#2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators] Props jrf. See #59161, #58831. Built from https://develop.svn.wordpress.org/trunk@56549 git-svn-id: http://core.svn.wordpress.org/trunk@56061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Core: add sniffs to check formatting of increment/decrement operators
Refs:
Universal.Operators.DisallowStandalonePostIncrementDecrement
sniff PHPCSStandards/PHPCSExtra#65Closes #1511
CS: clean up codebase for new rules / pre-increment