xref: /PHP-7.2/ext/spl/tests/array_020.phpt (revision 610c7fbe)
1--TEST--
2SPL: ArrayIterator overloading
3--FILE--
4<?php
5
6class ArrayIteratorEx extends ArrayIterator
7{
8	function rewind()
9	{
10		echo __METHOD__ . "\n";
11		ArrayIterator::rewind();
12	}
13
14	function valid()
15	{
16		echo __METHOD__ . "\n";
17		return ArrayIterator::valid();
18	}
19
20	function key()
21	{
22		echo __METHOD__ . "\n";
23		return ArrayIterator::key();
24	}
25
26	function current()
27	{
28		echo __METHOD__ . "\n";
29		return ArrayIterator::current();
30	}
31
32	function next()
33	{
34		echo __METHOD__ . "\n";
35		return ArrayIterator::next();
36	}
37}
38
39$ar = new ArrayIteratorEx(array(1,2));
40foreach($ar as $k => $v)
41{
42	var_dump($k);
43	var_dump($v);
44}
45
46?>
47===DONE===
48<?php exit(0); ?>
49--EXPECTF--
50ArrayIteratorEx::rewind
51ArrayIteratorEx::valid
52ArrayIteratorEx::current
53ArrayIteratorEx::key
54int(0)
55int(1)
56ArrayIteratorEx::next
57ArrayIteratorEx::valid
58ArrayIteratorEx::current
59ArrayIteratorEx::key
60int(1)
61int(2)
62ArrayIteratorEx::next
63ArrayIteratorEx::valid
64===DONE===
65