php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david at grudl dot com
New email:
PHP Version: OS:

 

 [2020-04-14 16:42 UTC] 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;  


Patches

Pull Requests

History

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] nikic@php.net
-Status: Open +Status: Verified
 [2020-04-15 09:22 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=79a36ff7f33194cf08ebe511bd828e1cdaea8e41
Log: Fixed bug #79477
 [2020-04-15 09:22 UTC] nikic@php.net
-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: Sun Oct 27 16:01:27 2024 UTC