-
-
Notifications
You must be signed in to change notification settings - Fork 492
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 upstream Generic.Arrays.DisallowShortArraySyntax sniff #1770
Conversation
Recently a new section has been added to the handbook which forbids the use of short arrays. > Using long array syntax ( array( 1, 2, 3 ) ) for declaring arrays is generally more readable than short array syntax ( [ 1, 2, 3 ] ), particularly for those with vision difficulties. Additionally, it’s much more descriptive for beginners. > > Arrays must be declared using long array syntax. https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#declaring-arrays This PR add an existing upstream sniff which addresses this. Includes auto-fixer. Also see: https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/ Loosely related to 764
I presume to override this, folks can do something like: <rule ref="Generic.Arrays.DisallowShortArraySyntax">
<severity>0</severity>
</rule> ...with an optional: <rule ref="Generic.Arrays.DisallowLongArraySyntax"/> |
@GaryJones Correct. Alternatively for the first code snippet, you can use: <rule ref="WordPresss">
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
</rule> (within WPCS we use |
Since https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/ explicitly says these changes are only intended for WP core itself:
I'm wondering whether the addition could have been made to https://core.trac.wordpress.org/browser/trunk/phpcs.xml.dist instead of to the standards that all of the community would be using. |
@GaryJones I hear you, but I believe that discussion has been had numerous times already and the conclusion was always that the rulesets in WPCS follow the |
WPCS wants arrays to be declared using long array syntax in WordPress Core: WordPress/WordPress-Coding-Standards#1770 https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/
Recently a new section has been added to the handbook which forbids the use of short arrays.
https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#declaring-arrays
This PR add an existing upstream sniff which addresses this.
Includes auto-fixer.
Also see: https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/
Loosely related to #764