@@ -54,8 +54,12 @@ public function register()
5454 */
5555 public function process (File $ phpcsFile , $ stackPtr )
5656 {
57- $ tokens = $ phpcsFile ->getTokens ();
58- $ this ->spacing = (int ) $ this ->spacing ;
57+ $ tokens = $ phpcsFile ->getTokens ();
58+ $ this ->spacing = (int ) $ this ->spacing ;
59+ $ pluralizeSpace = 's ' ;
60+ if ($ this ->spacing === 1 ) {
61+ $ pluralizeSpace = '' ;
62+ }
5963
6064 $ nextNonEmpty = $ phpcsFile ->findNext (Tokens::$ emptyTokens , ($ stackPtr + 1 ), null , true );
6165 if ($ nextNonEmpty === false ) {
@@ -81,8 +85,11 @@ public function process(File $phpcsFile, $stackPtr)
8185
8286 $ nextNonWhitespace = $ phpcsFile ->findNext (T_WHITESPACE , ($ stackPtr + 1 ), null , true );
8387 if ($ nextNonEmpty !== $ nextNonWhitespace ) {
84- $ error = 'Expected %s space(s) after the spread operator; comment found ' ;
85- $ data = [$ this ->spacing ];
88+ $ error = 'Expected %s space%s after the spread operator; comment found ' ;
89+ $ data = [
90+ $ this ->spacing ,
91+ $ pluralizeSpace ,
92+ ];
8693 $ phpcsFile ->addError ($ error , $ stackPtr , 'CommentFound ' , $ data );
8794
8895 if ($ tokens [($ stackPtr + 1 )]['code ' ] === T_WHITESPACE ) {
@@ -107,9 +114,10 @@ public function process(File $phpcsFile, $stackPtr)
107114 return ;
108115 }
109116
110- $ error = 'Expected %s space(s) after the spread operator; %s found ' ;
117+ $ error = 'Expected %s space%s after the spread operator; %s found ' ;
111118 $ data = [
112119 $ this ->spacing ,
120+ $ pluralizeSpace ,
113121 $ found ,
114122 ];
115123
0 commit comments