diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index f2d1e7f9c2..749a1d943e 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -205,7 +205,7 @@ public function processBracket(PHP_CodeSniffer_File $phpcsFile, $openBracket, $t } $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true); - if ($tokens[$next]['line'] !== ($tokens[$i]['line'] + 1)) { + if ($tokens[$next]['line'] === $tokens[$i]['line']) { $error = 'Multi-line '.$type.' declarations must define one parameter per line'; $fix = $phpcsFile->addFixableError($error, $next, $errorPrefix.'OneParamPerLine'); if ($fix === true) { diff --git a/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc b/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc index d17e743900..469694ea97 100644 --- a/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc +++ b/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc @@ -152,3 +152,12 @@ function foo( ) { // body } + +function foo( + $param1, + + $param2, + + $param3, +) : SomeClass { +} diff --git a/package.xml b/package.xml index e4d2f30a7d..feaa0f5d97 100644 --- a/package.xml +++ b/package.xml @@ -28,6 +28,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> - The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2 - PEAR.Functions.FunctionDeclaration no longer reports indent errors for blank lines in a function declaration + - Squiz.Functions.MultiLineFunctionDeclaration no longer reports errors for blank lines in a function declaration + -- It would previously report that only one argument is allowed per line - Squiz.Commenting.FunctionComment now corrects multi-line param comment padding more accurately - Squiz.Commenting.FunctionComment now properly fixes pipe-seperated param types - Squiz.Commenting.FunctionComment now works correctly when function return types also contain a comment