xref: /PHP-8.0/ext/reflection/tests/bug78774.phpt (revision 1fa6f032)
1--TEST--
2Bug #78774: ReflectionNamedType on Typed Properties Crash
3--FILE--
4<?php
5
6class Test {
7    public stdClass $prop;
8    public stdClass|Foo $prop2;
9}
10
11$rc = new ReflectionClass(Test::class);
12$rp = $rc->getProperty('prop');
13$rt = $rp->getType();
14$rp2 = $rc->getProperty('prop2');
15$rt2 = $rp2->getType();
16
17// Force a resolution of the property type
18$test = new Test;
19$test->prop = new stdClass;
20$test->prop2 = new stdClass;
21
22var_dump($rt->getName());
23var_dump((string) $rt2);
24
25?>
26--EXPECT--
27string(8) "stdClass"
28string(12) "stdClass|Foo"
29