Skip to content

Using array_merge and array shapes #7857

@nicholasruunu

Description

@nicholasruunu

Bug report

There seems to be a small issue with specificity when using array_merge and array shapes.
It seems to force non-empty-array<'page'|'perPage', int> over the more specific array{page: int, perPage?: int}.
It also passes when rewritten with if statements without array_merge.

Code snippet that reproduces the problem

phpstan snippet

Expected output

I'm expecting it to pass since the array shape is more specific in that page is always present but perPage not always.
Also passes in Psalm

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

Great project, keep it up!

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