Skip to content

Array shape is oversimplified when defined with a variable key #9907

@VincentLanglet

Description

@VincentLanglet

Bug report

When an array key is 'foo'|'bar' the array shape is too much simplified

Code snippet that reproduces the problem

https://phpstan.org/r/42797189-cf51-44e5-a0f7-fef18ce9545a

Expected output

Best would be

array{id: null, bar: string}|array{id: null, foo: string}

but I would expect at least

array{id: null, bar?: string, foo?: string}

Is something something possible without impacting (too much ?) the performance ?

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

Sure, I'm adding phpdoc for arrays and it detects so much

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