xref: /PHP-8.0/ext/spl/tests/iterator_030.phpt (revision f8d79582)
1--TEST--
2SPL: EmptyIterator access
3--FILE--
4<?php
5
6$it = new EmptyIterator;
7
8var_dump($it->valid());
9$it->rewind();
10var_dump($it->valid());
11$it->next();
12var_dump($it->valid());
13
14try
15{
16    var_dump($it->key());
17}
18catch(BadMethodCallException $e)
19{
20    echo $e->getMessage() . "\n";
21}
22
23try
24{
25    var_dump($it->current());
26}
27catch(BadMethodCallException $e)
28{
29    echo $e->getMessage() . "\n";
30}
31
32var_dump($it->valid());
33
34?>
35--EXPECT--
36bool(false)
37bool(false)
38bool(false)
39Accessing the key of an EmptyIterator
40Accessing the value of an EmptyIterator
41bool(false)
42