Skip to content

Static call to instance method error should not happen if class implements __callStatic method #3641

@canvural

Description

@canvural

Feature request

For the given code:

<?php declare(strict_types = 1);

class Foo
{
	public function bar(): int
	{
		return 5;
	}
}

/**
 * @mixin Foo
 */
class Bar
{
	/**
     * @param  mixed[]  $args
     * @return mixed
     */
	public static function __callStatic(string $method, $args)
    {
        $instance = new Foo;

        return $instance->$method(...$args);
    }
}

Bar::bar();

https://phpstan.org/r/856294ef-b9e3-4d5f-94d9-2dcae85f72cb

I'd expect no errors. (https://3v4l.org/MRhFu)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions