WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

[Generic.Arrays.DisallowShort Array Syntax.Found] Short array syntax is not allowed

Open matheussant6s opened this issue 6 years ago • 3 comments

please change this by default to allow short array

matheussant6s avatar May 29 '20 06:05 matheussant6s

It was decided some time ago that WP should use array() instead of [] so I believe that's why that rule is set the way it is. In my own projects I always just add this in my phpcs.xml.dist files:

	<rule ref="WordPress">
		<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found" />
	</rule>
	<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found" />

It doesn't matter which one you choose (long or short syntax), what's more important is to keep it consistent

aristath avatar May 29 '20 06:05 aristath

Yes, I always do that too, thanks.

matheussant6s avatar May 29 '20 07:05 matheussant6s

This was changed in the core and if you want to, you can change it in your project as Ari suggested.

https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/

dingo-d avatar May 29 '20 08:05 dingo-d