Skip to content

Narrow return type: do not lose value type in array #10600

@gharlan

Description

@gharlan

Bug report

For the given code, phpstan reports correctly that SplFixedArray can be removed from return type (method a).
But when removing it, phpstan complains about missing value type (method b).
For method a phpstan does not complain about missing value type.
I think phpstan should keep the array value type info for the narrowed return type without having to note it again via phpdoc.

Code snippet that reproduces the problem

https://phpstan.org/r/d357662a-cd0d-49e9-b03f-3bb23fd9ebd7

Expected output

No error for method b.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions