Skip to content

call_user_func() with variable class_name (class-string<Interface>) wrongly reports error #3608

@davidbrnovjak

Description

@davidbrnovjak

Bug report

Using call_user_func([$class_name, 'myMethod']) where $class_name is of type class-string<Interface> reports error even if Interface declares myMethod.

Replacing $class_name with string containing name of class works.

Code snippet that reproduces the problem

Using variable as a $class_name fails https://phpstan.org/r/ec57ec5e-d5e3-47c2-8189-e2534bfee26f

Using class_name directly works https://phpstan.org/r/f63497b3-65c3-4e8a-9567-63556b63d8b7

Expected output

No error reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions