-
Notifications
You must be signed in to change notification settings - Fork 672
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
False positive MixedPropertyFetch after instanceof $this
#11281
Labels
Comments
Hey @kynx, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug. |
I found these snippets: https://psalm.dev/r/814236f6c7<?php
abstract class A
{
public function __construct(private string $value)
{
}
public function equals(mixed $other): bool
{
if (! $other instanceof $this) {
return false;
}
return $this->value === $other->value;
}
}
|
Note that replacing $this by static works if it's not inverted |
I found these snippets: https://psalm.dev/r/0afbd90e20<?php
abstract class A
{
public function __construct(private string $value)
{
}
public function equals(mixed $other): bool
{
if ($other instanceof static) {
/** @psalm-trace $other */;
return false;
}
/** @psalm-trace $other */;
return $this->value === $other->value;
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results in:
The text was updated successfully, but these errors were encountered: