* Skip calling fake() on facades that require parameters (fix Socialite error)
The ide-helper attempted to invoke Facade::fake() unconditionally, which
breaks when a facade (such as Laravel Socialite) requires a mandatory
parameter in its fake() method signature. This resulted in an
ArgumentCountError during `php artisan ide-helper:generate`.
This patch adds a ReflectionMethod check and skips calling fake() when
required parameters are present, ensuring compatibility with Socialite
and preserving expected behavior for facades that support parameterless
faking.
* Update Alias.php
---------
Co-authored-by: Barry vd. Heuvel <[email protected]>
* Add return type `|static` to Query\Builder methods (#1574)
* Replace return type Query\Builder with Eloquent\Builder (#1574)
* Replace return type Query\Builder only for facade Eloquent (#1574)
* Add special return type replacement for Macros of \Eloquent
* Restrict special return type to methods from Eloquent\Builder and Query\Builder
* Do not overwrite return type in normalizeReturn() with conditional call of setType()
* Use generic return type for builder methods in \Eloquent
* composer fix-style
---------
Co-authored-by: laravel-ide-helper <[email protected]>
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.
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.
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.
* Add method to retrieve namespace of extended class
* Regroup classes by namespace of the class they extends
* Restore facades shortnames
* Fix classnames used for methods declaration