PHP 8.6.0 Beta 1 is available for testing

ReflectionIntersectionType::getTypes

(PHP 8 >= 8.1.0)

ReflectionIntersectionType::getTypesDevuelve los tipos incluidos en el tipo de intersección

Descripción

public function ReflectionIntersectionType::getTypes(): array

Devuelve los tipos incluidos en el tipo de intersección.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Un array de objetos ReflectionType .

Ejemplos

Ejemplo #1 Ejemplo de ReflectionIntersectionType::getTypes()

<?php
function someFunction(Iterator&Countable $value) {}
$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParam = $reflectionFunc->getParameters()[0];
var_dump($reflectionParam->getType()->getTypes());
?>

Resultado del ejemplo anterior es similar a:

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

Véase también

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 1 note

up
2
baptiste at pillot dot fr
2 years ago
php 8.2: ReflectionIntersectionType::getTypes returns an array of ReflectionNamedType. For now, PHP's DNF implementation does not allow union types nested into intersection types.
+add a note

AltStyle によって変換されたページ (->オリジナル) /