Dave Kellam
Posted on May 2, 2023
At Plank, we use the WordPress Coding Standards in our development process. It helps ensure that everyone is writing code in a similar style, and that we follow best practices (like escaping and sanitizing data).
That said, we don't necessarily agree with all of the rules. In particular, we prefer using the short array syntax for php arrays. We find it easier to find when an array closes, rather than searching through a sea of closing parentheses ();););
).
If you're using your own custom ruleset to extend the default standards, you do something like this to allow the short array syntax. If you really don't like the long array syntax, you can disallow it, and phpcbf
should convert to short arrays with the second pattern.
<!-- Allow short syntax arrays. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Disallow long array syntax -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
<exclude-pattern>*</exclude-pattern>
</rule>
Posted on May 2, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.