|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79477 casting object into array creates references
Submitted: 2020-04-14 16:42 UTC Modified: 2020-04-15 07:52 UTC
From: david at grudl dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.4.4 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: david at grudl dot com
New email:
PHP Version: OS:


 [2020-04-14 16:42 UTC] david at grudl dot com
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 and objects where property key is integer.

Test script:

class Test
	public $prop = 'default value';

$obj = new Test;
// $obj->{1} = null;

$arr = (array) $obj;
$arr['prop'] = 'new value';

echo $obj->prop;  


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-14 16:54 UTC] david at grudl dot com
-Package: Output Control +Package: Scripting Engine problem
 [2020-04-14 16:54 UTC] david at grudl dot com
fixed package
 [2020-04-15 07:52 UTC]
-Status: Open +Status: Verified
 [2020-04-15 09:22 UTC]
Automatic comment on behalf of
Log: Fixed bug #79477
 [2020-04-15 09:22 UTC]
-Status: Verified +Status: Closed
 [2020-04-15 16:53 UTC] david at grudl dot com
Wow, it was fast, thanks :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 10:01:29 2024 UTC