klesun / deep-assoc-completion

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

Support @self reference #190

Closed 6562680 closed 3 years ago

6562680 commented 3 years ago

First i tried to do

/** @return array [ 'id' => 123, 'children' => [ ? ] ] */

and it is impossible. I just dont know how to mark deep-assoc to know i want to recursive autocomplete in child

Rarely case but needed for me.

How do you think?

klesun commented 3 years ago

Hi. The proper way would probably be by using PSALM typedefs, but this is not supported yet: https://github.com/klesun/deep-assoc-completion/issues/158

One workaround you could use is to define the type with a circular function: image

Click to expand code ```php function describeNode() { return [ 'id' => 123, 'children' => [describeNode()], ]; } /** @return array = describeNode() */ function doStuff() { } doStuff()['children'][0][] ```
klesun commented 3 years ago

Let me know if you'll have more questions regarding the status of annotating circular type structures