1

I use a Lumen Laravel-based framework and it allows me to create custom method like this:

/**there should be a proper doc*/
\Laravel\Lumen\Http\ResponseFactory::macro('customMethod', function ()
    {

        return $this;
    });

It creates method customMethod called as method which belongs response() function.

/**or probably there should be a proper doc*/
return response()->customMethod()

I want to make a hint to my IDE (PhpStorm 2020.1.2) which allows it to see reference from where customMethod is called to where it is declared, and follow it with click on function name in IDE.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Valik Tralik
  • 69
  • 1
  • 12
  • Do you use `barryvdh/laravel-ide-helper`? It generates stub file for Laravel code that documents lots of "magic" / "calling normal method statically" and alike. You can edit generated file and add your own reference for such `customMethod` (be it PHPDoc `@method` or real method in a class). The difficulty is that such macro is defined dynamically in your code, it's not part of the framework so the standard PHPDoc cannot be used on the real class from the framework. – LazyOne Oct 06 '20 at 08:11
  • You will not be able to navigate to the actual real definition line in this way, but it will help with code completion / not marking it as unknown method in IDE and all usages will lead to that stub file so you can still see all usages if you want (IDE will differentiate in case if you will have the same macro on another class) – LazyOne Oct 06 '20 at 08:11

0 Answers0