Skip to content

Commit 2ac73f2

Browse files
Jaspurbarryvdh
andauthored
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 <[email protected]>
1 parent c95825a commit 2ac73f2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Alias.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,20 @@ protected function detectFake()
248248
return;
249249
}
250250

251+
$reflection = new \ReflectionMethod($facade, 'fake');
252+
if ($reflection->getNumberOfRequiredParameters() > 0) {
253+
return;
254+
}
255+
251256
$real = $facade::getFacadeRoot();
252257

253258
try {
254259
$facade::fake();
255260
$fake = $facade::getFacadeRoot();
261+
256262
if ($fake !== $real) {
257263
$this->addClass(get_class($fake));
258264
}
259-
} catch (Throwable $throwable) {
260-
// Ignore error
261265
} finally {
262266
$facade::swap($real);
263267
}

0 commit comments

Comments
 (0)