From:             gma625 at msn dot com
Operating system: windows xp2
PHP version:      5.2.9
PHP Bug Type:     SPL related
Bug description:  function valid , next, current ..from subclass of 
FilterIterator return false

Description:
------------
When extends a class with FilterIterator, the valid ,current,key, next
functions can't work, until you override your function with the following
codes
public function valid() {
     $this->getInnerIterator()->valid();  
}

btw, my php works version is 5.2.6, I can't found this version in the
select list , so I selected 5.2.9

Reproduce code:
---------------
error_reporting ( E_ALL | E_STRICT );
$array = array ('koala', 'kangaroo', 'wombat', 'wallaby', 'emu', 'NZ' =>
'kiwi', 'kookaburra', 'platypus' );

class CullingIterator extends FilterIterator {
        
        public function __construct(Iterator $it) {
                parent::__construct ( $it );
        }
        
        function accept() {
                $ittmp = $this->getInnerIterator ();
                if ($ittmp->current () == 'koala') {
                        return false;
                }
                return true;
        }
}

$cull = new CullingIterator ( new ArrayIterator ( $array ) );

try {
        while ( $cull->valid () ) {
                echo $cull->current ();
                $cull->next ();
        }
} catch ( Exception $e ) {
        $e->getTraceAsString ();
}

Expected result:
----------------
print out the array result as following
kangaroowombatwallabyemukiwikookaburraplatypus


Actual result:
--------------
print nothing, becuase when we call $cull->valid() will return false

additional information , I've also tracked this problem by the following
code, 

$cull = new CullingIterator ( new ArrayIterator ( $array ) );

$it = $cull->getInnerIterator();

var_dump( $it->valid() );

and the result is bool(true), it's very strange to get this while we
$cull->valid() it return false(true)

-- 
Edit bug report at http://bugs.php.net/?id=48272&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48272&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48272&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48272&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48272&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48272&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48272&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48272&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48272&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48272&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48272&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48272&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48272&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48272&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48272&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48272&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48272&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48272&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48272&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48272&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48272&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48272&r=mysqlcfg

Reply via email to