Skip to content

Commit b7fdd3e

Browse files
committed
PEAR.Functions.FunctionDeclaration no longer reports indent errors for blank lines in a function declaration (ref #1369)
1 parent ca8f28c commit b7fdd3e

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $st
346346
// We changed lines, so this should be a whitespace indent token.
347347
if ($tokens[$i]['code'] !== T_WHITESPACE) {
348348
$foundIndent = 0;
349+
} else if ($tokens[$i]['line'] !== $tokens[($i + 1)]['line']) {
350+
// This is an empty line, so don't check the indent.
351+
$foundIndent = $expectedIndent;
349352
} else {
350353
$foundIndent = strlen($tokens[$i]['content']);
351354
}

CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,12 @@ function foo(
200200
): SomeClass // Comment here
201201
{
202202
}
203+
204+
function foo(
205+
$param1,
206+
207+
$param2,
208+
209+
$param3,
210+
) : SomeClass {
211+
}

CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,12 @@ function foo(
205205
): SomeClass { // Comment here
206206

207207
}
208+
209+
function foo(
210+
$param1,
211+
212+
$param2,
213+
214+
$param3,
215+
) : SomeClass {
216+
}

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
2727
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
2828
<notes>
2929
- The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2
30+
- PEAR.Functions.FunctionDeclaration no longer reports indent errors for blank lines in a function declaration
3031
- Squiz.Commenting.FunctionComment now corrects multi-line param comment padding more accurately
3132
- Squiz.Commenting.FunctionComment now properly fixes pipe-seperated param types
3233
- Squiz.Commenting.FunctionComment now works correctly when function return types also contain a comment

0 commit comments

Comments
 (0)