-
Notifications
You must be signed in to change notification settings - Fork 509
Use ConstantScalarTypeTrait in NullType #3643
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
cfe042a
to
3076c9e
Compare
Maybe |
The error comes from phpstan-src/src/Rules/Methods/StaticMethodCallCheck.php Lines 82 to 116 in 30d20e6
so I get an error because
in the context of NullType. PHPStan doesn't understand |
This pull request has been marked as ready for review. |
The method shouldn't just accept ConstantScalarType. It should always be asking a Type about any other Type. I don't love traits and I'd like to see them be used less, not more. |
I really don't understand what you're asking. Those methods already exists, they are
But there is a special logic needed for ConstantScalar which is that for constantScalar we need to know if we check one of the many following condition based on PHP version and type of constants.
This is a special logic needed only for ConstantScalarType when compared to another ConstantScalarType ; so I don't see how and why I would work with a new method to Type about any other Type. This is similar to the existing
I provided a refacto in #3485 which seems the simpler way (in my eyes) to have a reusable method in order to
Some guidelines would be helpful 🙏 |
Hi, I wanted to finish (#3484) and therefor following your advice on #3485 (comment).
The best option I see would be to introduce
in the ConstantScalarTypeTrait ; but the NullType would require the exact same logic.
So it would be helpful to use the ConstantScalarTypeTrait in the NullType.
Also, there is multiple method duplicated between both trait/class.
The only issue I found is that ConstantScalarTypeTrait sometimes rely on parent method. This can be avoided with
checks ; but PHPStan doesn't understand such things.
Should I just ignore the static analysis error or you don't want such PR ?
Also, I didn't know if I should have targeted the 2.0.x branch for such refacto to avoid conflict on merge ; or if it's ok on 1.12.x.