barryvdh/laravel-ide-helper

Not working.

ThatOneRockyBoy opened this issue · 1 comments

Versions:

  • ide-helper Version: 2.13
  • Laravel Version: 10.10
  • PHP Version: 8.2.9

Question:

I can't get it to work. I have tried using this but vscode still complains. I honestly don't know what to do other than to just ignore the error. All I get is Undefined method

The code works just fine.

image
image

mfn commented

These are not cases ide-helper handles (or was designed to handle) 🤷🏼 I suggest to read the docs to get a better idea.

I'm not using vscode, but I can give you some suggestions what might work:

In the first one you likely can help yourself, I've two suggestion:

  • Use phpdoc on the handle method and document what the closure accepts/returns:
        /**
         * @param Request $request
         * @param Closure(Request):Response $next
         */
        public function handle(Request $request, Closure $next): Response
        {
    image
  • if vscode does not support Closure descriptions like this, you can try assigning it to a temporary variable and add a phpdoc:
    /** @var Response $result */
    $result = $next($request);

In the second example, Laravel documents $this->app as \Illuminate\Contracts\Foundation\Application, but isLocal is from the concrete class which implements the interface, this one here https://github.com/laravel/framework/blob/c1569099594168870cb4bdabfbaa35e5d172310b/src/Illuminate/Foundation/Application.php#L666-L669

At least in phpstorm, once you wrote isLocal() it infers it (and does not underline it)
image

The yolo one is made up, isLocal shows no indicator and you can also jump to source here.

But alas, phpstorm does not provide autocomplete to it per se. However, the github copilot will certainly suggest it 😅

I'm not ware if vscode supports stubbing for those or even how to write them, phpstorm supports the meta file format but I could not see either aspects being supported.