@@ -54,8 +54,12 @@ public function register()
54
54
*/
55
55
public function process (File $ phpcsFile , $ stackPtr )
56
56
{
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
+ }
59
63
60
64
$ nextNonEmpty = $ phpcsFile ->findNext (Tokens::$ emptyTokens , ($ stackPtr + 1 ), null , true );
61
65
if ($ nextNonEmpty === false ) {
@@ -81,8 +85,11 @@ public function process(File $phpcsFile, $stackPtr)
81
85
82
86
$ nextNonWhitespace = $ phpcsFile ->findNext (T_WHITESPACE , ($ stackPtr + 1 ), null , true );
83
87
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
+ ];
86
93
$ phpcsFile ->addError ($ error , $ stackPtr , 'CommentFound ' , $ data );
87
94
88
95
if ($ tokens [($ stackPtr + 1 )]['code ' ] === T_WHITESPACE ) {
@@ -107,9 +114,10 @@ public function process(File $phpcsFile, $stackPtr)
107
114
return ;
108
115
}
109
116
110
- $ error = 'Expected %s space(s) after the spread operator; %s found ' ;
117
+ $ error = 'Expected %s space%s after the spread operator; %s found ' ;
111
118
$ data = [
112
119
$ this ->spacing ,
120
+ $ pluralizeSpace ,
113
121
$ found ,
114
122
];
115
123
0 commit comments