xref: /PHP-8.2/ext/spl/tests/iterator_056.phpt (revision b3e08881)
1--TEST--
2SPL: Calling __construct(void) on class extending SPL iterator
3--CREDITS--
4Sebastian Schürmann
5--FILE--
6<?php
7
8class myFilterIterator extends FilterIterator {
9    function accept(): bool { }
10}
11
12class myCachingIterator extends CachingIterator { }
13
14class myRecursiveCachingIterator extends RecursiveCachingIterator { }
15
16class myParentIterator extends ParentIterator { }
17
18class myLimitIterator extends LimitIterator { }
19
20class myNoRewindIterator extends NoRewindIterator  {}
21
22try {
23    $it = new myFilterIterator();
24} catch (TypeError $e) {
25    echo $e->getMessage(), "\n";
26}
27
28try {
29    $it = new myCachingIterator();
30} catch (TypeError $e) {
31    echo $e->getMessage(), "\n";
32}
33
34try {
35    $it = new myRecursiveCachingIterator();
36} catch (TypeError $e) {
37    echo $e->getMessage(), "\n";
38}
39
40try {
41    $it = new myParentIterator();
42} catch (TypeError $e) {
43    echo $e->getMessage(), "\n";
44}
45
46try {
47    $it = new myLimitIterator();
48} catch (TypeError $e) {
49    echo $e->getMessage(), "\n";
50}
51try {
52    $it = new myNoRewindIterator();
53} catch (TypeError $e) {
54    echo $e->getMessage(), "\n";
55}
56
57?>
58--EXPECT--
59FilterIterator::__construct() expects exactly 1 argument, 0 given
60CachingIterator::__construct() expects at least 1 argument, 0 given
61RecursiveCachingIterator::__construct() expects at least 1 argument, 0 given
62ParentIterator::__construct() expects exactly 1 argument, 0 given
63LimitIterator::__construct() expects at least 1 argument, 0 given
64NoRewindIterator::__construct() expects exactly 1 argument, 0 given
65