Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  Fix GH-8080: ReflectionClass::getConstants() depends on def. order
This commit is contained in:
Christoph M. Becker 2022-02-28 10:11:29 +01:00
commit 27d2fddf6a
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
3 changed files with 37 additions and 2 deletions

4
NEWS
View file

@ -28,6 +28,10 @@ PHP NEWS
- MySQLnd:
. Fixed bug GH-8058 (NULL pointer dereference in mysqlnd package). (Kamil Tekiela)
- Reflection:
. Fixed bug GH-8080 (ReflectionClass::getConstants() depends on def. order).
(cmb)
- Zlib:
. Fixed bug GH-7953 (ob_clean() only does not set Content-Encoding). (cmb)

View file

@ -4637,7 +4637,7 @@ ZEND_METHOD(ReflectionClass, getConstants)
array_init(return_value);
ZEND_HASH_FOREACH_STR_KEY_PTR(CE_CONSTANTS_TABLE(ce), key, constant) {
if (UNEXPECTED(zval_update_constant_ex(&constant->value, ce) != SUCCESS)) {
if (UNEXPECTED(zval_update_constant_ex(&constant->value, constant->ce) != SUCCESS)) {
RETURN_THROWS();
}
@ -4696,7 +4696,7 @@ ZEND_METHOD(ReflectionClass, getConstant)
GET_REFLECTION_OBJECT_PTR(ce);
constants_table = CE_CONSTANTS_TABLE(ce);
ZEND_HASH_FOREACH_PTR(constants_table, c) {
if (UNEXPECTED(zval_update_constant_ex(&c->value, ce) != SUCCESS)) {
if (UNEXPECTED(zval_update_constant_ex(&c->value, c->ce) != SUCCESS)) {
RETURN_THROWS();
}
} ZEND_HASH_FOREACH_END();

View file

@ -0,0 +1,31 @@
--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"
}