1414use PHPStan \Type \Accessory \HasMethodType ;
1515use PHPStan \Type \ClassStringType ;
1616use PHPStan \Type \Constant \ConstantBooleanType ;
17- use PHPStan \Type \Constant \ConstantStringType ;
1817use PHPStan \Type \FunctionTypeSpecifyingExtension ;
1918use PHPStan \Type \IntersectionType ;
2019use PHPStan \Type \ObjectWithoutClassType ;
@@ -50,8 +49,8 @@ public function specifyTypes(
5049 TypeSpecifierContext $ context ,
5150 ): SpecifiedTypes
5251 {
53- $ methodNameType = $ scope ->getType ($ node ->getArgs ()[1 ]->value );
54- if (! $ methodNameType instanceof ConstantStringType ) {
52+ $ methodNameTypes = $ scope ->getType ($ node ->getArgs ()[1 ]->value )-> getConstantStrings ( );
53+ if ($ methodNameTypes === [] ) {
5554 return $ this ->typeSpecifier ->create (
5655 new FuncCall (new FullyQualified ('method_exists ' ), $ node ->getRawArgs ()),
5756 new ConstantBooleanType (true ),
@@ -60,14 +59,19 @@ public function specifyTypes(
6059 );
6160 }
6261
62+ $ hasMethodTypes = [];
63+ foreach ($ methodNameTypes as $ methodNameType ) {
64+ $ hasMethodTypes [] = new HasMethodType ($ methodNameType ->getValue ());
65+ }
66+
6367 $ objectType = $ scope ->getType ($ node ->getArgs ()[0 ]->value );
6468 if ($ objectType ->isString ()->yes ()) {
6569 if ($ objectType ->isClassString ()->yes ()) {
6670 return $ this ->typeSpecifier ->create (
6771 $ node ->getArgs ()[0 ]->value ,
6872 new IntersectionType ([
6973 $ objectType ,
70- new HasMethodType ( $ methodNameType -> getValue ()) ,
74+ ... $ hasMethodTypes ,
7175 ]),
7276 $ context ,
7377 $ scope ,
@@ -82,7 +86,7 @@ public function specifyTypes(
8286 new UnionType ([
8387 new IntersectionType ([
8488 new ObjectWithoutClassType (),
85- new HasMethodType ( $ methodNameType -> getValue ()) ,
89+ ... $ hasMethodTypes ,
8690 ]),
8791 new ClassStringType (),
8892 ]),
0 commit comments