Skip to content

Commit a4308ec

Browse files
authored
[9.x] Improve facade script (#45219)
* Removes @internal methods from facade docblocks * Correctly filter userland deprecated methods
1 parent 38c2126 commit a4308ec

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

bin/facades.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
->flatMap(fn ($class) => [$class, ...resolveDocMixins($class)])
3232
->flatMap(resolveMethods(...))
3333
->reject(isMagic(...))
34+
->reject(isInternal(...))
3435
->reject(isDeprecated(...))
3536
->reject(fulfillsBuiltinInterface(...))
3637
->reject(fn ($method) => conflictsWithFacade($facade, $method))
@@ -328,6 +329,21 @@ function isMagic($method)
328329
return Str::startsWith(is_string($method) ? $method : $method->getName(), '__');
329330
}
330331

332+
/**
333+
* Determine if the method is marked as @internal.
334+
*
335+
* @param \ReflectionMethod|string $method
336+
* @return bool
337+
*/
338+
function isInternal($method)
339+
{
340+
if (is_string($method)) {
341+
return false;
342+
}
343+
344+
return resolveDocTags($method->getDocComment(), '@internal')->isNotEmpty();
345+
}
346+
331347
/**
332348
* Determine if the method is deprecated.
333349
*
@@ -336,7 +352,11 @@ function isMagic($method)
336352
*/
337353
function isDeprecated($method)
338354
{
339-
return ! is_string($method) && $method->isDeprecated();
355+
if (is_string($method)) {
356+
return false;
357+
}
358+
359+
return $method->isDeprecated() || resolveDocTags($method->getDocComment(), '@deprecated')->isNotEmpty();
340360
}
341361

342362
/**

src/Illuminate/Support/Facades/Notification.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
* @method static void assertNothingSentTo(mixed $notifiable)
3030
* @method static void assertSentTimes(string $notification, int $expectedCount)
3131
* @method static void assertCount(int $expectedCount)
32-
* @method static void assertTimesSent(int $expectedCount, string $notification)
3332
* @method static \Illuminate\Support\Collection sent(mixed $notifiable, string $notification, callable|null $callback = null)
3433
* @method static bool hasSent(mixed $notifiable, string $notification)
3534
* @method static array sentNotifications()

src/Illuminate/Support/Facades/Redirect.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminate\Support\Facades;
44

55
/**
6-
* @method static \Illuminate\Http\RedirectResponse home(int $status = 302)
76
* @method static \Illuminate\Http\RedirectResponse back(int $status = 302, array $headers = [], mixed $fallback = false)
87
* @method static \Illuminate\Http\RedirectResponse refresh(int $status = 302, array $headers = [])
98
* @method static \Illuminate\Http\RedirectResponse guest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

src/Illuminate/Support/Facades/Request.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
* @method static bool getHttpMethodParameterOverride()
6767
* @method static bool hasPreviousSession()
6868
* @method static void setSession(\Symfony\Component\HttpFoundation\Session\SessionInterface $session)
69-
* @method static void setSessionFactory(callable(): SessionInterface $factory)
7069
* @method static array getClientIps()
7170
* @method static string|null getClientIp()
7271
* @method static string getScriptName()
@@ -96,7 +95,6 @@
9695
* @method static void setFormat(string|null $format, string|string[] $mimeTypes)
9796
* @method static string|null getRequestFormat(string|null $default = 'html')
9897
* @method static void setRequestFormat(string|null $format)
99-
* @method static string|null getContentType()
10098
* @method static string|null getContentTypeFormat()
10199
* @method static void setDefaultLocale(string $locale)
102100
* @method static string getDefaultLocale()

0 commit comments

Comments
 (0)