Skip to content

Infer class-string<callable> as class-string<callable-object> #9148

@boesing

Description

@boesing

Feature request

I am currently providing the missing feature of class-string allowing callable objects and callable&object intersections to psalm.
Since class-string should ofc always refer to objects, I'd say that class-string<callable> can be inferred as class-string<object&callable> or class-string<callable-object> (which is also supported).

https://phpstan.org/r/5e902009-c3ce-4499-81f3-375920a80b93

I just wanted to raise the awareness that phpstan is actually not allowing class-string<callable> due to the fact that it might not be clear that we are talking about object. But I think, class-string should ofc verify the passed value to be a class-string but the resulting type should not be limited to that (esp. since an object can be passed to a callable). class-string should already provide the object information if it is not of interest of what kind of class/interface it has to be.

WDYT?

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