Skip to content

Spread operator on array of constants #4950

@superfaktura

Description

@superfaktura

Bug report

When using spread operator on class constant that contains an array of string constants, phpstan assumes its type wrong when used in another class array.
Simply, array of string constants is: string[]
Array in another class with spreaded array of constants should be: string[] but is array<int, string>|string[]

It seems that phpstan ignores the spread operator.

Code snippet that reproduces the problem

Behavior can be reproduced in phpstan playground:
https://phpstan.org/r/35d850a0-ec29-4afb-a773-e378c04d0e0a

Expected output

No errors expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions