--- /dev/null
+--TEST--
+Overwriting a typed property that is not yet a reference
+--FILE--
+<?php
+
+class Test {
+ public ?Test $prop;
+}
+$s = <<<'STR'
+O:4:"Test":2:{s:4:"prop";N;s:4:"prop";O:4:"Test":1:{s:4:"prop";R:2;}}
+STR;
+var_dump(unserialize($s));
+
+?>
+--EXPECT--
+object(Test)#1 (1) {
+ ["prop"]=>
+ &object(Test)#2 (1) {
+ ["prop"]=>
+ *RECURSION*
+ }
+}
/* This is a property with a declaration */
old_data = Z_INDIRECT_P(old_data);
info = zend_get_typed_property_info_for_slot(obj, old_data);
- if (info && Z_ISREF_P(old_data)) {
- /* If the value is overwritten, remove old type source from ref. */
- ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(old_data), info);
+ if (info) {
+ if (Z_ISREF_P(old_data)) {
+ /* If the value is overwritten, remove old type source from ref. */
+ ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(old_data), info);
+ }
+
+ if ((*var_hash)->ref_props) {
+ /* Remove old entry from ref_props table, if it exists. */
+ zend_hash_index_del(
+ (*var_hash)->ref_props, (zend_uintptr_t) old_data);
+ }
}
var_push_dtor(var_hash, old_data);
Z_TRY_DELREF_P(old_data);