php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36064 RecursiveDirectoryIterator::hasChildren 's problem
Submitted: 2006-01-18 07:11 UTC Modified: 2006-01-18 10:01 UTC
From: sqchen at citiz dot net Assigned: helly (profile)
Status: Not a bug Package: SPL related
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sqchen at citiz dot net
New email:
PHP Version: OS:

 

 [2006-01-18 07:11 UTC] sqchen at citiz dot net
Description:
------------
php manual says RecursiveDirectoryIterator::hasChildren()

Returns whether current entry is a directory and not '.' or '..' () 




Reproduce code:
---------------
<?php
$obj = new RecursiveDirectoryIterator("bbb");
$obj->rewind();
for($i=0;$i<5;$i++){
var_dump($obj->key());
var_dump($obj->hasChildren());
$obj->next();
}
?>


   directory bbb included:
1.txt   ccc    p.txt      //ccc is a directory

Expected result:
----------------
string(9) "bbb/1.txt"
bool(false)
string(7) "bbb/ccc"
bool(true)
string(9) "bbb/p.txt"
bool(false)
string(4) "bbb/"
bool(false)
string(4) "bbb/"
bool(false)


Actual result:
--------------
string(9) "bbb/1.txt"
bool(false)
string(7) "bbb/ccc"
bool(true)
string(9) "bbb/p.txt"
bool(false)
string(4) "bbb/"
bool(true)
string(4) "bbb/"
bool(true)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-18 09:43 UTC] sniper@php.net
Assigned to the maintainer.
 [2006-01-18 10:01 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You don't check valid(). In general no iterator method must be used when valid() returns false.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC