Skip to content

Callable parameter loses its argument typing when part of an union type #6629

@axlon

Description

@axlon

Bug report

When a function (or method) accepts a callable as part of a union, the type of the callable's parameters seems to get lost.

Code snippet that reproduces the problem

https://phpstan.org/r/7e566448-8b05-4b83-9082-f2169233c862

Expected output

I'd expect the type of the callable's $attributes parameter in the example to be array<string, mixed>, but for some reason PHPStan thinks its mixed. When the union is removed (leaving only the callable), PHPStan reports correctly.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan recently pointed me to a minor issue (when we raised its level) which led me to notice one of our tests was comprised entirely of false positives

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions