From 2ac73f2953f59e43b798e959a352e09305cb5320 Mon Sep 17 00:00:00 2001 From: Jaspur Date: Wed, 10 Dec 2025 10:31:15 +0100 Subject: [PATCH] Skip calling fake() when required parameters exist (Socialite compatibility) (#1746) * 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 --- src/Alias.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Alias.php b/src/Alias.php index 8008d01..b7480f7 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -248,16 +248,20 @@ class Alias return; } + $reflection = new \ReflectionMethod($facade, 'fake'); + if ($reflection->getNumberOfRequiredParameters() > 0) { + return; + } + $real = $facade::getFacadeRoot(); try { $facade::fake(); $fake = $facade::getFacadeRoot(); + if ($fake !== $real) { $this->addClass(get_class($fake)); } - } catch (Throwable $throwable) { - // Ignore error } finally { $facade::swap($real); }