Skip to content
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

Fix ImpossibleCheckTypeFunctionCallRule for is_subclass and is_a #3788

Open
wants to merge 3 commits into
base: 1.12.x
Choose a base branch
from

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Jan 19, 2025

Improved strategy for #3404

The main idea is that always true error can always be reported if the second param is a Constant class-string (or union of them).

I included a non regression test from
#3404 (comment)

Closes phpstan/phpstan#3979
Closes phpstan/phpstan#8464

@gnutix
Copy link
Contributor

gnutix commented Jan 23, 2025

I don't know if this PR would fix this, but I just upgraded to the latest PHPStan version and this new error popped up:

Call to method ReflectionClass<object>::isSubclassOf() with 'App\\Application\\Shared\\
Query\\Filter\\ListQuery' will always evaluate to false.

for this code :

#[Override]
    public function supports(Model $model): bool
    {
        $type = $model->getType();
        if ('object' !== $type->getBuiltinType()) {
            return false;
        }

        $class = $type->getClassName();
        if (null === $class || !class_exists($class)) {
            return false;
        }

        $reflection = new ReflectionClass($class);

        return $reflection->isSubclassOf(ListQuery::class) ? ... : ...;

Should I open a separate bug?

@ondrejmirtes
Copy link
Member

@gnutix That is unrelated, and most likely a consequence of phpstan/phpstan#12459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants