You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When working on #3186, I got a weird behavior with the scope opener/closer of switch/case. In the code sample, when I dump the tokens, : is the scope opener of the scope_conditioncase, and return is the scope closer.
But then, when using the findStartOfStatement with the index of the token 4, it will return the token 4 instead of the return one, because of this condition: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Files/File.php#L2311-L2319
Return is a scope closer here so it return the value before return (or after, since we're looking backward), which is 4.
So I think we should ignore the scope closer of the switch/case, the right fix would be this: e790378
The text was updated successfully, but these errors were encountered:
Code sample
Describe the bug
When working on #3186, I got a weird behavior with the scope opener/closer of switch/case. In the code sample, when I dump the tokens,
:
is the scope opener of thescope_condition
case
, andreturn
is the scope closer.Seems like it's because of this: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Tokenizers/PHP.php#L220
But then, when using the
findStartOfStatement
with the index of the token4
, it will return the token4
instead of thereturn
one, because of this condition: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Files/File.php#L2311-L2319Return is a scope closer here so it return the value before
return
(or after, since we're looking backward), which is4
.So I think we should ignore the scope closer of the
switch/case
, the right fix would be this: e790378The text was updated successfully, but these errors were encountered: