(PHP 8 >= 8.1.0)
ReflectionIntersectionType::getTypes — 返回包含在交集類(lèi)型中的類(lèi)型
返回包含在交集類(lèi)型中的類(lèi)型的反射。
此函數沒(méi)有參數。
包含 ReflectionType 對象的數組。
示例 #1 ReflectionIntersectionType::getTypes() 示例
<?php
function someFunction(Iterator&Countable $value) {}
$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParam = $reflectionFunc->getParameters()[0];
var_dump($reflectionParam->getType()->getTypes());
?>
以上例程的輸出類(lèi)似于:
array(2) { [0] => class ReflectionNamedType#4(0) { } [1] => class ReflectionNamedType#5(0) { } }