Skip to content

Commit b76eb2b

Browse files
committed
Tests/Tokenizer: test related to setting the scope for T_CASE
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.
1 parent eab109d commit b76eb2b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/Core/Tokenizer/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,16 @@ switch ($type) {
117117
}
118118
break;
119119
}
120+
121+
// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/1590
122+
switch ($num) {
123+
/* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */
124+
case 0:
125+
if (1 > $num)
126+
return bar(
127+
baz(
128+
"foobarbaz"
129+
)
130+
);
131+
break;
132+
}

tests/Core/Tokenizer/Tokenizer/RecurseScopeMapCaseKeywordConditionsTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ public static function dataNotEnumCases()
208208
'scope_closer' => T_BREAK,
209209
],
210210
],
211+
'switch case, nested inline if' => [
212+
'testMarker' => '/* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */',
213+
'expectedTokens' => [
214+
'scope_opener' => T_COLON,
215+
'scope_closer' => T_BREAK,
216+
],
217+
],
211218
];
212219

213220
}//end dataNotEnumCases()

0 commit comments

Comments
 (0)