Make sure to deindirect properties when creating array.
- Core:
. Fixed bug #79434 (PHP 7.3 and PHP-7.4 crash with NULL-pointer dereference
on !CS constant). (Nikita)
+ . Fixed bug #79477 (casting object into array creates references). (Nikita)
- DOM:
. Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).
--- /dev/null
+--TEST--
+Bug #79477: casting object into array creates references
+--FILE--
+<?php
+
+class Test {
+ public $prop = 'default value';
+}
+
+$obj = new Test;
+$obj->{1} = null;
+
+$arr = (array) $obj;
+$arr['prop'] = 'new value';
+
+echo $obj->prop, "\n";
+
+?>
+--EXPECT--
+default value
{
HashTable *new_ht = zend_new_array(zend_hash_num_elements(ht));
- ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, str_key, zv) {
+ ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, str_key, zv) {
do {
if (Z_OPT_REFCOUNTED_P(zv)) {
if (Z_ISREF_P(zv) && Z_REFCOUNT_P(zv) == 1) {