-
-
Notifications
You must be signed in to change notification settings - Fork 867
-
-
Notifications
You must be signed in to change notification settings - Fork 867
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
calling static methods on strings #504
Comments
the workaround on 74c3cf8 seems to be to |
There are two things going on at once:
About 1), I'm torn whether PHPStan should complain when a method is called on a string without any public function doFoo(string $className)
{
$className::doSomething(); // dangerous, report Cannot call static method doSomething() on string.
} versus: public function doFoo(string $className)
{
if (!is_a($className, DoesSomething::class, true)) {
throw new \InvalidArgumentException));
}
$className::doSomething(); // this is fine
} It probably should report that, but the error message is not a convenient place to explain that the developer should use About 2) - I will try to implement this and I hope the current type system will allow this. If not, it will have to be postponed until later. If everything goes well, both 1) and 2) will be adressed at once. |
no rush on it, although mildly inellegant, the workaround to p.s. see the changes here corresponding to (mostly phpstan) today's update on static analysis. |
Fixee the "cannot call on string" problem: a7c931c I'm removing the "0.9" milestone and leaving this open for the |
@ondrejmirtes Removing the milestone seems unnecessary as |
@JanTvrdik Sorry, didn't notice that, the milestone is back :) |
#507 got merged so this issue should be completely solved. Feel free to test dev-master. |
ideally, this should only cause an error in the case of baz1, since there's nothing in particular to indicate that
$thing
is an implementation offoo
The text was updated successfully, but these errors were encountered: