@@ -59,40 +59,43 @@ public function specifyTypes(
59
59
);
60
60
}
61
61
62
- $ hasMethodTypes = [];
63
- foreach ($ methodNameTypes as $ methodNameType ) {
64
- $ hasMethodTypes [] = new HasMethodType ($ methodNameType ->getValue ());
65
- }
62
+ $ specifiedTypes = new SpecifiedTypes ([], []);
66
63
67
64
$ objectType = $ scope ->getType ($ node ->getArgs ()[0 ]->value );
68
65
if ($ objectType ->isString ()->yes ()) {
69
66
if ($ objectType ->isClassString ()->yes ()) {
70
- return $ this ->typeSpecifier ->create (
71
- $ node ->getArgs ()[0 ]->value ,
72
- new IntersectionType ([
73
- $ objectType ,
74
- ...$ hasMethodTypes ,
75
- ]),
76
- $ context ,
77
- $ scope ,
78
- );
67
+ foreach ($ methodNameTypes as $ methodNameType ) {
68
+ $ specifiedTypes = $ specifiedTypes ->unionWith ($ this ->typeSpecifier ->create (
69
+ $ node ->getArgs ()[0 ]->value ,
70
+ new IntersectionType ([
71
+ $ objectType ,
72
+ new HasMethodType ($ methodNameType ->getValue ()),
73
+ ]),
74
+ $ context ,
75
+ $ scope ,
76
+ ));
77
+ }
79
78
}
80
79
81
- return new SpecifiedTypes ([], []) ;
80
+ return $ specifiedTypes ;
82
81
}
83
82
84
- return $ this ->typeSpecifier ->create (
85
- $ node ->getArgs ()[0 ]->value ,
86
- new UnionType ([
87
- new IntersectionType ([
88
- new ObjectWithoutClassType (),
89
- ...$ hasMethodTypes ,
83
+ foreach ($ methodNameTypes as $ methodNameType ) {
84
+ $ specifiedTypes = $ specifiedTypes ->unionWith ($ this ->typeSpecifier ->create (
85
+ $ node ->getArgs ()[0 ]->value ,
86
+ new UnionType ([
87
+ new IntersectionType ([
88
+ new ObjectWithoutClassType (),
89
+ new HasMethodType ($ methodNameType ->getValue ()),
90
+ ]),
91
+ new ClassStringType (),
90
92
]),
91
- new ClassStringType (),
92
- ]),
93
- $ context ,
94
- $ scope ,
95
- );
93
+ $ context ,
94
+ $ scope ,
95
+ ));
96
+ }
97
+
98
+ return $ specifiedTypes ;
96
99
}
97
100
98
101
}
0 commit comments