WordPress-Coding-Standards
WordPress-Coding-Standards copied to clipboard
[Generic.Arrays.DisallowShort Array Syntax.Found] Short array syntax is not allowed
please change this by default to allow short array
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
Yes, I always do that too, thanks.
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/