php-src/ext/reflection/tests/gh8080.phpt
Christoph M. Becker 0d266a24d6
Fix GH-8080: ReflectionClass::getConstants() depends on def. order
When we need to evaluate constant ASTs, we always have to do that in
the scope where the constant has been defined, which may be a parent
of the `ReflectionClass`'s scope.

Closes GH-8106.
2022-02-28 10:08:47 +01:00

32 lines
451 B
PHP

--TEST--
GH-8080 (ReflectionClass::getConstants() depends on def. order)
--FILE--
<?php
class A {
const LIST = [
self::TEST => 'Test',
];
private const TEST = 'test';
}
class B extends A {}
$r = new ReflectionClass(B::class);
var_dump(
$r->getConstants(),
$r->getConstant("LIST")
);
?>
--EXPECT--
array(1) {
["LIST"]=>
array(1) {
["test"]=>
string(4) "Test"
}
}
array(1) {
["test"]=>
string(4) "Test"
}