php.net |  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
Votes:1
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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
40 + 47 = ?
Subscribe to this entry?

 
 [2012-09-27 16:49 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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