Skip to content

Doesn't recognize the callable method #2880

@peter-gribanov

Description

@peter-gribanov

Code snippet that reproduces the problem

interface CommandSubscriber
{
    /**
     * @return array<class-string, string>
     */
    public static function getSubscribedCommands(): array;
}

class Locator
{
    /**
     * @var array[]
     */
    private $command_handler_ids = [];

    public function registerSubscriberService(string $service_name, string $class_name): void
    {
        if (is_a($class_name, CommandSubscriber::class, true)) {
            foreach (forward_static_call([$class_name, 'getSubscribedCommands']) as $command_name => $method) {
                $this->command_handler_ids[$command_name] = [$service_name, $method];
            }
        }
    }
}

https://phpstan.org/r/f1c77d3e-9c47-4665-bd2d-1441fdaf0714

I checked that the variable $class_name belongs to the class that implements the interface CommandSubscriber. The interface has a static method getSubscribedCommands() that i call. This method must be accessible as the interface declares. I see no reason to check it again for callability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions