xref: /PHP-7.1/Zend/tests/bug49269.phpt (revision f694c09a)
1--TEST--
2Bug #49269 (Ternary operator fails on Iterator object when used inside foreach declaration).
3--FILE--
4<?php
5class TestObject implements Iterator
6{
7    public $n = 0;
8    function valid()
9    {
10        return ($this->n < 3);
11    }
12    function current() {return $this->n;}
13    function next() {$this->n++;}
14    function key() { }
15    function rewind() {$this->n = 0;}
16}
17
18
19$array_object = new TestObject();
20
21foreach ((true ? $array_object : $array_object) as $item) echo "$item\n";
22?>
23--EXPECT--
240
251
262
27