-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic/InlineControlStructure: stop listening for T_SWITCH #595
Changes from all commits
a9b6fa0
4c92408
b9809c7
9546775
82fae8e
61b9e9b
105b4be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,6 @@ public function register() | |
T_FOREACH, | ||
T_WHILE, | ||
T_DO, | ||
T_SWITCH, | ||
T_FOR, | ||
]; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,18 +62,21 @@ switch (true) { | |
case CONSTANT = 1: | ||
/* testIsNotEnumCaseIsCaseInsensitive */ | ||
cAsE CONSTANT: | ||
/* testCaseConstantCloserMarker */ | ||
} | ||
|
||
switch ($x) { | ||
/* testCaseInSwitchWhenCreatingEnumInSwitch1 */ | ||
case 'a': { | ||
enum Foo {} | ||
break; | ||
/* testCaseInSwitchWhenCreatingEnumInSwitch1CloserMarker */ | ||
} | ||
|
||
/* testCaseInSwitchWhenCreatingEnumInSwitch2 */ | ||
case 'b'; | ||
enum Bar {} | ||
/* testCaseInSwitchWhenCreatingEnumInSwitch2CloserMarker */ | ||
break; | ||
} | ||
|
||
|
@@ -93,3 +96,37 @@ enum Foo: string { | |
/* testKeywordAsEnumCaseNameShouldBeString7 */ | ||
case ARRAY = 'array'; | ||
} | ||
|
||
// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/497 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be worth it to also have a variation of this test in the |
||
switch ($value): | ||
/* testSwitchCaseScopeCloserSharedWithSwitch */ | ||
case 1: | ||
echo 'one'; | ||
endswitch; | ||
|
||
// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/879 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to have a similar test to this one in the |
||
switch ($type) { | ||
/* testSwitchCaseNestedIfWithAndWithoutBraces */ | ||
case 1: | ||
if ($foo) { | ||
return true; | ||
} elseif ($baz) | ||
return true; | ||
else { | ||
echo 'else'; | ||
} | ||
break; | ||
} | ||
|
||
// Test for https://github.com/squizlabs/PHP_CodeSniffer/issues/1590 | ||
switch ($num) { | ||
/* testSwitchCaseNestedInlineIfWithMoreThanThreeLines */ | ||
case 0: | ||
if (1 > $num) | ||
return bar( | ||
baz( | ||
"foobarbaz" | ||
) | ||
); | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this improvement also be done
RecurseScopeMapDefaultKeywordConditionsTest
tests ?