@@ -41,16 +41,28 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
41
41
{
42
42
$ args = $ methodCall ->args ;
43
43
if (count ($ args ) === 0 ) {
44
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
44
+ return ParametersAcceptorSelector::selectFromArgs (
45
+ $ scope ,
46
+ $ methodCall ->getArgs (),
47
+ $ methodReflection ->getVariants (),
48
+ )->getReturnType ();
45
49
}
46
50
47
51
$ arg = $ args [0 ]->value ;
48
52
if (!($ arg instanceof \PhpParser \Node \Expr \ClassConstFetch)) {
49
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
53
+ return ParametersAcceptorSelector::selectFromArgs (
54
+ $ scope ,
55
+ $ methodCall ->getArgs (),
56
+ $ methodReflection ->getVariants (),
57
+ )->getReturnType ();
50
58
}
51
59
52
60
if (!($ arg ->class instanceof \PhpParser \Node \Name)) {
53
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
61
+ return ParametersAcceptorSelector::selectFromArgs (
62
+ $ scope ,
63
+ $ methodCall ->getArgs (),
64
+ $ methodReflection ->getVariants (),
65
+ )->getReturnType ();
54
66
}
55
67
56
68
return new ObjectType ((string ) $ arg ->class );
@@ -75,12 +87,20 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
75
87
{
76
88
$ args = $ methodCall ->args ;
77
89
if (count ($ args ) === 0 ) {
78
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
90
+ return ParametersAcceptorSelector::selectFromArgs (
91
+ $ scope ,
92
+ $ methodCall ->getArgs (),
93
+ $ methodReflection ->getVariants (),
94
+ )->getReturnType ();
79
95
}
80
96
81
97
$ argType = $ scope ->getType ($ args [0 ]->value );
82
98
if (!$ argType instanceof ConstantStringType) {
83
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
99
+ return ParametersAcceptorSelector::selectFromArgs (
100
+ $ scope ,
101
+ $ methodCall ->getArgs (),
102
+ $ methodReflection ->getVariants (),
103
+ )->getReturnType ();
84
104
}
85
105
86
106
return new ObjectType ($ argType ->getValue ());
@@ -105,16 +125,28 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection,
105
125
{
106
126
$ args = $ methodCall ->args ;
107
127
if (count ($ args ) === 0 ) {
108
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
128
+ return ParametersAcceptorSelector::selectFromArgs (
129
+ $ scope ,
130
+ $ methodCall ->getArgs (),
131
+ $ methodReflection ->getVariants (),
132
+ )->getReturnType ();
109
133
}
110
134
111
135
$ arg = $ args [0 ]->value ;
112
136
if (!($ arg instanceof \PhpParser \Node \Expr \ClassConstFetch)) {
113
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
137
+ return ParametersAcceptorSelector::selectFromArgs (
138
+ $ scope ,
139
+ $ methodCall ->getArgs (),
140
+ $ methodReflection ->getVariants (),
141
+ )->getReturnType ();
114
142
}
115
143
116
144
if (!($ arg ->class instanceof \PhpParser \Node \Name)) {
117
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
145
+ return ParametersAcceptorSelector::selectFromArgs (
146
+ $ scope ,
147
+ $ methodCall ->getArgs (),
148
+ $ methodReflection ->getVariants (),
149
+ )->getReturnType ();
118
150
}
119
151
120
152
return new ObjectType ((string ) $ arg ->class );
@@ -215,7 +247,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
215
247
216
248
public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): Type
217
249
{
218
- return ParametersAcceptorSelector::selectSingle ($ methodReflection ->getVariants ())->getReturnType ();
250
+ return ParametersAcceptorSelector::selectFromArgs (
251
+ $ scope ,
252
+ $ methodCall ->getArgs (),
253
+ $ methodReflection ->getVariants (),
254
+ )->getReturnType ();
219
255
}
220
256
221
257
}
0 commit comments