Skip to content

Commit 19c8127

Browse files
committed
Further fix for #2810 to make the new check more specific
1 parent 0547626 commit 19c8127

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public function process(File $phpcsFile, $stackPtr)
7777

7878
if ($tokens[$nonSpace]['code'] === T_SEMICOLON
7979
|| ($forCondition === true && $nonSpace === $tokens[$owner]['parenthesis_opener'])
80-
|| (isset($tokens[$nonSpace]['scope_opener']) === true)
80+
|| (isset($tokens[$nonSpace]['scope_opener']) === true
81+
&& $tokens[$nonSpace]['scope_opener'] === $nonSpace)
8182
) {
8283
// Empty statement.
8384
return;

src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ for ( ; ; ) {}
2929
for ( /* Deliberately left empty. */ ; $ptr >= 0; $ptr-- ) {}
3030
for ( $i = 1 ; /* Deliberately left empty. */ ; $i++ ) {}
3131

32+
switch ($foo) {
33+
case 'foo':
34+
;
35+
break
36+
;
37+
}
38+
3239
// This is an empty statement and should be ignored.
3340
if ($foo) {
3441
;

src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.inc.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ for ( ; ; ) {}
2929
for ( /* Deliberately left empty. */; $ptr >= 0; $ptr-- ) {}
3030
for ( $i = 1; /* Deliberately left empty. */; $i++ ) {}
3131

32+
switch ($foo) {
33+
case 'foo':
34+
;
35+
break;
36+
}
37+
3238
// This is an empty statement and should be ignored.
3339
if ($foo) {
3440
;

src/Standards/Squiz/Tests/WhiteSpace/SemicolonSpacingUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc')
4141
18 => 1,
4242
29 => 1,
4343
30 => 2,
44+
36 => 1,
4445
];
4546
break;
4647
case 'SemicolonSpacingUnitTest.js':

0 commit comments

Comments
 (0)