xref: /PHP-8.1/ext/reflection/tests/bug77325.phpt (revision 0d06a63e)
1--TEST--
2Bug #77325: ReflectionClassConstant::$class returns wrong class when extending
3--FILE--
4<?php
5
6class Foo {
7    const FOO = 'foo';
8}
9
10class Bar extends Foo {
11}
12
13$barClassReflection = new ReflectionClass(Bar::class);
14$constants = $barClassReflection->getReflectionConstants();
15foreach ($constants as $constant) {
16    var_dump($constant->class);
17    var_dump($constant->getDeclaringClass()->getName());
18}
19
20$constant = new ReflectionClassConstant(Bar::class, 'FOO');
21var_dump($constant->class);
22var_dump($constant->getDeclaringClass()->getName());
23
24?>
25--EXPECT--
26string(3) "Foo"
27string(3) "Foo"
28string(3) "Foo"
29string(3) "Foo"
30