Bug #75173 [Ver->Asn]: incorrect behavior of AppendIterator::append in foreach loop

From: Date: Sun, 10 Sep 2017 18:11:08 +0000
Subject: Bug #75173 [Ver->Asn]: incorrect behavior of AppendIterator::append in foreach loop
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211033@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75173&edit=1

 ID:                 75173
 Updated by:         jhdxr@php.net
 Reported by:        gharlan at web dot de
-Summary:            AppendIterator: Changes within foreach ignored
+Summary:            incorrect behavior of AppendIterator::append in
                     foreach loop
-Status:             Verified
+Status:             Assigned
 Type:               Bug
 Package:            SPL related
-PHP Version:        7.1.9
+PHP Version:        7.0.23
 Assigned To:        jhdxr
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2017-09-08 10:30:03] gharlan at web dot de

Description:
------------
https://3v4l.org/itLi1

I guess the change was introduced by https://github.com/php/php-src/pull/2499

Test script:
---------------
<?php

$it = new \AppendIterator();
$it->append(new ArrayIterator(['foo']));

foreach ($it as $item) {
    echo $item;
    
    if ('foo' === $item) {
        $it->append(new ArrayIterator(['bar']));
    }
}

Expected result:
----------------
foobar

Actual result:
--------------
foo


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75173&edit=1


Thread (4 messages)

« previous php.bugs (#211033) next »