File tree Expand file tree Collapse file tree 2 files changed +43
-2
lines changed
Expand file tree Collapse file tree 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-19053: Incorrect properties_info_table for abstract properties
3+ --FILE--
4+ <?php
5+
6+ abstract class GP {
7+ public abstract mixed $ foo { get; }
8+ }
9+
10+ class P extends GP {
11+ public mixed $ foo = 1 ;
12+ }
13+
14+ class C extends P {
15+ public mixed $ foo { get => 2 ; }
16+ }
17+
18+ $ c = new C ;
19+ var_dump ($ c );
20+
21+ ?>
22+ --EXPECTF--
23+ object(C)#%d (0) {
24+ ["foo"]=>
25+ uninitialized(mixed)
26+ }
Original file line number Diff line number Diff line change @@ -1713,10 +1713,25 @@ void zend_build_properties_info_table(zend_class_entry *ce)
17131713 }
17141714 }
17151715
1716- ZEND_HASH_MAP_FOREACH_PTR (& ce -> properties_info , prop ) {
1716+ ZEND_HASH_MAP_FOREACH_STR_KEY_PTR (& ce -> properties_info , zend_string * key , prop ) {
17171717 if (prop -> ce == ce && (prop -> flags & ZEND_ACC_STATIC ) == 0
17181718 && !(prop -> flags & ZEND_ACC_VIRTUAL )) {
1719- uint32_t prop_table_offset = OBJ_PROP_TO_NUM (!(prop -> prototype -> flags & ZEND_ACC_VIRTUAL ) ? prop -> prototype -> offset : prop -> offset );
1719+ const zend_property_info * root_prop = prop -> prototype ;
1720+ if (UNEXPECTED (root_prop -> flags & ZEND_ACC_VIRTUAL )) {
1721+ /* Prototype is virtual, we need to manually hunt down the first backed property. */
1722+ root_prop = prop ;
1723+ zend_class_entry * parent_ce ;
1724+ while ((parent_ce = root_prop -> ce -> parent )) {
1725+ zend_property_info * parent_prop = zend_hash_find_ptr (& parent_ce -> properties_info , key );
1726+ if (!parent_prop
1727+ || parent_prop -> prototype != prop -> prototype
1728+ || (parent_prop -> flags & ZEND_ACC_VIRTUAL )) {
1729+ break ;
1730+ }
1731+ root_prop = parent_prop ;
1732+ }
1733+ }
1734+ uint32_t prop_table_offset = OBJ_PROP_TO_NUM (root_prop -> offset );
17201735 table [prop_table_offset ] = prop ;
17211736 }
17221737 } ZEND_HASH_FOREACH_END ();
You can’t perform that action at this time.
0 commit comments