xref: /PHP-8.3/ext/spl/tests/iterator_036.phpt (revision f8d79582)
1--TEST--
2SPL: CachingIterator and __toString and flags = 0
3--FILE--
4<?php
5
6function test($it)
7{
8    foreach($it as $v)
9    {
10        var_dump((string)$it);
11    }
12}
13
14$ar = new ArrayIterator(array(1, 2, 3));
15
16test(new CachingIterator($ar, 0));
17
18?>
19===DONE===
20--EXPECTF--
21Fatal error: Uncaught BadMethodCallException: CachingIterator does not fetch string value (see CachingIterator::__construct) in %s:%d
22Stack trace:
23#0 %s(%d): CachingIterator->__toString()
24#1 %s(%d): test(Object(CachingIterator))
25#2 {main}
26  thrown in %s on line %d
27