1--TEST--
2ReflectionClass::isIterateable()
3--CREDITS--
4Robin Fernandes <robinf@php.net>
5Steve Seear <stevseea@php.net>
6--FILE--
7<?php
8Interface ExtendsIterator extends Iterator {
9}
10Interface ExtendsIteratorAggregate extends IteratorAggregate {
11}
12Class IteratorImpl implements Iterator {
13    public function next(): void {}
14    public function key(): mixed {}
15    public function rewind(): void {}
16    public function current(): mixed {}
17    public function valid(): bool {}
18}
19Class IteratorAggregateImpl implements IteratorAggregate {
20    public function getIterator(): Traversable {}
21}
22Class ExtendsIteratorImpl extends IteratorImpl {
23}
24Class ExtendsIteratorAggregateImpl extends IteratorAggregateImpl {
25}
26Class A {
27}
28
29$classes = array('Traversable', 'Iterator', 'IteratorAggregate', 'ExtendsIterator', 'ExtendsIteratorAggregate',
30      'IteratorImpl', 'IteratorAggregateImpl', 'ExtendsIteratorImpl', 'ExtendsIteratorAggregateImpl', 'A');
31
32foreach($classes as $class) {
33    $rc = new ReflectionClass($class);
34    echo "Is $class iterable? ";
35    var_dump($rc->isIterateable());
36}
37
38echo "\nTest static invocation:\n";
39ReflectionClass::isIterateable();
40
41?>
42--EXPECTF--
43Is Traversable iterable? bool(false)
44Is Iterator iterable? bool(false)
45Is IteratorAggregate iterable? bool(false)
46Is ExtendsIterator iterable? bool(false)
47Is ExtendsIteratorAggregate iterable? bool(false)
48Is IteratorImpl iterable? bool(true)
49Is IteratorAggregateImpl iterable? bool(true)
50Is ExtendsIteratorImpl iterable? bool(true)
51Is ExtendsIteratorAggregateImpl iterable? bool(true)
52Is A iterable? bool(false)
53
54Test static invocation:
55
56Fatal error: Uncaught Error: Non-static method ReflectionClass::isIterateable() cannot be called statically in %s:%d
57Stack trace:
58#0 {main}
59  thrown in %s on line %d
60