php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64264 SPLFixedArray toArray problem
Submitted: 2013-02-21 13:09 UTC Modified: 2013-02-24 10:36 UTC
From: kwreczycki at gmail dot com Assigned: laruence (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2013-02-21 13:09 UTC] kwreczycki at gmail dot com
Description:
------------
Be aware if You extends SplFixedArray and use toArray method.
                                                                                                                                                    

Test script:
---------------
class MyFixedArray extends \SplFixedArray {                                                                                                                                 
    protected $foo;                                                                                                                                                         
    protected $bar;                                                                                                                                                         
}                                                                                                                                                                           
                                                                                                                                                                            
$myFixedArr = new MyFixedArray(1);                                                                                                                                          
$myFixedArray[] = 'foo';



Expected result:
----------------
array(1) {
  [0]=>
  NULL
}


Actual result:
--------------
array(3) {
  ["*foo"]=>
  NULL
  ["*bar"]=>
  NULL
  [0]=>
  NULL
}


*foo and *bar keys, can invoke troubles in some situations if You expects array 
without properties from inherited class. Method toArray should return values only 
for elements which are added to collection without properties inherited from 
class.

Patches

bug64264.phpt (last revision 2013-02-23 12:08 UTC by laruence@php.net)
bug64264.patch (last revision 2013-02-23 12:08 UTC by laruence@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-23 12:08 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug64264.patch
Revision:   1361621303
URL:        https://bugs.php.net/patch-display.php?bug=64264&patch=bug64264.patch&revision=1361621303
 [2013-02-23 12:08 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug64264.phpt
Revision:   1361621333
URL:        https://bugs.php.net/patch-display.php?bug=64264&patch=bug64264.phpt&revision=1361621333
 [2013-02-24 04:56 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2013-02-24 04:56 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1b58bd39a637e9ec4ea9e95903b74aefdbd1b596
Log: Fixed bug #64264 (SPLFixedArray toArray problem)
 [2013-02-24 04:58 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1b58bd39a637e9ec4ea9e95903b74aefdbd1b596
Log: Fixed bug #64264 (SPLFixedArray toArray problem)
 [2013-02-24 04:59 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1b58bd39a637e9ec4ea9e95903b74aefdbd1b596
Log: Fixed bug #64264 (SPLFixedArray toArray problem)
 [2013-02-24 05:00 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1b58bd39a637e9ec4ea9e95903b74aefdbd1b596
Log: Fixed bug #64264 (SPLFixedArray toArray problem)
 [2013-02-24 05:01 UTC] laruence@php.net
-Status: Closed +Status: Open
 [2013-02-24 05:01 UTC] laruence@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2013-02-24 05:03 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2013-02-24 10:36 UTC] kwreczycki at gmail dot com
Great, thanks for Your work.
 [2013-03-01 18:32 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1b58bd39a637e9ec4ea9e95903b74aefdbd1b596
Log: Fixed bug #64264 (SPLFixedArray toArray problem)
 [2014-10-07 23:20 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=1b58bd39a637e9ec4ea9e95903b74aefdbd1b596
Log: Fixed bug #64264 (SPLFixedArray toArray problem)
 [2014-10-07 23:31 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=1b58bd39a637e9ec4ea9e95903b74aefdbd1b596
Log: Fixed bug #64264 (SPLFixedArray toArray problem)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC