|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63175 Wrong behaviour of setIteratorMode in SplStack,SplQueue and SplDoublyLinkedList
Submitted: 2012-09-27 16:49 UTC Modified: 2012-09-28 03:05 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: maciej dot sz at gmail dot com Assigned:
Status: Open Package: SPL related
PHP Version: 5.4.7 OS: irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: maciej dot sz at gmail dot com
New email:
PHP Version: OS:


 [2012-09-27 16:49 UTC] maciej dot sz at gmail dot com
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:

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 );

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

Test script:
$Sl = new SplStack();



Expected result:
setIteratorMode should accept any provided integer

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-28 03:05 UTC]
that is by design now, so, not a bug, change to FR instead
 [2012-09-28 03:05 UTC]
-Type: Bug +Type: Feature/Change Request
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 15:01:32 2024 UTC