From: Operating system: PHP version: 5.3.6 Package: SPL related Bug Type: Bug Bug description:SplFixedArray.setSize ambiguous treatment of existing values
Description: ------------ --- >From manual page: http://www.php.net/splfixedarray.setsize --- When resizing an SplFixedArray using the setSize method, values from the deleted indexes behave strangely. Test script: --------------- The following piece of code: <?php $fa = new SplFixedArray(2); $fa[0] = 'Hello'; $fa[1] = 'World'; $fa->setSize(3); var_dump($fa); $fa[2] = '!'; $fa->setSize(1); var_dump($fa); ?> Outputs: object(SplFixedArray)#1 (3) { [0]=> string(5) "Hello" [1]=> string(5) "World" [2]=> NULL } object(SplFixedArray)#1 (3) { [0]=> string(5) "Hello" [1]=> string(5) "World" [2]=> NULL } While the following piece of code: <?php $fa = new SplFixedArray(2); $fa[0] = 'Hello'; $fa[1] = 'World'; $fa->setSize(3); $fa[2] = '!'; var_dump($fa); $fa->setSize(1); var_dump($fa); ?> Outputs this: object(SplFixedArray)#1 (3) { [0]=> string(5) "Hello" [1]=> string(5) "World" [2]=> string(1) "!" } object(SplFixedArray)#1 (3) { [0]=> string(5) "Hello" [1]=> string(5) "World" [2]=> string(1) "!" } Expected result: ---------------- I would expect to see the same in either of the above presented cases, and it should be an array with the new size that was specified using setSize: object(SplFixedArray)#1 (1) { [0]=> string(5) "Hello" } -- Edit bug report at http://bugs.php.net/bug.php?id=54970&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54970&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54970&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54970&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=54970&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54970&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=54970&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=54970&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=54970&r=needscript Try newer version: http://bugs.php.net/fix.php?id=54970&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=54970&r=support Expected behavior: http://bugs.php.net/fix.php?id=54970&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=54970&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=54970&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=54970&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54970&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=54970&r=dst IIS Stability: http://bugs.php.net/fix.php?id=54970&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=54970&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=54970&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=54970&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=54970&r=mysqlcfg
