PHP :: Bug #54970 :: SplFixedArray::setSize() isn't resizing
| Bug #54970 | SplFixedArray::setSize() isn't resizing | ||||
|---|---|---|---|---|---|
| Submitted: | 2011-06-01 15:25 UTC | Modified: | 2011-06-02 02:40 UTC | ||
| From: | marco dot paulo dot lopes at gmail dot com | Assigned: | felipe (profile) | ||
| Status: | Closed | Package: | SPL related | ||
| PHP Version: | 5.3.6 | OS: | |||
| Private report: | No | CVE-ID: | None | ||
[2011-06-01 15:25 UTC] marco dot paulo dot lopes at gmail dot com
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" }
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2011-06-02 02:40 UTC] felipe@php.net
-Summary: SplFixedArray.setSize ambiguous treatment of existing values +Summary: SplFixedArray::setSize() isn't resizing
[2011-06-02 02:40 UTC] felipe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: felipe
[2011-06-02 02:40 UTC] felipe@php.net