array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'reflectionuniontype.gettypes.php', 1 => 'ReflectionUnionType::getTypes', 2 => 'Returns the types included in the union type', ), 'up' => array ( 0 => 'class.reflectionuniontype.php', 1 => 'ReflectionUnionType', ), 'prev' => array ( 0 => 'class.reflectionuniontype.php', 1 => 'ReflectionUnionType', ), 'next' => array ( 0 => 'class.reflectiongenerator.php', 1 => 'ReflectionGenerator', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/reflection/reflectionuniontype/gettypes.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 8)
ReflectionUnionType::getTypes — Returns the types included in the union type
Returns the reflections of types included in the union type.
У цієї функції немає параметрів.
An array of ReflectionType objects.
Приклад #1 ReflectionUnionType::getTypes() example
<?php
function someFunction(int|float $number) {}
$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParam = $reflectionFunc->getParameters()[0];
var_dump($reflectionParam->getType()->getTypes());Поданий вище приклад виведе щось схоже на:
array(2) {
[0] =>
class ReflectionNamedType#4(0) {
}
[1] =>
class ReflectionNamedType#5(0) {
}
}