-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
Description
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
- 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);
});
}
- Use the macro in a controller:
return response()->success([], 'Success', 200);
-
Intelephense shows:
❗
Undefined method 'success'.intelephense(P1013)