Bug #79477 [Opn->Ver]: casting object into array creates references

From: Date: Wed, 15 Apr 2020 07:53:00 +0000
Subject: Bug #79477 [Opn->Ver]: casting object into array creates references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226581@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79477&edit=1 ID: 79477 Updated by: nikic@php.net Reported by: david at grudl dot com Summary: casting object into array creates references -Status: Open +Status: Verified Type: Bug Package: Scripting Engine problem PHP Version: 7.4.4 Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2020-04-14 16:54:41] david at grudl dot com fixed package ------------------------------------------------------------------------ [2020-04-14 16:42:13] david at grudl dot com Description: ------------ See the code below. It should print 'default value', but when I'll create property $obj->{1}, it prints 'new value'. This affects PHP >= 7.2 https://3v4l.org/S5tJV and objects where property key is integer. Test script: --------------- <?php class Test { public $prop = 'default value'; } $obj = new Test; // $obj->{1} = null; $arr = (array) $obj; $arr['prop'] = 'new value'; echo $obj->prop; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79477&edit=1

« previous php.bugs (#226581) next »