1--TEST--
2iterable Type in Reflection
3--FILE--
4<?php
5
6$function = function(iterable $arg): iterable {};
7
8$paramType = (new ReflectionParameter($function, 0))->getType();
9var_dump($paramType::class);
10var_dump($paramType);
11var_dump($paramType->getName());
12var_dump((string) $paramType);
13var_dump($paramType->isBuiltin());
14
15$reflectionFunc = new ReflectionFunction($function);
16$returnType = $reflectionFunc->getReturnType();
17var_dump($returnType::class);
18var_dump($returnType);
19var_dump($returnType->getName());
20var_dump((string) $returnType);
21var_dump($returnType->isBuiltin());
22
23class PropIterableTypeTest {
24    public iterable $iterable;
25    public ?iterable $nullableIterable;
26    public array $control;
27    public ?array $nullableControl;
28}
29
30$reflector = new ReflectionClass(PropIterableTypeTest::class);
31
32[$property, $nullable, $control, $nullableControl] = $reflector->getProperties();
33$iterableType = $property->getType();
34var_dump($iterableType::class);
35var_dump($iterableType);
36var_dump($iterableType->getName());
37var_dump((string) $iterableType);
38var_dump($iterableType->isBuiltin());
39
40$nullableIterableType = $nullable->getType();
41var_dump($nullableIterableType::class);
42var_dump($nullableIterableType);
43var_dump($nullableIterableType->getName());
44var_dump((string) $nullableIterableType);
45var_dump($nullableIterableType->isBuiltin());
46
47$controlType = $control->getType();
48var_dump($controlType::class);
49var_dump($controlType);
50var_dump($controlType->getName());
51var_dump((string) $controlType);
52var_dump($controlType->isBuiltin());
53
54$nullableControlType = $nullableControl->getType();
55var_dump($nullableControlType::class);
56var_dump($nullableControlType);
57var_dump($nullableControlType->getName());
58var_dump((string) $nullableControlType);
59var_dump($nullableControlType->isBuiltin());
60
61?>
62--EXPECTF--
63string(19) "ReflectionNamedType"
64object(ReflectionNamedType)#%d (0) {
65}
66string(8) "iterable"
67string(8) "iterable"
68bool(true)
69string(19) "ReflectionNamedType"
70object(ReflectionNamedType)#%d (0) {
71}
72string(8) "iterable"
73string(8) "iterable"
74bool(true)
75string(19) "ReflectionNamedType"
76object(ReflectionNamedType)#%d (0) {
77}
78string(8) "iterable"
79string(8) "iterable"
80bool(true)
81string(19) "ReflectionNamedType"
82object(ReflectionNamedType)#%d (0) {
83}
84string(8) "iterable"
85string(9) "?iterable"
86bool(true)
87string(19) "ReflectionNamedType"
88object(ReflectionNamedType)#%d (0) {
89}
90string(5) "array"
91string(5) "array"
92bool(true)
93string(19) "ReflectionNamedType"
94object(ReflectionNamedType)#%d (0) {
95}
96string(5) "array"
97string(6) "?array"
98bool(true)
99