Skip to content

Commit 7849092

Browse files
authored
Allow more commenting in BlankLineBeforeReturnSniff (#207)
closes GH-203
1 parent 2198569 commit 7849092

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

Symfony/Sniffs/Formatting/BlankLineBeforeReturnSniff.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ public function process(File $phpcsFile, $stackPtr)
6969
$spaceTokens = [
7070
'T_WHITESPACE',
7171
'T_COMMENT',
72+
'T_DOC_COMMENT_OPEN_TAG',
7273
'T_DOC_COMMENT_CLOSE_TAG',
74+
'T_DOC_COMMENT_TAG',
75+
'T_DOC_COMMENT_STRING',
7376
'T_DOC_COMMENT_WHITESPACE',
77+
'T_PHPCS_IGNORE',
7478
];
7579

7680
while ($current >= 0 && $tokens[$current]['line'] >= $previousLine) {

Symfony/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ function invalidFunctionReturnOne()
3737
return;
3838
}
3939

40+
function validFunctionReturnWithPhpcsIgnore1(): string
41+
{
42+
// phpcs:ignore Foobar.Whatever.Rule
43+
return foobar(1);
44+
}
45+
46+
function validFunctionReturnWithPhpcsIgnore2(): string
47+
{
48+
/* phpcs:ignore Foobar.Whatever.Rule */
49+
return foobar(1);
50+
}
51+
52+
function validFunctionReturnWithPhpcsIgnore3(): string
53+
{
54+
/** phpcs:ignore Foobar.Whatever.Rule */
55+
return foobar(1);
56+
}
57+
58+
function validFunctionReturnWithVariableDoc(): string
59+
{
60+
/** @psalm-var ClassName $variable */
61+
return foobar(1);
62+
}
63+
4064
switch ($condition) {
4165
case 'foo':
4266
return true;

Symfony/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ function invalidFunctionReturnOne()
3838
return;
3939
}
4040

41+
function validFunctionReturnWithPhpcsIgnore1(): string
42+
{
43+
// phpcs:ignore Foobar.Whatever.Rule
44+
return foobar(1);
45+
}
46+
47+
function validFunctionReturnWithPhpcsIgnore2(): string
48+
{
49+
/* phpcs:ignore Foobar.Whatever.Rule */
50+
return foobar(1);
51+
}
52+
53+
function validFunctionReturnWithPhpcsIgnore3(): string
54+
{
55+
/** phpcs:ignore Foobar.Whatever.Rule */
56+
return foobar(1);
57+
}
58+
59+
function validFunctionReturnWithVariableDoc(): string
60+
{
61+
/** @psalm-var ClassName $variable */
62+
return foobar(1);
63+
}
64+
4165
switch ($condition) {
4266
case 'foo':
4367
return true;

0 commit comments

Comments
 (0)