Edit report at https://bugs.php.net/bug.php?id=63175&edit=1
ID: 63175 Updated by: larue...@php.net Reported by: maciej dot sz at gmail dot com Summary: Wrong behaviour of setIteratorMode in SplStack,SplQueue and SplDoublyLinkedList Status: Open -Type: Bug +Type: Feature/Change Request Package: SPL related Operating System: irrelevant PHP Version: 5.4.7 Block user comment: N Private report: N New Comment: that is by design now, so, not a bug, change to FR instead Previous Comments: ------------------------------------------------------------------------ [2012-09-27 16:49:01] maciej dot sz at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=63175&edit=1