Edit report at https://bugs.php.net/bug.php?id=64264&edit=1

 ID:                 64264
 Patch added by:     larue...@php.net
 Reported by:        kwreczycki at gmail dot com
 Summary:            SPLFixedArray toArray problem
 Status:             Open
 Type:               Bug
 Package:            SPL related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2013-02-21 13:09:41] 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.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64264&edit=1

Reply via email to