Skip to content

Commit

Permalink
Tests/Tokenizer: test related to setting the scope for T_CASE
Browse files Browse the repository at this point in the history
This commit copies a sniff test from InlineControlStructureUnitTest.php
to the Tokenizer::recurseScopeMap() tests for the case keyword. This
test was added in 65ef053 before the Tokenizer tests were created. It
ensures that the scope for the T_CASE token is set correctly when there
is a inline control structure inside it with more than three lines.
  • Loading branch information
rodrigoprimo committed Oct 9, 2024
1 parent 8ae10e9 commit 8211f0d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,16 @@ switch ($type) {
}
break;
}

// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/1590
switch ($num) {
/* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */
case 0:
if (1 > $num)
return bar(
baz(
"foobarbaz"
)
);
break;
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ public static function dataNotEnumCases()
'scope_closer' => T_BREAK,
],
],
'switch case, nested inline if' => [
'testMarker' => '/* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */',
'expectedTokens' => [
'scope_opener' => T_COLON,
'scope_closer' => T_BREAK,
],
],
];

}//end dataNotEnumCases()
Expand Down

0 comments on commit 8211f0d

Please sign in to comment.