-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add arrow function support #179
Conversation
The problem I'm running into is that I don't know how to find out where the scope ends for an arrow function. PHPCS doesn't seem to consider it a scope at all:
However, variables defined inside the arguments list for the function ( There's no obvious token to use to find the end to an arrow function; it's the end of the expression but I'm not sure of an easy way to find that. |
Ah, I was wrong, there's additional processing done to find the arrow function scope:
|
@sirbrillig Arrow function support in PHPCS was only added in PHPCS 3.5.3 and was pretty broken until 3.5.5 and there are still bugs being found. As PHPCS 3.1 is your minimum, you will need to sniff for both The PHPCSUtils Caveat: that is: in so far as possible of course, as when PHPCS sets the wrong |
Just noticed that you are changing the minimum PHPCS version to |
I'm just experimenting so far. I've got it to recognize the scope of variables defined within an arrow function. Now I just need to get it to properly scan the variables within that scope at scope close. The tricky thing is that variables in the scope also include variables from the parent scope. |
f52c260
to
e079598
Compare
Hey! We're getting there! Arrow functions now work. I got stuck because there's a bunch of old poorly-named, poorly-documented code lying around that I've been meaning to refactor for a long time. I spent a few days tearing the scope detection apart and then re-building it from scratch and I think it works much better now. I need to rebase this PR to make some of the commits make sense, but I'll wait till this is all done. Now just to support PHP 5.6... |
0cdaf57
to
e099bc9
Compare
✅ all tests pass 💥 🥳 💥 |
Coming back around to this, since we rely on |
35e2583
to
fc01fa6
Compare
fc01fa6
to
79dec4c
Compare
Fixes #134