Skip to content

Commit

Permalink
Merge pull request #499 from rodrigoprimo/fix-inline-control-structur…
Browse files Browse the repository at this point in the history
…e-bug

Generic/InlineControlStructure: fix error when handling `else if`
  • Loading branch information
jrfnl authored May 18, 2024
2 parents 72b50b9 + f83ba7e commit 4866ee3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function process(File $phpcsFile, $stackPtr)

// Ignore the ELSE in ELSE IF. We'll process the IF part later.
if ($tokens[$stackPtr]['code'] === T_ELSE) {
$next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
if ($tokens[$next]['code'] === T_IF) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,7 @@ function testFinally()
} finally {
}
}

if ($something) {
echo 'hello';
} else /* comment */ if ($somethingElse) echo 'hi';
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,8 @@ function testFinally()
}
}
}

if ($something) {
echo 'hello';
} else /* comment */ if ($somethingElse) { echo 'hi';
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ if ($("#myid").rotationDegrees()=='90')

if ($("#myid").rotationDegrees()=='90')
$foo = {'transform': 'rotate(90deg)'};

if (something) {
alert('hello');
} else /* comment */ if (somethingElse) alert('hi');
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ if ($("#myid").rotationDegrees()=='90') {
if ($("#myid").rotationDegrees()=='90') {
$foo = {'transform': 'rotate(90deg)'};
}

if (something) {
alert('hello');
} else /* comment */ if (somethingElse) { alert('hi');
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function getErrorList($testFile='')
242 => 1,
260 => 1,
269 => 1,
278 => 1,
];

case 'InlineControlStructureUnitTest.js':
Expand All @@ -90,6 +91,7 @@ public function getErrorList($testFile='')
21 => 1,
27 => 1,
30 => 1,
35 => 1,
];

default:
Expand Down

0 comments on commit 4866ee3

Please sign in to comment.