diff --git a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index 8a39744184..c93dc80157 100644 --- a/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -349,6 +349,12 @@ public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $st } else if ($tokens[$i]['line'] !== $tokens[($i + 1)]['line']) { // This is an empty line, so don't check the indent. $foundIndent = $expectedIndent; + + $error = 'Blank lines are not allowed in a multi-line function declaration'; + $fix = $phpcsFile->addFixableError($error, $i, 'EmptyLine'); + if ($fix === true) { + $phpcsFile->fixer->replaceToken($i, ''); + } } else { $foundIndent = strlen($tokens[$i]['content']); } diff --git a/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed b/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed index 870b3252c7..239ad18f67 100644 --- a/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed +++ b/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed @@ -208,9 +208,7 @@ function foo( function foo( $param1, - $param2, - $param3, ) : SomeClass { } diff --git a/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php b/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php index ad33f2c208..943b94917e 100644 --- a/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php +++ b/CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.php @@ -67,6 +67,8 @@ public function getErrorList() 171 => 1, 173 => 1, 201 => 1, + 206 => 1, + 208 => 1, ); }//end getErrorList() diff --git a/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php b/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php index 9c515b2d75..bcb05f3add 100644 --- a/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php +++ b/CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.php @@ -63,6 +63,8 @@ public function getErrorList($testFile='MultiLineFunctionDeclarationUnitTest.inc 137 => 1, 141 => 2, 142 => 1, + 158 => 1, + 160 => 1, ); } else { $errors = array( diff --git a/package.xml b/package.xml index feaa0f5d97..84c884d1b1 100644 --- a/package.xml +++ b/package.xml @@ -27,6 +27,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> BSD 3-Clause License - The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2 + - PEAR.Functions.FunctionDeclaration now reports an error for blank lines found inside a function declaration - 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 @@ -45,6 +46,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - Fixed bug #1349 : Squiz.Strings.DoubleQuoteUsage.NotRequired message is badly formatted when string contains a CR newline char -- Thanks to Algirdas Gurevicius for the patch - Fixed bug #1350 : Invalid Squiz.Formatting.OperatorBracket error when using namespaces + - Fixed bug #1369 : Empty line in multi-line function declaration cause infinite loop