Bug #79477 [Opn]: casting object into array creates references
| From: | david at grudl dot com | Date: | Tue, 14 Apr 2020 16:54:41 +0000 |
| Subject: | Bug #79477 [Opn]: casting object into array creates references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226575@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
User updated by: david at grudl dot com
Reported by: david at grudl dot com
Summary: casting object into array creates references
Status: Open
Type: Bug
-Package: Output Control
+Package: Scripting Engine problem
PHP Version: 7.4.4
Block user comment: N
Private report: N
New Comment:
fixed package
Previous Comments:
------------------------------------------------------------------------
[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