Bug #73686 [NEW]: Adding settype()ed values to ArrayObject results in references.
From: arjen at parse dot nl
Operating system: All
PHP version: 7.1.0
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Adding settype()ed values to ArrayObject results in references.
Description:
------------
Found at https://twitter.com/kozzi11/status/806828728890380288
https://3v4l.org/suHQh
Removing the settype() call produces the expected output.
Test script:
---------------
<?php
$ao = new ArrayObject;
foreach ([1, 2, 3] as $i => $var)
{
settype($var, 'string');
$ao[$i] = $var;
}
var_dump($ao);
Expected result:
----------------
Output for 5.6.0 - 5.6.28, hhvm-3.12.0 - 3.13.2, 7.0.0 - 7.0.14
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
}
}
Actual result:
--------------
Output for 7.1.0
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(3) {
[0]=>
&string(1) "3"
[1]=>
&string(1) "3"
[2]=>
&string(1) "3"
}
}
--
Edit bug report at https://bugs.php.net/bug.php?id=73686&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73686&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73686&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73686&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73686&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73686&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73686&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73686&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73686&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73686&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73686&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73686&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73686&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73686&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73686&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73686&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73686&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73686&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73686&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73686&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73686&r=mysqlcfg
Thread (3 messages)
- arjen at parse dot nl