Skip to content

Commit

Permalink
Further fix for #2810 to make the new check more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Feb 18, 2020
1 parent 0547626 commit 19c8127
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public function process(File $phpcsFile, $stackPtr)

if ($tokens[$nonSpace]['code'] === T_SEMICOLON
|| ($forCondition === true && $nonSpace === $tokens[$owner]['parenthesis_opener'])
|| (isset($tokens[$nonSpace]['scope_opener']) === true)
|| (isset($tokens[$nonSpace]['scope_opener']) === true
&& $tokens[$nonSpace]['scope_opener'] === $nonSpace)
) {
// Empty statement.
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ for ( ; ; ) {}
for ( /* Deliberately left empty. */ ; $ptr >= 0; $ptr-- ) {}
for ( $i = 1 ; /* Deliberately left empty. */ ; $i++ ) {}

switch ($foo) {
case 'foo':
;
break
;
}

// This is an empty statement and should be ignored.
if ($foo) {
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ for ( ; ; ) {}
for ( /* Deliberately left empty. */; $ptr >= 0; $ptr-- ) {}
for ( $i = 1; /* Deliberately left empty. */; $i++ ) {}

switch ($foo) {
case 'foo':
;
break;
}

// This is an empty statement and should be ignored.
if ($foo) {
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getErrorList($testFile='SemicolonSpacingUnitTest.inc')
18 => 1,
29 => 1,
30 => 2,
36 => 1,
];
break;
case 'SemicolonSpacingUnitTest.js':
Expand Down

0 comments on commit 19c8127

Please sign in to comment.