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

Question: Intellisense for Laravel helper methods #1601

Open
saade opened this issue Oct 22, 2024 · 0 comments
Open

Question: Intellisense for Laravel helper methods #1601

saade opened this issue Oct 22, 2024 · 0 comments
Labels

Comments

@saade
Copy link

saade commented Oct 22, 2024

Versions:

  • ide-helper Version: v3.1.0
  • Laravel Version: 11.28.1
  • PHP Version: 8.3.11

Question:

When defining a macro, let's say for the Response class:

// app/Providers/AppServiceProvider.php

use Illuminate\Support\Facades\Response;

Response::macro('api', function (?string $message = null, ?array $data = null, int $status = 200, array $headers = []) {
    return Response::json(
        data: ['message' => $message, 'data' => $data],
        status: $status,
        headers: $headers
    );
});

is it possible to get intellisense when using? :

return response()->api() // Undefined method 'api'

This also occurs when macroing Auth too:

use Illuminate\Support\Facades\Auth;

Auth::macro('admin', function (): ?Admin {
    /** @var Auth $this */
    return auth('admin')->user();
});
auth()->admin() // Undefined method 'admin'

PS: The method works as expected, just the intellisense cannot pick the defined macro
PS2: Even auth()->user() which is a standard method is not being found

@saade saade added the question label Oct 22, 2024
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