-
Notifications
You must be signed in to change notification settings - Fork 507
Add ConstantsInTraitsRule
#2718
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
Conversation
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.
Hi, this really does not have to be a Collector+Rule, just a simple Rule.
c3ce077
to
71775c9
Compare
Initially, I tried using rule only targeting the |
Yes, ClassConst rule should be fine, please push your earlier attempt and I'll see what's wrong. |
71775c9
to
9ea56ec
Compare
You need to use the trait by a class in order to have it inspected. Alternatively (maybe a better option) is to hook your rule onto Trait_ node and inspect its stmts. |
9ea56ec
to
6ecb69f
Compare
Looks pretty okay now. FYI there are dozens of similar rules that could be implemented that PHPStan does not check but PHP crashes on it. Would you be interested in looking at the list and maybe implementing some of them? Thank you! |
Sure. Maybe you have a list or something? |
The larastan tests failures are not mine as I see from the larastan repo their build is failing. Not sure for phpstan-doctrine, though. |
Thank you very much. The failures are not your fault, you certainly couldn't break that with a new rule :) As for the other rule ideas. Here's one list: And I also have a pretty comprehensive list in a private Trello board. If you give me your email address, I can invite you to it. |
Thanks! Here's my email: paulbalandan[at]gmail.com |
Just invited you, thanks! |
This PR adds a rule to flag usage of constants inside traits, which feature is only available on PHP 8.2 and later.
Ref: https://php.watch/versions/8.2/constants-in-traits