#28217 [Opn->Fbk]: casting RecursiveDirectoryIterator is bogus

From: Date: Thu, 29 Apr 2004 21:08:20 +0000
Subject: #28217 [Opn->Fbk]: casting RecursiveDirectoryIterator is bogus
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-59030@lists.php.net to get a copy of this message
ID: 28217 Updated by: helly@php.net Reported By: nlopess@php.net -Status: Open +Status: Feedback Bug Type: Zend Engine 2 problem Operating System: n/a PHP Version: 5CVS-2004-04-29 (dev) New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2004-04-29 16:57:11] nlopess@php.net Description: ------------ Just the check the following line in the reproduce code: if($it->isDir() && !$it->isDot() && $it->current() != 'CVS') { if you don't cast $it->current to a string it will output an error, so I need to write: if($it->isDir() && !$it->isDot() && (string) $it->current() != 'CVS') { This should really cast it to a string automatically. Reproduce code: --------------- <?php function recurse($it) { for( ; $it->valid(); $it->next()) { if($it->isDir() && !$it->isDot() && $it->current() != 'CVS') { echo $it->current() . "\n"; if($it->hasChildren()) { recurse($it->getChildren()); } } elseif($it->isFile() && $it->current() != '.cvsignore') { if(!php_check_syntax($it->current())) { echo $it->current(); } } } } recurse(new RecursiveDirectoryIterator('phpdoc/en')); ?> Actual result: -------------- Notice: Object of class RecursiveDirectoryIterator could not be converted to int eger in c:\cvs\recurse.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28217&edit=1

« previous php.bugs (#59030) next »