ReflectionIntersectionType::getTypes

(PHP 8 >= 8.1.0)

ReflectionIntersectionType::getTypes返回包含在交集類(lèi)型中的類(lèi)型

說(shuō)明

public ReflectionIntersectionType::getTypes(): array

返回包含在交集類(lèi)型中的類(lèi)型的反射。

參數(shù)

此函數(shù)沒(méi)有參數(shù)。

返回值

包含 ReflectionType 對(duì)象的數(shù)組。

范例

示例 #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) {
    }
}

參見(jiàn)