Advanced metadata parameter suggestions doesn't work in chained methods.

I'm defining a metadata for my helper function in Laravel:

function package($name) {
return app()->make('...service...')->find($name);
}

So far, I've added such metadata for this function:

override(\package(0), map([
'menu' => \Vendor\Menu\MenuPackage::class,
]));

It works fine at this stage and it nicely suggests `menu` for `$name` parameter value and it resolves properly autocompletion list when calling:

package('menu')

Problem begins when I want to define a metadata for a method `\Vendor\Menu\MenuPackage::service($name)`. I define it like that:

override(\Vendor\Menu\MenuPackage::service(0), map([
'class_locator' => \Vendor\Menu\Services\ClassLocator::class,
]));

It resolves proper class for further autocompletion so when I call it like that:

package('menu')->service('class_locator')

I get a proper autocompletion list of methods etc. from `\Vendor\Menu\Services\ClassLocator` class but it doesn't suggest `class_locator` for service method `$name` parameter like it does in case of package function.

Some more details:

A `\Vendor\Menu\MenuPackage` class actually extends an abstract class `\Vendor\Package\AbstractPage` and a `service()` method mentioned in examples above actually comes from that abstract class. I've tried to override service method so it was defined directly in `\Vendor\Menu\MenuPackage` but it didn't fix suggestions anyway.

A `package()` function has a `@return mixed` tag added to doc block.

Suggestions works when I override `\Vendor\Package\AbstractPage::service(0)` instead of `\Vendor\Menu\MenuPackage::service(0)`, but then it will display suggestions for services defined in all packages which in my case doesn't make sense as I need suggestions available only for `\Vendor\Menu\MenuPackage`.

Is there a way to make it work somehow? It would be very helpful for me and my team to have this working as we have quite a lot of packages and services inside these packages.

Please sign in to leave a comment.