Skip to content

Problem with shaped array and array_merge #8632

@Brainshaker95

Description

@Brainshaker95

Bug report

I have noticed a possible bug. Given the following code the following error will be emitted:

Method HelloWorld::test() should return array{id?: int, categories?: array} but returns array<'categories'|'id', 1|array{'news'}>.

Code snippet that reproduces the problem

Reproduction: https://phpstan.org/r/04dbfd87-93d6-485c-887e-15cd0d342f37

I noticed that the error only gets thrown when both of the array keys are set, When omitting either id or categories no error will be emitted.

Expected output

No errors

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

Yes 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions