22
22
use PHPStan \Analyser \TypeSpecifierAwareExtension ;
23
23
use PHPStan \Analyser \TypeSpecifierContext ;
24
24
use PHPStan \Reflection \MethodReflection ;
25
- use PHPStan \Reflection \ParameterReflection ;
26
25
use PHPStan \TrinaryLogic ;
27
26
use PHPStan \Type \Php \RegexArrayShapeMatcher ;
28
- use PHPStan \Type \StaticMethodParameterOutTypeExtension ;
29
27
use PHPStan \Type \StaticMethodTypeSpecifyingExtension ;
30
28
31
29
final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
@@ -36,8 +34,7 @@ final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyi
36
34
37
35
public function __construct (
38
36
RegexArrayShapeMatcher $ regexShapeMatcher
39
- )
40
- {
37
+ ) {
41
38
$ this ->regexShapeMatcher = $ regexShapeMatcher ;
42
39
}
43
40
@@ -53,7 +50,7 @@ public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
53
50
54
51
public function isStaticMethodSupported (MethodReflection $ staticMethodReflection , StaticCall $ node , TypeSpecifierContext $ context ): bool
55
52
{
56
- return $ staticMethodReflection ->getName () === ' match ' && !$ context ->null ();
53
+ return ' match ' === $ staticMethodReflection ->getName () && !$ context ->null ();
57
54
}
58
55
59
56
public function specifyTypes (MethodReflection $ staticMethodReflection , StaticCall $ node , Scope $ scope , TypeSpecifierContext $ context ): SpecifiedTypes
@@ -64,19 +61,19 @@ public function specifyTypes(MethodReflection $staticMethodReflection, StaticCal
64
61
$ flagsArg = $ args [3 ] ?? null ;
65
62
66
63
if (
67
- $ patternArg === null || $ matchesArg === null
64
+ null === $ patternArg || null === $ matchesArg
68
65
) {
69
66
return new SpecifiedTypes ();
70
67
}
71
68
72
69
$ patternType = $ scope ->getType ($ patternArg ->value );
73
70
$ flagsType = null ;
74
- if ($ flagsArg !== null ) {
71
+ if (null !== $ flagsArg ) {
75
72
$ flagsType = $ scope ->getType ($ flagsArg ->value );
76
73
}
77
74
78
75
$ matchedType = $ this ->regexShapeMatcher ->matchType ($ patternType , $ flagsType , TrinaryLogic::createFromBoolean ($ context ->true ()));
79
- if ($ matchedType === null ) {
76
+ if (null === $ matchedType ) {
80
77
return new SpecifiedTypes ();
81
78
}
82
79
@@ -95,5 +92,4 @@ public function specifyTypes(MethodReflection $staticMethodReflection, StaticCal
95
92
$ node ,
96
93
);
97
94
}
98
-
99
95
}
0 commit comments