-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#393Labels
Milestone
Description
Bug report
When iterating an array<string, class-string<SomeBaseClass>>, phpstan fails to use that type information across an is_a() call to a call on a method of that class.
In the provided example, phpstan reports a call to an undefined method, but the method clearly exists because the object has been checked to be a member of that type.
Code snippet that reproduces the problem
https://phpstan.org/r/9b1cfac7-fbbf-4a07-ab76-ca149e7c04c6
Expected output
Since $class is a class-string<Base>, and is_a($obj, $class), $obj must be a Base, and therefore has the getId() method and should not error.
Alternatively: since is_a($obj, $class), and $class == Foo:class, $class is a Foo, which has a getId().
Reactions are currently unavailable