Skip to content

Commit 66bbdd8

Browse files
committed
Merge branch 'feature/psr12-controlstructurespacing-allow-fix-comments' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 787b92f + 7aec50f commit 66bbdd8

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function process(File $phpcsFile, $stackPtr)
9595
for ($i = $parenOpener; $i < $parenCloser; $i++) {
9696
if ($tokens[$i]['column'] !== 1
9797
|| $tokens[($i + 1)]['line'] > $tokens[$i]['line']
98+
|| isset(Tokens::$commentTokens[$tokens[$i]['code']]) === true
9899
) {
99100
continue;
100101
}

src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,14 @@ EOD
7373
) {
7474
return;
7575
}
76+
77+
if (
78+
isset($foo) === true
79+
&& $bar > $foo
80+
/*
81+
* A multi-line comment.
82+
*/
83+
&& $foo === true
84+
) {
85+
break;
86+
}

src/Standards/PSR12/Tests/ControlStructures/ControlStructureSpacingUnitTest.inc.fixed

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,14 @@ EOD
7474
) {
7575
return;
7676
}
77+
78+
if (
79+
isset($foo) === true
80+
&& $bar > $foo
81+
/*
82+
* A multi-line comment.
83+
*/
84+
&& $foo === true
85+
) {
86+
break;
87+
}

0 commit comments

Comments
 (0)