php8.5
Home/ Manual/ reflection / reflectionintersectiontype/ ReflectionIntersectionType::getTypes

ReflectionIntersectionType::getTypes

PHP function Edit on GitHub ✎

(PHP 8 >= 8.1.0)

Returns the types included in the intersection type

Description

ReflectionIntersectionType::getTypes(): array

Returns the reflections of types included in the intersection type.

Parameters Parameters

Return Values

An array of ReflectionType objects.

Examples

ReflectionIntersectionType::getTypes example

php
<?php

function someFunction(Iterator&Countable $value) {}

$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParam = $reflectionFunc->getParameters()[0];

var_dump($reflectionParam->getType()->getTypes());
?>

The above example will output something similar to:

output
array(2) {
    [0] =>
    class ReflectionNamedType#4(0) {
    }
    [1] =>
    class ReflectionNamedType#5(0) {
    }
}

See Also

  • ReflectionType::allowsNull
  • ReflectionParameter::getType

Source: reference/reflection/reflectionintersectiontype/gettypes.xml · from the official PHP manual (php/doc-en)