Skip to content

Commit e6e2a0c

Browse files
authored
Merge pull request #34 from inpsyde/issue-32
Allow blank line after single line declaration #32
2 parents 9bf9f0c + 9863f5e commit e6e2a0c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Inpsyde/Sniffs/CodeQuality/FunctionBodyStartSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function checkBodyStart(
8686

8787
$error =
8888
($isMultiLineDeclare || $isSingleLineSignature) && $bodyLine !== ($openerLine + 2)
89-
|| $isSingleLineDeclare && $bodyLine !== ($openerLine + 1);
89+
|| $isSingleLineDeclare && $bodyLine > ($openerLine + 2);
9090

9191
if (!$error) {
9292
return [null, null, null];

tests/fixtures/function-body-start.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ function foo()
88
return 'foo';
99
}
1010

11-
// @phpcsWarningCodeOnNextLine WrongForSingleLineDeclaration
11+
// tolerate this as PHPStorm code styler cannot distinguish between
12+
// single line and multiline function declarations. See issue #32
1213
function bar()
1314
{
1415

1516
return 'bar';
1617
}
1718

19+
// @phpcsWarningCodeOnNextLine WrongForSingleLineSignature
20+
function lorem() {
21+
22+
23+
return 'ipsum';
24+
}
25+
1826
// @phpcsWarningCodeOnNextLine WrongForMultiLineDeclaration
1927
function fooFoo(
2028
string $foo,
@@ -66,13 +74,19 @@ public function foo()
6674
return 'foo';
6775
}
6876

69-
// @phpcsWarningCodeOnNextLine WrongForSingleLineDeclaration
7077
private function bar()
7178
{
7279

7380
return 'bar';
7481
}
7582

83+
// @phpcsWarningCodeOnNextLine WrongForSingleLineSignature
84+
public function lorem() {
85+
86+
87+
return 'ipsum';
88+
}
89+
7690
// @phpcsWarningCodeOnNextLine WrongForMultiLineDeclaration
7791
protected function fooFoo(
7892
string $foo,

0 commit comments

Comments
 (0)