Bug #79477 [Com]: casting object into array creates references
| From: | david at grudl dot com | Date: | Wed, 15 Apr 2020 16:53:20 +0000 |
| Subject: | Bug #79477 [Com]: casting object into array creates references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226594@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
Comment by: david at grudl dot com
Reported by: david at grudl dot com
Summary: casting object into array creates references
Status: Closed
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.4.4
Block user comment: N
Private report: N
New Comment:
Wow, it was fast, thanks :)
Previous Comments:
------------------------------------------------------------------------
[2020-04-15 09:22:31] 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-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