File tree Expand file tree Collapse file tree 3 files changed +63
-2
lines changed
Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
2- <files psalm-version =" 6.6.0@07e9a53713232e924da9acb4a6e47507461cd411 " >
2+ <files psalm-version =" 6.6.1@dae5a05eac03b55e8f50ae00f4cd2ba5d5588d59 " >
33 <file src =" src/Handlers/Auth/AuthConfigAnalyzer.php" >
44 <MixedArgument >
55 <code ><![CDATA[ $this->config->get('auth.guards')]]> </code >
1010 </MixedReturnStatement >
1111 </file >
1212 <file src =" src/Handlers/Auth/AuthHandler.php" >
13+ <LessSpecificImplementedReturnType >
14+ <code ><![CDATA[ array]]> </code >
15+ <code ><![CDATA[ array]]> </code >
16+ </LessSpecificImplementedReturnType >
1317 <TypeDoesNotContainType >
1418 <code ><![CDATA[ null]]> </code >
1519 </TypeDoesNotContainType >
Original file line number Diff line number Diff line change 55namespace Psalm \LaravelPlugin \Handlers \Auth ;
66
77use Psalm \Plugin \EventHandler \Event \MethodReturnTypeProviderEvent ;
8+ use Psalm \Plugin \EventHandler \Event \MethodParamsProviderEvent ;
89use Psalm \Plugin \EventHandler \MethodReturnTypeProviderInterface ;
10+ use Psalm \Plugin \EventHandler \MethodParamsProviderInterface ;
911use Psalm \Type ;
1012
1113use function in_array ;
2830 * @see \Illuminate\Support\Facades\Auth::setRequest()
2931 * @see \Illuminate\Support\Facades\Auth::forgetUser()
3032 */
31- final class AuthHandler implements MethodReturnTypeProviderInterface
33+ final class AuthHandler implements MethodReturnTypeProviderInterface, MethodParamsProviderInterface
3234{
3335 /** @inheritDoc */
36+ #[\Override]
3437 public static function getClassLikeNames (): array
3538 {
3639 return [\Illuminate \Support \Facades \Auth::class];
3740 }
3841
3942 /** @inheritDoc */
43+ #[\Override]
4044 public static function getMethodReturnType (MethodReturnTypeProviderEvent $ event ): ?Type \Union
4145 {
4246 $ method_name_lowercase = $ event ->getMethodNameLowercase ();
@@ -81,4 +85,18 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event)
8185 default => null ,
8286 };
8387 }
88+
89+ #[\Override]
90+ public static function getMethodParams (MethodParamsProviderEvent $ event ): ?array
91+ {
92+ $ method_name_lowercase = $ event ->getMethodNameLowercase ();
93+
94+ if ($ method_name_lowercase !== 'user ' ) {
95+ return null ;
96+ }
97+
98+ return match ($ method_name_lowercase ) {
99+ 'user ' => [], // Explicitly define that user() has no parameters
100+ };
101+ }
84102}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Psalm \LaravelPlugin \Tests \Unit \Handlers \Auth ;
6+
7+ use PHPUnit \Framework \Attributes \CoversClass ;
8+ use PHPUnit \Framework \TestCase ;
9+ use Psalm \LaravelPlugin \Handlers \Auth \AuthHandler ;
10+ use Psalm \Plugin \EventHandler \Event \MethodParamsProviderEvent ;
11+
12+ #[CoversClass(AuthHandler::class)]
13+ final class AuthHandlerTest extends TestCase
14+ {
15+ public function testGetMethodParamsForUser (): void
16+ {
17+ $ event = new MethodParamsProviderEvent (
18+ \Illuminate \Support \Facades \Auth::class,
19+ 'user '
20+ );
21+
22+ $ params = AuthHandler::getMethodParams ($ event );
23+
24+ $ this ->assertNotNull ($ params );
25+ $ this ->assertEmpty ($ params );
26+ }
27+
28+ public function testGetMethodParamsForUnknownMethod (): void
29+ {
30+ $ event = new MethodParamsProviderEvent (
31+ \Illuminate \Support \Facades \Auth::class,
32+ 'unknown '
33+ );
34+
35+ $ params = AuthHandler::getMethodParams ($ event );
36+
37+ $ this ->assertNull ($ params );
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments