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

Cannot call an abstract static method #3007

Closed
vudaltsov opened this issue Mar 23, 2020 · 2 comments
Closed

Cannot call an abstract static method #3007

vudaltsov opened this issue Mar 23, 2020 · 2 comments

Comments

@vudaltsov
Copy link
Contributor

Since 3.10 this code breaks. https://psalm.dev/r/94b8f284f0
It's certainly right that an abstract static method cannot be called from the abstract class itself, but how can I tell psalm that I have an array of implementing class names?

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/94b8f284f0
<?php

abstract class A
{
    abstract public static function name(): string;
}

final class B extends A
{
    public static function name(): string
    {
        return 'b';
    }
}

final class C extends A
{
    public static function name(): string
    {
        return 'c';
    }
}

/** @var list<class-string<A>> $classes */
$classes = [B::class, C::class];

foreach ($classes as $class) {
    echo $class::name();
}
Psalm output (using commit 2043e85):

ERROR: AbstractMethodCall - 28:10 - Cannot call an abstract static method A::name directly

@muglug muglug closed this as completed in eeed5ec Mar 23, 2020
@muglug
Copy link
Collaborator

muglug commented Mar 23, 2020

Thanks, this is fixed in 3.10.1

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

No branches or pull requests

2 participants