|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-01-29 20:41 UTC] adam at trachtenberg dot com
[2004-01-30 01:49 UTC] helly@php.net
[2004-04-08 17:41 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Feb 08 13:00:01 2026 UTC |
Description: ------------ You cannot access, $it, the iterator passed into FilterIterator in a child class. Reproduce code: --------------- class DirectoryFilterDots extends FilterIterator implements RecursiveIterator { function __construct($path) { parent::__construct(new DirectoryIterator($path)); } function accept() { return !$this->it->isDot(); } function hasChildren() { return $this->it->hasChildren(); } function getChildren() { return new DirectoryFilterDots($this->it->getPathname()); } function key() { return $this->it->getPathname(); } } $dir = new RecursiveIteratorIterator(new DirectoryFilterDots( new RecursiveDirectoryIterator($argv[1])), true); foreach ($dir as $file) { print $file. "\n"; } Expected result: ---------------- Class filters out dot files. Actual result: -------------- PHP Notice: Undefined property: DirectoryFilterDots::$it in /Users/adam/Documents/php/ php5/dir.php on line 42 PHP Fatal error: Call to a member function isDot() on a non-object in /Users/adam/Documents/php/php5/dir.php on line 42 /usr/local/cvs/php/php-src/main/streams/streams.c(371) : Stream of type 'dir' 0xad6f28 (path:(null)) was not closed /usr/local/cvs/php/php-src/main/streams/streams.c(371) : Stream of type 'dir' 0xad65a0 (path:(null)) was not closed