php-src/ext/reflection/tests/bug77325.phpt
Nikita Popov 0d06a63ee3 Fixed bug #77325
Make ReflectionClassConstant->class the declaring class, not the
class on which the constant was fetched. This matches the behavior
for properties and methods.
2020-02-28 17:21:19 +01:00

30 lines
632 B
PHP

--TEST--
Bug #77325: ReflectionClassConstant::$class returns wrong class when extending
--FILE--
<?php
class Foo {
const FOO = 'foo';
}
class Bar extends Foo {
}
$barClassReflection = new ReflectionClass(Bar::class);
$constants = $barClassReflection->getReflectionConstants();
foreach ($constants as $constant) {
var_dump($constant->class);
var_dump($constant->getDeclaringClass()->getName());
}
$constant = new ReflectionClassConstant(Bar::class, 'FOO');
var_dump($constant->class);
var_dump($constant->getDeclaringClass()->getName());
?>
--EXPECT--
string(3) "Foo"
string(3) "Foo"
string(3) "Foo"
string(3) "Foo"