klesun / deep-assoc-completion

A phpstorm plugin for associative array key typing and completion
Other
267 stars 17 forks source link

Nested references don't work in associative arrays #197

Open 1234ru opened 2 years ago

1234ru commented 2 years ago

I have arrays of items, whose structure is declared, and I reference to that structure in the arrays' declaration.

If the array has implicit or numeric keys, suggestion works fine.

But if the array has string keys, suggestion doesn't work.

<?php

class Test {
    /** @var = [
     *      'one' => '',
     *      'two' => '',
     *  ] */
    public $x;
}

/** @var $a = [ Test::$x ] */
$a = [
    [
        '' // suggests 'one', 'two' as expected
    ]
];

/** @var $b = [ Test::$x ] */
$b = [
    'key' => [
        '' // doesn't suggest anything :(
    ]
];

Is there a way to make such reference work in an associative array?