From:             maciej dot sz at gmail dot com
Operating system: irrelevant
PHP version:      5.4.7
Package:          SPL related
Bug Type:         Bug
Bug description:Wrong behaviour of setIteratorMode in SplStack,SplQueue and 
SplDoublyLinkedList

Description:
------------
The setIteratorMode method seems to cut everything above 3 (IT_MODE_LIFO |
IT_MODE_DELETE) to 0.

This is most unfortunate, because one can not define any user flags. For
example I can't do anything of sort:

<?php
class MyList extends SplDoublyLinkedList
{
    const IT_MODE_PLUS_ONE = 512;

    public function current()
    {
        $val = parent::current();
        if ( 0 != $this->getIteratorMode() & self::IT_MODE_PLUS_ONE ) {
            return $val + 1;
        }
        return $val;
    }
}


$List = new MyList();
$List->setIteratorMode( $List->getIteratorMode() | MyList::IT_MODE_PLUS_ONE
);
$List->push(5);
$List->push(6);

foreach ( $List as $value ) {
    echo "{$value}\n";
}
?>

Test script:
---------------
$Sl = new SplStack();

$Sl->setIteratorMode(3);
var_dump($Sl->getIteratorMode());

$Sl->setIteratorMode(4);
var_dump($Sl->getIteratorMode());

Expected result:
----------------
setIteratorMode should accept any provided integer

Actual result:
--------------
the mode is stripped down to 0 if provided integer is greater then 3

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63175&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63175&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63175&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63175&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63175&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63175&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63175&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63175&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63175&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63175&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63175&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63175&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63175&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63175&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63175&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63175&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63175&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63175&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63175&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63175&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63175&r=mysqlcfg

Reply via email to