Skip to content

Commit 244d084

Browse files
committed
Squiz.Functions.MultiLineFunctionDeclaration no longer reports errors for blank lines in a function declaration (ref #1369)
1 parent b7fdd3e commit 244d084

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function processBracket(PHP_CodeSniffer_File $phpcsFile, $openBracket, $t
205205
}
206206

207207
$next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true);
208-
if ($tokens[$next]['line'] !== ($tokens[$i]['line'] + 1)) {
208+
if ($tokens[$next]['line'] === $tokens[$i]['line']) {
209209
$error = 'Multi-line '.$type.' declarations must define one parameter per line';
210210
$fix = $phpcsFile->addFixableError($error, $next, $errorPrefix.'OneParamPerLine');
211211
if ($fix === true) {

CodeSniffer/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc

+9
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,12 @@ function foo(
152152
) {
153153
// body
154154
}
155+
156+
function foo(
157+
$param1,
158+
159+
$param2,
160+
161+
$param3,
162+
) : SomeClass {
163+
}

package.xml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
2828
<notes>
2929
- The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2
3030
- PEAR.Functions.FunctionDeclaration no longer reports indent errors for blank lines in a function declaration
31+
- Squiz.Functions.MultiLineFunctionDeclaration no longer reports errors for blank lines in a function declaration
32+
-- It would previously report that only one argument is allowed per line
3133
- Squiz.Commenting.FunctionComment now corrects multi-line param comment padding more accurately
3234
- Squiz.Commenting.FunctionComment now properly fixes pipe-seperated param types
3335
- Squiz.Commenting.FunctionComment now works correctly when function return types also contain a comment

0 commit comments

Comments
 (0)