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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
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

Pull Requests

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: Thu Nov 21 18:01:29 2024 UTC