See my comment https://github.com/barryvdh/laravel-ide-helper/pull/765#issuecomment-471014271:
The change in #765 made anonymous functions get reflected with `ReflectionMethod` instead of `ReflectionFunction`, which makes it lose the doc comment. This means that the generated helpers are missing their return types. This is because Closure is also an object and callable.
To fix it, Closure should be excluded from that new condition.
Macros can be used with invokable classes, like so.
```
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Response;
class ResponseMacroServiceProvider extends ServiceProvider
{
public function boot()
{
Response::macro('foo', new Foo());
}
}
class Foo
{
public function __invoke()
{
return 'foobar';
}
}
```
When running `ide-helper:generate` the following fatal error was thrown.
``` Symfony\Component\Debug\Exception\FatalThrowableError : ReflectionFunction::__construct() expects parameter 1 to be string, object given```
This commit fixes this error.
* Fix missing doc-block.
* Fixes a bug where a missing DocBlock caused errors.
* Change Option Shorthand to W
Because it is not allowed to have two char shorthands for options.
* Revert code refactoring.
* Fix copied config header.
This update improves the parsing of return types, allowing array return
types to be recognized.
This was needed to properly recognize the files and allFiles methods as
duplicates (the function filtering duplicate definitions -
`removeDuplicateMethodsFromPhpDoc` in `Alias.php` - didn't recognise
them as duplicates, because the return type was seen as part of the name).
The getMethods function gets called both in the removeDuplicateMethodsFromPhpDoc
function and in helper.php, which causes the method detection to be performed twice.
Parts of the method detection includes a check for duplicate methods, but Macro
methods for example, aren't checked for duplicates.
Instead of checking everywhere if we're not adding duplicates, I've included a
check in the getMethods call to just use the already generated methods
if they have been generated already.
Closures do not have a method name that makes sense to use in the ide_helper
file.
e.g. Illuminate\Foundation\Providers\{closure} would be the real_name instead of
just validate. So for the closure methods, we should just use the provided
methodName instead.
When a method is declared both in the phpdoc and in the class itself,
PhpStorm (2018.3) complains about duplicate function declarations, preventing
correct code hinting.
To solve this, I remove the already declared functions from the generated dockblocks.