klesun / deep-assoc-completion

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

Providing completion in a php file that returns a array #129

Closed RobinRadic closed 4 years ago

RobinRadic commented 4 years ago

I would like to provide completion in a .php file (for example like the one below (settings.php)) I do not want to add the definition inside the file itself. I simply want to add a reference towards it. Here's what i mean:

settings.php

/** @return array = \App\Example::example() */
return [
    '<caret>' // CODE COMPLETION HERE
];

App/Example.php

<?php
namespace App;
class Example {
    public static function example(){
        return  [
            'env'         => 'APP_NAME',
            'bind'        => 'app.name',
            'type'        => 'anomaly.field_type.text',
            'placeholder' => config('streams::distribution.name'),
            'config'      => [
                'default_value' => config('streams::distribution.name'),
            ],
        ];
    }
}

Is something like this possible?

klesun commented 4 years ago

Hi. Maybe you would consider defining the return value in a variable? Then you will be able to reference it in phpdoc: image

RobinRadic commented 4 years ago

I want to use this on the config files in laravel/pyrocms The way you showed is not used in any of the config files and require my package (a code completion provider) to modify all those files in such a way. The package is open-source/public so i'd like it to change as little as possible. It would break consistency as well.

klesun commented 4 years ago

Hm, ok, seems reasonable enough. Released in 2019.11.18.002 image

RobinRadic commented 4 years ago

That's just awesome. Thanks a lot!