@@ -115,7 +115,8 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra
115
115
));
116
116
117
117
if (isset ($ a [$ prefix .'returnType ' ])) {
118
- $ a [$ prefix .'returnType ' ] = method_exists ('ReflectionType ' , 'getName ' ) ? $ a [$ prefix .'returnType ' ]->getName () : $ a [$ prefix .'returnType ' ]->__toString ();
118
+ $ v = $ a [$ prefix .'returnType ' ];
119
+ $ a [$ prefix .'returnType ' ] = $ v instanceof \ReflectionNamedType ? $ v ->getName () : $ v ->__toString ();
119
120
}
120
121
if (isset ($ a [$ prefix .'this ' ])) {
121
122
$ a [$ prefix .'this ' ] = new CutStub ($ a [$ prefix .'this ' ]);
@@ -168,9 +169,9 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
168
169
));
169
170
170
171
try {
171
- if (method_exists ($ c , 'hasType ' )) {
172
- if ($ c ->hasType ()) {
173
- $ a [$ prefix .'typeHint ' ] = method_exists ( ' ReflectionType ' , ' getName ' ) ? $ c -> getType ()-> getName () : $ c -> getType () ->__toString ();
172
+ if (method_exists ($ c , 'getType ' )) {
173
+ if ($ v = $ c ->getType ()) {
174
+ $ a [$ prefix .'typeHint ' ] = $ v instanceof \ReflectionNamedType ? $ v -> getName () : $ v ->__toString ();
174
175
}
175
176
} else {
176
177
$ v = explode (' ' , $ c ->__toString (), 6 );
@@ -196,7 +197,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
196
197
unset($ a [$ prefix .'allowsNull ' ]);
197
198
}
198
199
} catch (\ReflectionException $ e ) {
199
- if (isset ($ a [$ prefix .'typeHint ' ]) && $ c ->allowsNull () && !method_exists ( ' ReflectionType ' , ' getName ' )) {
200
+ if (isset ($ a [$ prefix .'typeHint ' ]) && $ c ->allowsNull () && !class_exists ( ' ReflectionNamedType ' , false )) {
200
201
$ a [$ prefix .'default ' ] = null ;
201
202
unset($ a [$ prefix .'allowsNull ' ]);
202
203
}
0 commit comments