xref: /PHP-8.1/Zend/tests/bug26229.phpt (revision 75a678a7)
1--TEST--
2Bug #26229 (getIterator() segfaults when it returns arrays or scalars)
3--FILE--
4<?php
5
6class array_iterator implements IteratorAggregate {
7        #[ReturnTypeWillChange]
8        public function getIterator() {
9                return array('foo', 'bar');
10        }
11}
12
13$obj = new array_iterator;
14
15try
16{
17    foreach ($obj as $property => $value)
18    {
19        var_dump($value);
20    }
21}
22catch(Exception $e)
23{
24    echo $e->getMessage() . "\n";
25}
26?>
27--EXPECT--
28Objects returned by array_iterator::getIterator() must be traversable or implement interface Iterator
29