[php-src] Issue #10899: Override properties in object after push in array

From: Date: Tue, 21 Mar 2023 10:40:27 +0000
Subject: [php-src] Issue #10899: Override properties in object after push in array
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243953@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10899 Author: maniaba ### Description The following code: ```php <?php $entity = new stdClass(); $entity->test = 1; $array[] = $entity; $entity->test = 2; $array[] = $entity; var_dump($array); ``` Resulted in this output: ``` array(2) { [0]=> object(stdClass)#1 (1) { ["test"]=> int(2) } [1]=> object(stdClass)#1 (1) { ["test"]=> int(2) } } ``` But I expected this output instead: ``` array(2) { [0]=> object(stdClass)#1 (1) { ["test"]=> int(1) } [1]=> object(stdClass)#1 (1) { ["test"]=> int(2) } } ``` ### PHP Version PHP 7.4.33 ### Operating System Ubuntu 22.04.2

« previous php.bugs (#243953) next »