-
-
Notifications
You must be signed in to change notification settings - Fork 55
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/CallTimePassByReference: add support for self, parent and static #466
Generic/CallTimePassByReference: add support for self, parent and static #466
Conversation
f280e3f
to
f4a8eb8
Compare
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.
Thanks @rodrigoprimo LGTM.
As a side-note: I'm not a fan of always sorting the tokens in register()
alphabetically.
On the one hand it makes history tracing more difficult; on the other hand, the tokens are often sorted by the kind of language structure they represent, so sorting them alphabetically increases the cognitive load.
Sorting makes sense when all tokens represent the same type of language structure, but that's not the case here.
Thanks for the review, @jrfnl!
Noted. Let me know if you prefer that I drop the commit that sorts the tokens in this PR. |
Well, I've said what I had to say about it. It's now up to you to decide what to do with it. |
f4a8eb8
to
7a96d3d
Compare
My impression is that it is better to sort the tokens alphabetically for all the sniffs. That being said, I have way less experience than you, so I trust your opinion more than mine on this matter. I went ahead and dropped the commit. I added the tokens to the end of the list grouped together with the T_ANON_CLASS as all those tokens relate to classes and objects. I'm not sure if that is the organization that you had in mind. |
This commit changes the CallTimePassByReference sniff to listen to the T_PARENT, T_SELF, and T_STATIC tokens. From now on the sniff will trigger errors when one of those tokens is used to instantiate a class containing a variable passed by reference.
7a96d3d
to
b7ec8bc
Compare
Rebased without changes. Merging once the build passes. |
Description
This PR changes the Generic.Functions.CallTimePassByReference sniff to trigger an error when the parent, self, or static tokens are used to instantiate a class containing a variable passed by reference. In a separate commit, it also sorts alphabetically the list of tokens this sniff listens to.
Suggested changelog entry
Generic.Functions.CallTimePassByReference: flag call-time pass-by-reference when instantiating a class using parent, self, or static.
Related issues/external references
Suggested in #394 (review)
Types of changes
PR checklist