Skip to content

Commit 3052823

Browse files
[3.4] Fix support for PHP8 union types
1 parent 1362ae9 commit 3052823

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Caster/ReflectionCaster.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNes
9191
$prefix = Caster::PREFIX_VIRTUAL;
9292

9393
$a += [
94-
$prefix.'name' => $c instanceof \ReflectionNamedType ? $c->getName() : $c->__toString(),
94+
$prefix.'name' => $c instanceof \ReflectionNamedType ? $c->getName() : (string) $c,
9595
$prefix.'allowsNull' => $c->allowsNull(),
9696
$prefix.'isBuiltin' => $c->isBuiltin(),
9797
];
@@ -178,7 +178,7 @@ public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, arra
178178

179179
if (isset($a[$prefix.'returnType'])) {
180180
$v = $a[$prefix.'returnType'];
181-
$v = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
181+
$v = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v;
182182
$a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType']->allowsNull() ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']);
183183
}
184184
if (isset($a[$prefix.'class'])) {
@@ -247,7 +247,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
247247

248248
if (method_exists($c, 'getType')) {
249249
if ($v = $c->getType()) {
250-
$a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : $v->__toString();
250+
$a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v;
251251
}
252252
} elseif (preg_match('/^(?:[^ ]++ ){4}([a-zA-Z_\x7F-\xFF][^ ]++)/', $c, $v)) {
253253
$a[$prefix.'typeHint'] = $v[1];

0 commit comments

Comments
 (0)