Skip to content

[ArrayShape] doesn't work for structure inside the array #18

@hantc

Description

@hantc

Hello, pseudocode:

    #[ArrayShape(['soldCount' => 'int', 'bookId' => 'int'])]
    public function foo(): array
    {
        $arr = [];

        $arr[] = [
            'soldCount' => 123,
            'bookId' => 453478,
        ];

        $arr[] = [
            'soldCount' => 22,
            'bookId' => 7863,
        ];


        return $arr;
    }

I'm not able to make phpstorm to suggest 'soldCount' and 'bookId' inside foreach. Is there any way how to define ArrayShape for structure inside list of items in array?

foreach ($this->foo() as $item) {
   echo $item['soldCount']; // phpstorm doesn't suggest
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions