|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-04-13 12:29 UTC] pornel at despammed dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 11:00:02 2025 UTC |
Description: ------------ I'm using RecursiveDirectoryIterator to scan directories. File objects returned by this iterator seem to threat isDir and hasChildren as the same thing. That is isDir returns true only when item has children. This assumption is invalid and causes empty directories to be reported as files. Reproduce code: --------------- <?php function scan(RecursiveDirectoryIterator $dir) { foreach($dir as $file) { var_dump($file->isDir()); if ($dir->hasChildren()) scan($dir->getChildren()); } } scan(new RecursiveDirectoryIterator('/some/path/that/has/empty/dirs')); Expected result: ---------------- isDir should not act as alias of hasChildren Actual result: -------------- empty directories have isFile()==true and isDir()==false