Skip to content

Lost narrowed type from PHPDoc or Psl\Type #11386

@p4veI

Description

@p4veI

Bug report

Hello, I've come across this issue a few versions back, when I narrow e.g. an array type using a PHPDoc var annotation (but also using Psl\Type\.. features from azjezz/psl), and passing this to a function I'm using to construct a \Ds\Map of the items the narrowed type is lost.

Hope there is not something I'm missing but it started to occur with v1.11.2, additional assertion inside the mapper function can get rid of the error, but from what it seems the type should be known for phpstan without the assertion.

Code snippet that reproduces the problem

https://phpstan.org/r/cb1cf6e6-46ad-423b-addb-60ea588987de

Expected output

No errors.

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

Makes me happy every day when I see no errors :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions