9
9
use PHPStan \Analyser \TypeSpecifierAwareExtension ;
10
10
use PHPStan \Analyser \TypeSpecifierContext ;
11
11
use PHPStan \Reflection \MethodReflection ;
12
- use PHPStan \Reflection \ParametersAcceptorSelector ;
13
- use PHPStan \Reflection \ReflectionProvider ;
14
12
use PHPStan \Type \MethodTypeSpecifyingExtension ;
15
- use PHPStan \Type \TypeCombinator ;
13
+ use PHPStan \Type \NullType ;
16
14
use Symfony \Component \HttpFoundation \InputBag ;
17
15
18
16
final class InputBagTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
@@ -22,17 +20,9 @@ final class InputBagTypeSpecifyingExtension implements MethodTypeSpecifyingExten
22
20
private const HAS_METHOD_NAME = 'has ' ;
23
21
private const GET_METHOD_NAME = 'get ' ;
24
22
25
- /** @var ReflectionProvider */
26
- private $ reflectionProvider ;
27
-
28
23
/** @var TypeSpecifier */
29
24
private $ typeSpecifier ;
30
25
31
- public function __construct (ReflectionProvider $ reflectionProvider )
32
- {
33
- $ this ->reflectionProvider = $ reflectionProvider ;
34
- }
35
-
36
26
public function getClass (): string
37
27
{
38
28
return self ::INPUT_BAG_CLASS ;
@@ -45,18 +35,10 @@ public function isMethodSupported(MethodReflection $methodReflection, MethodCall
45
35
46
36
public function specifyTypes (MethodReflection $ methodReflection , MethodCall $ node , Scope $ scope , TypeSpecifierContext $ context ): SpecifiedTypes
47
37
{
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
-
56
38
return $ this ->typeSpecifier ->create (
57
39
new MethodCall ($ node ->var , self ::GET_METHOD_NAME , $ node ->getArgs ()),
58
- TypeCombinator:: removeNull ( $ returnType ),
59
- $ context
40
+ new NullType ( ),
41
+ $ context-> negate ()
60
42
);
61
43
}
62
44
0 commit comments