-
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
Incorrect scope matching when arrow function used inside IF condition #2867
Comments
I was able to prepare a workaround but I suppose that |
Confirmed. But there's more going on here: the I have a feeling that's what's throwing everything off. The check for scope openers for control structures using alternative syntax should probably make sure that the close parenthesis of the control structure's open parenthesis has been seen before looking for a scope opener. |
I think this is going to require the arrow function detection code to be moved out of processAdditional and into the main process method. |
Much much easier said than done. Probably need to figure something else out. |
Looks like it's easier to just ensure that a scope opener has the same nested parenthesis as the scope condition. So in this case, the T_COLON is nested differently to the T_IF, so it can't be the scope opener for it. |
I've pushed up a fix for this issue and PHPCS is now matching the scope openers and closers correctly for the code sample. If you get a chance to test, please let me know if there are other code snippets where this doesn't work. Thanks for the report. |
I run phpcs with slevomat/coding-standard and I get error:
This is code which causes error:
First reported here slevomat/coding-standard#902
The text was updated successfully, but these errors were encountered: