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 rule call constructor #1208
Conversation
Already pointed out how to define rules |
I'll split Rule |
|
||
return $this->isCollectCallingConstructor($node, $scope) | ||
? [] | ||
: ['__construct should not be called outside constructor.']; |
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.
: ['__construct should not be called outside constructor.']; | |
: ['__construct() should not be called outside constructor.']; |
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.
LGTM
This message is written in other lines, so I changed those.
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.
Thank you. I'm gonna take over and bring it over the finish line 😊
[IMO] but since the number of use cases is expected to be small, it can be ignored. |
I think, above case is no need of using __construct(). Is this wrong understanding? |
Yep, it can be rewrite such of your example. |
Sorry. I misread your first comment. |
47828c4
to
6fa97ee
Compare
6fa97ee
to
4daa27c
Compare
I've pushed some improvements, feel free to check out the commits :) |
535a03e
to
18930cc
Compare
Thank you. |
Thank you, too. |
FYI I've moved these rules to phpstan-strict-rules (124b30f, phpstan/phpstan-strict-rules@0c82c96) because it's a better fit there. According to some opinions, these rules are too opinionated to be part of the "mainstream" PHPStan. Thanks for understanding. |
Implementation for phpstan/phpstan/issues/7022.
Notes
Because it is a bit difficult.