@@ -330,11 +330,17 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
330
330
}
331
331
} else if ($ tokens [$ arrayEnd ]['column ' ] !== $ keywordStart ) {
332
332
// Check the closing bracket is lined up under the "a" in array.
333
- $ expected = ($ keywordStart - 1 );
334
- $ found = ($ tokens [$ arrayEnd ]['column ' ] - 1 );
335
- $ error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s ' ;
336
- $ data = [
333
+ $ expected = ($ keywordStart - 1 );
334
+ $ found = ($ tokens [$ arrayEnd ]['column ' ] - 1 );
335
+ $ pluralizeSpace = 's ' ;
336
+ if ($ expected === 1 ) {
337
+ $ pluralizeSpace = '' ;
338
+ }
339
+
340
+ $ error = 'Closing parenthesis not aligned correctly; expected %s space%s but found %s ' ;
341
+ $ data = [
337
342
$ expected ,
343
+ $ pluralizeSpace ,
338
344
$ found ,
339
345
];
340
346
@@ -674,12 +680,18 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
674
680
} else if ($ previousIsWhitespace === true ) {
675
681
$ expected = $ keywordStart ;
676
682
677
- $ first = $ phpcsFile ->findFirstOnLine (T_WHITESPACE , $ valuePointer , true );
678
- $ found = ($ tokens [$ first ]['column ' ] - 1 );
683
+ $ first = $ phpcsFile ->findFirstOnLine (T_WHITESPACE , $ valuePointer , true );
684
+ $ found = ($ tokens [$ first ]['column ' ] - 1 );
685
+ $ pluralizeSpace = 's ' ;
686
+ if ($ expected === 1 ) {
687
+ $ pluralizeSpace = '' ;
688
+ }
689
+
679
690
if ($ found !== $ expected ) {
680
- $ error = 'Array value not aligned correctly; expected %s spaces but found %s ' ;
691
+ $ error = 'Array value not aligned correctly; expected %s space%s but found %s ' ;
681
692
$ data = [
682
693
$ expected ,
694
+ $ pluralizeSpace ,
683
695
$ found ,
684
696
];
685
697
@@ -763,11 +775,17 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
763
775
}
764
776
765
777
if ($ tokens [$ indexPointer ]['column ' ] !== $ indicesStart && ($ indexPointer - 1 ) !== $ arrayStart ) {
766
- $ expected = ($ indicesStart - 1 );
767
- $ found = ($ tokens [$ indexPointer ]['column ' ] - 1 );
768
- $ error = 'Array key not aligned correctly; expected %s spaces but found %s ' ;
769
- $ data = [
778
+ $ expected = ($ indicesStart - 1 );
779
+ $ found = ($ tokens [$ indexPointer ]['column ' ] - 1 );
780
+ $ pluralizeSpace = 's ' ;
781
+ if ($ expected === 1 ) {
782
+ $ pluralizeSpace = '' ;
783
+ }
784
+
785
+ $ error = 'Array key not aligned correctly; expected %s space%s but found %s ' ;
786
+ $ data = [
770
787
$ expected ,
788
+ $ pluralizeSpace ,
771
789
$ found ,
772
790
];
773
791
@@ -779,15 +797,21 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
779
797
$ phpcsFile ->fixer ->replaceToken (($ indexPointer - 1 ), str_repeat (' ' , $ expected ));
780
798
}
781
799
}
782
- }
800
+ }//end if
783
801
784
802
$ arrowStart = ($ tokens [$ indexPointer ]['column ' ] + $ maxLength + 1 );
785
803
if ($ tokens [$ index ['arrow ' ]]['column ' ] !== $ arrowStart ) {
786
- $ expected = ($ arrowStart - ($ index ['index_length ' ] + $ tokens [$ indexPointer ]['column ' ]));
787
- $ found = ($ tokens [$ index ['arrow ' ]]['column ' ] - ($ index ['index_length ' ] + $ tokens [$ indexPointer ]['column ' ]));
788
- $ error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s ' ;
789
- $ data = [
804
+ $ expected = ($ arrowStart - ($ index ['index_length ' ] + $ tokens [$ indexPointer ]['column ' ]));
805
+ $ found = ($ tokens [$ index ['arrow ' ]]['column ' ] - ($ index ['index_length ' ] + $ tokens [$ indexPointer ]['column ' ]));
806
+ $ pluralizeSpace = 's ' ;
807
+ if ($ expected === 1 ) {
808
+ $ pluralizeSpace = '' ;
809
+ }
810
+
811
+ $ error = 'Array double arrow not aligned correctly; expected %s space%s but found %s ' ;
812
+ $ data = [
790
813
$ expected ,
814
+ $ pluralizeSpace ,
791
815
$ found ,
792
816
];
793
817
@@ -801,7 +825,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
801
825
}
802
826
803
827
continue ;
804
- }
828
+ }//end if
805
829
806
830
$ valueStart = ($ arrowStart + 3 );
807
831
if ($ tokens [$ valuePointer ]['column ' ] !== $ valueStart ) {
@@ -811,9 +835,15 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
811
835
$ found = 'newline ' ;
812
836
}
813
837
814
- $ error = 'Array value not aligned correctly; expected %s space(s) but found %s ' ;
838
+ $ pluralizeSpace = 's ' ;
839
+ if ($ expected === 1 ) {
840
+ $ pluralizeSpace = '' ;
841
+ }
842
+
843
+ $ error = 'Array value not aligned correctly; expected %s space%s but found %s ' ;
815
844
$ data = [
816
845
$ expected ,
846
+ $ pluralizeSpace ,
817
847
$ found ,
818
848
];
819
849
0 commit comments