Skip to content

[Bug]: Intelephense does not recognize Response::macro methods in Laravel (e.g., response()->success()) #385

@iqbalhasandev

Description

@iqbalhasandev

Extension Version

1.0.7

PHP Binary

Herd

Operating System

macOS

What happened?

When defining a custom macro using Response::macro() in Laravel (e.g., in AppServiceProvider), Intelephense does not recognize the dynamically added method, resulting in:

  • No type hinting or autocomplete for the macro method (e.g., success, error).
  • Red underline and error:
    Undefined method 'success'.intelephense(P1013)

Despite the macro working perfectly at runtime in Laravel, this causes noise and confusion in the IDE.


✅ Expected Behavior

Intelephense should either:

  • Recognize and provide type hinting/autocomplete for custom response macros, or
  • At the very least, not show an error underline for methods registered via Response::macro().

❌ Actual Behavior

In any controller or class where you use the macro:

return response()->success([], 'success', 200);

You get:

  • 🔴 Undefined method 'success'.intelephense(P1013)
  • No suggestions/autocomplete
  • No type hinting on the success() method

🧪 Steps to Reproduce

  1. In AppServiceProvider:
use Illuminate\Support\Facades\Response;

public function boot(): void
{
    Response::macro('success', function ($data = null, ?string $message = null, int $code = 200) {
        return Response::json([
            'data' => $data,
            'message' => $message,
            'success' => true,
        ], $code);
    });
}
  1. Use the macro in a controller:
return response()->success([], 'Success', 200);
  1. Intelephense shows:

    Undefined method 'success'.intelephense(P1013)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions