-
-
Notifications
You must be signed in to change notification settings - Fork 87
Description
While working on something else, I noticed a number of error messages in various sniffs using concatenation instead of passing variable parts of the error message to the add[Fixable]Error/Warning()
methods via a $data
array.
These are likely left-overs from long ago.
I believe it would be prudent to fix these up to follow the best practice of using %s
placeholders and a $data
array.
I seem to remember that even messages with placeholders can be changed from within a phpcs.xml[.dist]
ruleset.
Before executing this action, it should be investigated whether updating the error messages would constitute a breaking change. And if so, it will need to be evaluated if this action needs to wait until the next major release of PHPCS or can be included in an earlier minor/patch version.
Action list
Action list based on what I came across (likely to be reasonably complete, though a critical look at all error messages in the sniffs involved is warranted):
-
PHP_CodeSniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
Line 419 in fcfefc6
$error = 'The closing parenthesis of a multi-line '.$type.' declaration must be on a new line'; -
PHP_CodeSniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
Line 476 in fcfefc6
$error = 'Blank lines are not allowed in a multi-line '.$type.' declaration'; -
PHP_CodeSniffer/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
Line 492 in fcfefc6
$error = 'Multi-line '.$type.' declaration not indented correctly; expected %s spaces but found %s'; -
$error = 'The '.$keywordType.' keyword must be on the same line as the %s '.$compareType; -
$error = 'Expected 1 space before '.$keywordType.' keyword; %s found'; -
PHP_CodeSniffer/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 72 in fcfefc6
$error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; -
PHP_CodeSniffer/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 103 in fcfefc6
$error = 'There must be no space before the colon in a '.strtoupper($type).' statement'; -
PHP_CodeSniffer/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 120 in fcfefc6
$error = 'The '.strtoupper($type).' body must start on the line following the statement'; -
PHP_CodeSniffer/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 174 in fcfefc6
$error = strtoupper($type).' statements must be defined using a colon'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 82 in c5e7f48
$error = strtoupper($type).' keyword must be lowercase; expected "%s" but found "%s"'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 95 in c5e7f48
$error = strtoupper($type).' keyword must be indented '.$this->indent.' spaces from SWITCH keyword'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 132 in c5e7f48
$error = 'There must be no space before the colon in a '.strtoupper($type).' statement'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 152 in c5e7f48
$error = 'Case breaking statement must be indented '.$this->indent.' spaces from SWITCH keyword'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Line 224 in c5e7f48
$error = 'Blank lines are not allowed after '.strtoupper($type).' statements'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php
Line 206 in c5e7f48
$error = 'Incorrect spacing between argument "%s" and equals sign; expected '.$this->equalsSpacing.' but found %s'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php
Line 240 in c5e7f48
$error = 'Incorrect spacing between default value and equals sign for argument "%s"; expected '.$this->equalsSpacing.' but found %s'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php
Line 191 in c5e7f48
$error = 'The first parameter of a multi-line '.$type.' declaration must be on the line after the opening bracket'; -
PHP_CodeSniffer/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php
Line 238 in c5e7f48
$error = 'Multi-line '.$type.' declarations must define one parameter per line';