99use PHPStan \Analyser \TypeSpecifierAwareExtension ;
1010use PHPStan \Analyser \TypeSpecifierContext ;
1111use PHPStan \Reflection \MethodReflection ;
12- use PHPStan \Reflection \ParametersAcceptorSelector ;
13- use PHPStan \Reflection \ReflectionProvider ;
1412use PHPStan \Type \MethodTypeSpecifyingExtension ;
15- use PHPStan \Type \TypeCombinator ;
13+ use PHPStan \Type \NullType ;
1614use Symfony \Component \HttpFoundation \InputBag ;
1715
1816final class InputBagTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
@@ -22,17 +20,9 @@ final class InputBagTypeSpecifyingExtension implements MethodTypeSpecifyingExten
2220 private const HAS_METHOD_NAME = 'has ' ;
2321 private const GET_METHOD_NAME = 'get ' ;
2422
25- /** @var ReflectionProvider */
26- private $ reflectionProvider ;
27-
2823 /** @var TypeSpecifier */
2924 private $ typeSpecifier ;
3025
31- public function __construct (ReflectionProvider $ reflectionProvider )
32- {
33- $ this ->reflectionProvider = $ reflectionProvider ;
34- }
35-
3626 public function getClass (): string
3727 {
3828 return self ::INPUT_BAG_CLASS ;
@@ -45,18 +35,10 @@ public function isMethodSupported(MethodReflection $methodReflection, MethodCall
4535
4636 public function specifyTypes (MethodReflection $ methodReflection , MethodCall $ node , Scope $ scope , TypeSpecifierContext $ context ): SpecifiedTypes
4737 {
48- $ classReflection = $ this ->reflectionProvider ->getClass (self ::INPUT_BAG_CLASS );
49- $ methodVariants = $ classReflection ->getNativeMethod (self ::GET_METHOD_NAME )->getVariants ();
50- $ returnType = ParametersAcceptorSelector::selectSingle ($ methodVariants )->getReturnType ();
51-
52- if (!TypeCombinator::containsNull ($ returnType )) {
53- return new SpecifiedTypes ();
54- }
55-
5638 return $ this ->typeSpecifier ->create (
5739 new MethodCall ($ node ->var , self ::GET_METHOD_NAME , $ node ->getArgs ()),
58- TypeCombinator:: removeNull ( $ returnType ),
59- $ context
40+ new NullType ( ),
41+ $ context-> negate ()
6042 );
6143 }
6244
0 commit comments