@@ -50,7 +50,7 @@ public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
50
50
51
51
public function isStaticMethodSupported (MethodReflection $ methodReflection , StaticCall $ node , TypeSpecifierContext $ context ): bool
52
52
{
53
- return in_array ($ methodReflection ->getName (), ['match ' , 'matchAll ' ], true ) && !$ context ->null ();
53
+ return \ in_array ($ methodReflection ->getName (), ['match ' , 'matchAll ' ], true ) && !$ context ->null ();
54
54
}
55
55
56
56
public function specifyTypes (MethodReflection $ methodReflection , StaticCall $ node , Scope $ scope , TypeSpecifierContext $ context ): SpecifiedTypes
@@ -71,11 +71,15 @@ public function specifyTypes(MethodReflection $methodReflection, StaticCall $nod
71
71
$ flagsType = $ scope ->getType ($ flagsArg ->value );
72
72
}
73
73
74
- if ($ methodReflection ->getName () === 'match ' ) {
75
- $ matchedType = $ this ->regexShapeMatcher ->matchExpr ($ patternArg ->value , $ flagsType , TrinaryLogic::createFromBoolean ($ context ->true ()), $ scope );
76
- } else {
77
- $ matchedType = $ this ->regexShapeMatcher ->matchAllExpr ($ patternArg ->value , $ flagsType , TrinaryLogic::createFromBoolean ($ context ->true ()), $ scope );
78
- }
74
+ $ matcherMethod = ('match ' === $ methodReflection ->getName ()) ? 'matchExpr ' : 'matchAllExpr ' ;
75
+
76
+ /** @phpstan-ignore method.dynamicName */
77
+ $ matchedType = $ this ->regexShapeMatcher ->{$ matcherMethod }(
78
+ $ patternArg ->value ,
79
+ $ flagsType ,
80
+ TrinaryLogic::createFromBoolean ($ context ->true ()),
81
+ $ scope
82
+ );
79
83
80
84
if (null === $ matchedType ) {
81
85
return new SpecifiedTypes ();
0 commit comments