@@ -113,7 +113,7 @@ public function process(File $phpcsFile, int $stackPtr)
113113 }
114114
115115 $ error = 'Language constructs must be followed by a single space; expected 1 space between YIELD FROM found "%s" ' ;
116- $ data = [Common::prepareForOutput ($ found )];
116+ $ data = [Common::prepareForOutput ($ found, [ ' ' ] )];
117117
118118 if ($ hasComment === true ) {
119119 $ phpcsFile ->addError ($ error , $ stackPtr , 'IncorrectYieldFromWithComment ' , $ data );
@@ -139,8 +139,16 @@ public function process(File $phpcsFile, int $stackPtr)
139139 if ($ tokens [($ stackPtr + 1 )]['code ' ] === T_WHITESPACE ) {
140140 $ content = $ tokens [($ stackPtr + 1 )]['content ' ];
141141 if ($ content !== ' ' ) {
142- $ error = 'Language constructs must be followed by a single space; expected 1 space but found "%s" ' ;
143- $ data = [Common::prepareForOutput ($ content )];
142+ if (trim ($ content , ' ' ) === '' ) {
143+ // Only space characters: report the count.
144+ $ found = $ tokens [($ stackPtr + 1 )]['length ' ] . ' spaces ' ;
145+ } else {
146+ // Contains tabs or newlines: make them visible.
147+ $ found = '" ' . Common::prepareForOutput ($ content , [' ' ]) . '" ' ;
148+ }
149+
150+ $ error = 'Language constructs must be followed by a single space; expected 1 space but found %s ' ;
151+ $ data = [$ found ];
144152 $ fix = $ phpcsFile ->addFixableError ($ error , $ stackPtr , 'IncorrectSingle ' , $ data );
145153 if ($ fix === true ) {
146154 $ phpcsFile ->fixer ->replaceToken (($ stackPtr + 1 ), ' ' );
0 commit comments