From:             sala...@php.net
Operating system: OS X
PHP version:      5.3.0
PHP Bug Type:     SPL related
Bug description:  iterator_to_array nukes DirectoryIterator

Description:
------------
When converting a DirectoryIterator instance into an array using
iterator_to_array, the array items appear to be converted to basic
DirectoryIterator instances with none of the file information intact. The
same does not appear to occur for other related classes
(FilesystemIterator, RecursiveDirectoryIterator).

Reproduce code:
---------------
<?php

echo "DirectoryIterator:\n";
$dit = new DirectoryIterator(dirname(__FILE__));
$ait = iterator_to_array($dit);
foreach ($ait as $file) {
        var_dump($file->getFilename());
}

echo "RecursiveDirectoryIterator:\n";
$rdit = new RecursiveDirectoryIterator(dirname(__FILE__));
$ait = iterator_to_array($rdit);
foreach ($ait as $file) {
        var_dump($file->getFilename());
}

?>

Expected result:
----------------
DirectoryIterator:
string(1) "."
string(2) ".."
string(7) "bug.php"
RecursiveDirectoryIterator:
string(7) "bug.php"


Actual result:
--------------
DirectoryIterator:
string(0) ""
string(0) ""
string(0) ""
RecursiveDirectoryIterator:
string(7) "bug.php"


-- 
Edit bug report at http://bugs.php.net/?id=49755&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49755&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49755&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49755&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49755&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49755&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49755&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49755&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49755&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49755&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49755&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49755&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49755&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49755&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49755&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49755&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49755&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49755&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49755&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49755&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49755&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49755&r=mysqlcfg

Reply via email to