mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
0d06a63ee3
Make ReflectionClassConstant->class the declaring class, not the class on which the constant was fetched. This matches the behavior for properties and methods.
30 lines
632 B
PHP
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"
|