From:             adam at trachtenberg dot com
Operating system: *
PHP version:      5CVS-2004-01-29 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  SPL: Can't access FilterIterator $it property

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

-- 
Edit bug report at http://bugs.php.net/?id=27092&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27092&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27092&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27092&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27092&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27092&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27092&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27092&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27092&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27092&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27092&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27092&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27092&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27092&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27092&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27092&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27092&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27092&r=float

Reply via email to