Skip to content

Annotate "insert element" operation on TKeyedArray #4193

@doggor

Description

@doggor

I have a function that accept an TKeyedArray and insert a specific element into it. For example, given a input $arr which is in type of @template T of array{id: int} , after having operation like $arr['baz'] = 'baz'; the output should becomes T & array{'baz':string}.

https://psalm.dev/r/ef60918b5a

I found a similar issue #3339 that describes a more general situation, but don't know if there is a solution for this case.

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