Bug #79477 [NEW]: casting object into array creates references

From: Date: Tue, 14 Apr 2020 16:42:13 +0000
Subject: Bug #79477 [NEW]: casting object into array creates references
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226574@lists.php.net to get a copy of this message
From: david at grudl dot com Operating system: PHP version: 7.4.4 Package: Output Control Bug Type: Bug Bug description:casting object into array creates references 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 bug report at https://bugs.php.net/bug.php?id=79477&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79477&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79477&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79477&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79477&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79477&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79477&r=support Expected behavior: https://bugs.php.net/fix.php?id=79477&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79477&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79477&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79477&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79477&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79477&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79477&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79477&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79477&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79477&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79477&r=mysqlcfg

« previous php.bugs (#226574) next »