mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix virtual properties in get_class_vars() (GH-15494)
Fixes GH-15456
This commit is contained in:
2
NEWS
2
NEWS
@@ -10,6 +10,8 @@ PHP NEWS
|
||||
. Fixed bug GH-15419 (Missing readonly+hook incompatibility check for readonly
|
||||
classes). (ilutov)
|
||||
. Fixed bug GH-15187 (Various hooked object iterator issues). (ilutov)
|
||||
. Fixed bug GH-15456 (Crash in get_class_vars() on virtual properties).
|
||||
(ilutov)
|
||||
|
||||
15 Aug 2024, PHP 8.4.0beta3
|
||||
|
||||
|
||||
20
Zend/tests/property_hooks/gh15456.phpt
Normal file
20
Zend/tests/property_hooks/gh15456.phpt
Normal file
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
GH-15456: Crash in get_class_vars() on virtual properties
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class C {
|
||||
public $a = 42;
|
||||
public $b = 42 { get => $this->b * 2; }
|
||||
public $c { get => 42; }
|
||||
}
|
||||
var_dump(get_class_vars(C::class));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
["a"]=>
|
||||
int(42)
|
||||
["b"]=>
|
||||
int(42)
|
||||
}
|
||||
@@ -724,7 +724,8 @@ static void add_class_vars(zend_class_entry *scope, zend_class_entry *ce, bool s
|
||||
if (((prop_info->flags & ZEND_ACC_PROTECTED) &&
|
||||
!zend_check_protected(prop_info->ce, scope)) ||
|
||||
((prop_info->flags & ZEND_ACC_PRIVATE) &&
|
||||
prop_info->ce != scope)) {
|
||||
prop_info->ce != scope) ||
|
||||
(prop_info->flags & ZEND_ACC_VIRTUAL)) {
|
||||
continue;
|
||||
}
|
||||
prop = NULL;
|
||||
|
||||
Reference in New Issue
Block a user