1 year ago
#359671
mirza
how to disallow arrays with extra whitespaces with php codesniffer ruleset?
I tried couple of sniffs in my phpcs.xml file but couldn't come up with a solution for such cases:
$arrays = array("1", 2, 2 , 3 ); // not allowed due to extra whitespaces
$arrays = [1 , 2 , 3, 4]; // not allowed
$arrays = [1, 2, 3, 4]; // allowed
$arrays = [1,2,3,4]; // also can be allowed
this is what I've tried:
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Arrays.ArrayDeclaration">
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned" />
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned" />
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned" />
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned" />
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline" />
<exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed" />
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed" />
</rule>
php
static-analysis
phpcs
0 Answers
Your Answer