Skip to content

[class-string<MyClass>, 'MyMethod'] not considered as valid callable even if it exists #3920

@davidbrnovjak

Description

@davidbrnovjak

Bug report

Calling call_user_func() with array as callable where class is of type class-string<MyClass> fails with Parameter #1 $function of function call_user_func expects callable(): mixed, array(class-string<MyClass>, 'MyMethod') given. Class MyClass has method of that name defined.

  • Calling call_user_func([$classname, 'MyMethod']) wrongly produces error.
  • But trying to call $classname::MyMethod() correctly produces no error. (as on line 23 in snippet)

Code snippet that reproduces the problem

https://phpstan.org/r/5d8ce00e-ba5b-4b49-84f6-3ba603c0ba2f

Expected output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions