@@ -166,7 +166,12 @@ private function checkModifiersOrder(File $phpcsFile, int $propertyPointer, int
166166 $ expectedModifiersFormatted = implode (' ' , $ expectedModifiers );
167167
168168 $ fix = $ phpcsFile ->addFixableError (
169- sprintf ('Incorrect order of property modifiers "%s", expected "%s". ' , $ actualModifiersFormatted , $ expectedModifiersFormatted ),
169+ sprintf (
170+ 'Incorrect order of modifiers "%s" of property %s, expected "%s". ' ,
171+ $ actualModifiersFormatted ,
172+ $ tokens [$ propertyPointer ]['content ' ],
173+ $ expectedModifiersFormatted
174+ ),
170175 $ firstModifierPointer ,
171176 self ::CODE_INCORRECT_ORDER_OF_MODIFIERS
172177 );
@@ -204,8 +209,10 @@ private function checkTypeHintSpacing(File $phpcsFile, int $propertyPointer, int
204209 $ previousPointer = TokenHelper::findPreviousEffective ($ phpcsFile , $ typeHintStartPointer - 1 , $ lastModifierPointer );
205210 $ nullabilitySymbolPointer = $ previousPointer !== null && $ tokens [$ previousPointer ]['code ' ] === T_NULLABLE ? $ previousPointer : null ;
206211
212+ $ propertyName = $ tokens [$ propertyPointer ]['content ' ];
213+
207214 if ($ tokens [$ lastModifierPointer + 1 ]['code ' ] !== T_WHITESPACE ) {
208- $ errorMessage = 'There must be exactly one space before type hint nullability symbol. ' ;
215+ $ errorMessage = sprintf ( 'There must be exactly one space before type hint nullability symbol of property %s. ' , $ propertyName ) ;
209216 $ errorCode = self ::CODE_NO_SPACE_BEFORE_NULLABILITY_SYMBOL ;
210217
211218 $ fix = $ phpcsFile ->addFixableError ($ errorMessage , $ typeHintEndPointer , $ errorCode );
@@ -216,10 +223,13 @@ private function checkTypeHintSpacing(File $phpcsFile, int $propertyPointer, int
216223 }
217224 } elseif ($ tokens [$ lastModifierPointer + 1 ]['content ' ] !== ' ' ) {
218225 if ($ nullabilitySymbolPointer !== null ) {
219- $ errorMessage = 'There must be exactly one space before type hint nullability symbol. ' ;
226+ $ errorMessage = sprintf (
227+ 'There must be exactly one space before type hint nullability symbol of property %s. ' ,
228+ $ propertyName
229+ );
220230 $ errorCode = self ::CODE_MULTIPLE_SPACES_BEFORE_NULLABILITY_SYMBOL ;
221231 } else {
222- $ errorMessage = 'There must be exactly one space before type hint. ' ;
232+ $ errorMessage = sprintf ( 'There must be exactly one space before type hint of property %s. ' , $ propertyName ) ;
223233 $ errorCode = self ::CODE_MULTIPLE_SPACES_BEFORE_TYPE_HINT ;
224234 }
225235
@@ -233,7 +243,7 @@ private function checkTypeHintSpacing(File $phpcsFile, int $propertyPointer, int
233243
234244 if ($ tokens [$ typeHintEndPointer + 1 ]['code ' ] !== T_WHITESPACE ) {
235245 $ fix = $ phpcsFile ->addFixableError (
236- 'There must be exactly one space between type hint and property. ' ,
246+ sprintf ( 'There must be exactly one space between type hint and property %s. ' , $ propertyName ) ,
237247 $ typeHintEndPointer ,
238248 self ::CODE_NO_SPACE_BETWEEN_TYPE_HINT_AND_PROPERTY
239249 );
@@ -244,7 +254,7 @@ private function checkTypeHintSpacing(File $phpcsFile, int $propertyPointer, int
244254 }
245255 } elseif ($ tokens [$ typeHintEndPointer + 1 ]['content ' ] !== ' ' ) {
246256 $ fix = $ phpcsFile ->addFixableError (
247- 'There must be exactly one space between type hint and property. ' ,
257+ sprintf ( 'There must be exactly one space between type hint and property %s. ' , $ propertyName ) ,
248258 $ typeHintEndPointer ,
249259 self ::CODE_MULTIPLE_SPACES_BETWEEN_TYPE_HINT_AND_PROPERTY
250260 );
@@ -264,7 +274,7 @@ private function checkTypeHintSpacing(File $phpcsFile, int $propertyPointer, int
264274 }
265275
266276 $ fix = $ phpcsFile ->addFixableError (
267- 'There must be no whitespace between type hint nullability symbol and type hint. ' ,
277+ sprintf ( 'There must be no whitespace between type hint nullability symbol and type hint of property %s. ' , $ propertyName ) ,
268278 $ typeHintStartPointer ,
269279 self ::CODE_WHITESPACE_AFTER_NULLABILITY_SYMBOL
270280 );
0 commit comments