-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Internal.Exception on valid switch statements with curly braces #3794
Comments
@r1pped Thanks for reporting this. I can confirm the issue. It's actually the combination of the curly braces being used for the first It results in the second This will need some digging into what exactly is going wrong with the setting of the |
I'm noticing another inconsistency in the token arrays related to this. switch (true) {
case 2 === 2:
echo "bar";
break;
case 3 === 3:
echo "bar";
break;
} In the above, the The switch (true) {
case 1 === 1: {
echo "foo";
break;
}
case 2 === 2: {
echo "bar";
break;
}
} In this second code sample, the 👉🏻 IMO it would be more consistent if the If we then take (a variation on) the original code sample: switch (true) {
case 1 === 1: {
echo "foo";
// omitting break; causes Internal.Exception
}
case 2 === 2:
echo "bar";
break;
case 3 === 3:
echo "bar";
break;
} The first The second
The third I'm fairly confident that the culprit is somewhere in the last part of the @gsherwood Got an opinion on this ? |
Describe the bug
Running sniffer with PSR-12 standard on some valid switch statements (mixing curly braces syntax with classic syntax) shows an Internal.Exception, which aborts checking rest of the code
Code sample
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above...phpcs --standard=psr12 test.php
Expected behavior
Maybe still show PSR2/PSR12 errors in lines 12-14 where
if(false){
is?Versions (please complete the following information):
Additional context
Even if we ignore PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase sniffer which occurs in line 4, the exception still happens and the rest of the code is not checked anymore.
The text was updated successfully, but these errors were encountered: