Skip to content

cannot store phpstan-assert-if-true result in a variable  #10040

@nikophil

Description

@nikophil

Bug report

When calling a function which has a phpstan-assert-if-true annotation, if the result of the function is stored in a variable, PHPStan should know about the "narrowed" type, when the variable is tested.

Code snippet that reproduces the problem

https://phpstan.org/r/62ff0a37-00d7-40bf-9498-70d1d48e0844

Expected output

the second and third dumpType() should also resolve to string

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

thanks for your excellent work

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions