Skip to content

Values added to a nullable array aren't being type-checked #5804

@gnarlyquack

Description

@gnarlyquack

Bug report

A property of type ?T[] can have any value assigned to it regardless of type without causing a type checking error.

Code snippet that reproduces the problem

https://phpstan.org/r/53a657a5-2847-4df6-84d1-7c209839dc6f

Expected output

Type errors on lines 13 and 15.

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

Yes, I'm using it in a current project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions