ID: 41975 User updated by: kevin at oceania dot net Reported By: kevin at oceania dot net Status: Bogus Bug Type: SPL related Operating System: linux PHP Version: 5CVS-2007-07-12 (snap) New Comment:
Ok, I took the code from your vancouver 200702 spl update slide. Thanks Kevin Previous Comments: ------------------------------------------------------------------------ [2007-07-12 09:11:21] [EMAIL PROTECTED] 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 RecursiveDirectoryIterator doesn't know about recursive iteration process so it does not have a const SELF_FIRST. That is the domain of RecursiveIteratorIterator. So you have to d: new RII(new RCI(new RDI(...))) there is: spl/examples/recursivetreeiterator.inc which generalizes the handling of the tree graphics. But it works a bit different. IT is an extended RecursiveIteratorIterator, so infact it does know what to do with const SELF_FIRST. And it also handles the caching automatically. Maybe we should put that into the extension finally. ------------------------------------------------------------------------ [2007-07-12 07:04:06] kevin at oceania dot net Description: ------------ When calling parent::SELF_FIRST with recursiveDirectoryIterator fatal error Reproduce code: --------------- <?php class DirectoryTreeIterator extends RecursiveDirectoryIterator{ public function __construct($path) { parent::__construct(new RecursiveCachingIterator( new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME), CachingIterator::CALL_TOSTRING), parent::SELF_FIRST); } public function current() { $cur = ""; for( $i = 0; $i < $this->getDepth(); $i++) { $cur .= $this->getSubIterator($i)->hasNext() ? " | " : " "; } $i = $this->SubIterator($i); return $cur . ($i->hasNext() ? " | - " : "/ - ").(string)$i; } } /*** end of class ***/ $obj = new DirectoryTreeIterator('albums'); Expected result: ---------------- directory list Actual result: -------------- Fatal error: Undefined class constant 'SELF_FIRST' in /www/web/test.php on line 9 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41975&edit=1