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
Check for unsafe direct __construct() calls #7022
Comments
Yes, this should be disallowed, I agree :) Yes, I've seen the pictures and they made me really happy :) |
We have categorized the use cases for the Safe case:
Unsafe case:
Whether it is safe or not is case by case, but the case where use is justified
Detecting C case is a bit difficult, so it may be out of scope for this time. |
Yes, it's difficult, I'm fine with B1 and B2 (needs two rules - for MethodCall and StaticCall AST nodes). |
Which is better, creating two rules, |
Definitely two separate rules for those two specific AST nodes. CallLike means a lot more different things. |
@ondrejmirtes Could you review it ? |
I found method name is not correct, so fix name. |
As a similar case, |
Implemented by: phpstan/phpstan-src#1208 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature request
refs php/php-src#8351, vimeo/psalm#7857, Nyholm/psr7#198
It can be pointed out in these issues that calling
__construct()
from outside the object not only breaks immutability, but can also cause many unexpected behaviors.Currently @muno92 is developing a PR for this feature.
Did PHPStan help you today? Did it make you happy in any way?
Over the last few days we have exchanged some opinions about PHP and PHPStan at PHPerKaigi in Japan. (You may have seen the picture too)
The text was updated successfully, but these errors were encountered: