Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working. #1458

Closed
ghost opened this issue Aug 17, 2023 · 1 comment
Closed

Not working. #1458

ghost opened this issue Aug 17, 2023 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Aug 17, 2023

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

@ghost ghost added the question label Aug 17, 2023
@mfn
Copy link
Collaborator

mfn commented Aug 17, 2023

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.

@mfn mfn closed this as completed Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant