-
-
Notifications
You must be signed in to change notification settings - Fork 932
Open
Labels
Milestone
Description
Bug report
public function update(object $entity): void
{
assert(method_exists($entity, 'getId'));
$class = $entity instanceof Proxy
? get_parent_class($entity)
: get_class($entity);
assert(is_string($class));
}phpstan gives the following false positive error on is_string call, when method_exists is called on the original object beforehand:
Call to function is_string() with false will always evaluate to false.
$class is not always false in this case
Code snippet that reproduces the problem
https://phpstan.org/r/2435eca1-a03a-450a-9927-8d99140c0048 - has error
https://phpstan.org/r/17c8150b-569a-430a-b02e-1ddaa2313016 - method_exists commented out -> no errors
https://phpstan.org/r/5bbd636c-ee9d-4a1c-b832-2f3b47a14d6a - method_exists called afterwards -> no errors
Expected output
no errors