xref: /PHP-7.4/ext/spl/tests/array_012.phpt (revision 610c7fbe)
1--TEST--
2SPL: ArrayIterator::count
3--FILE--
4<?php
5
6echo "===Array===\n";
7
8$a = array('zero' => 0, 'one' => 1, 'two' => 2);
9$it = new ArrayIterator($a);
10
11var_dump($it->count());
12foreach($it as $key => $val)
13{
14	echo "$key=>$val\n";
15	var_dump($it->count());
16}
17var_dump($it->count());
18
19echo "===Object===\n";
20
21class test
22{
23	public $zero = 0;
24	protected $pro;
25	public $one = 1;
26	private $pri;
27	public $two = 2;
28}
29
30$o = new test;
31$it = new ArrayIterator($o);
32
33var_dump($it->count());
34foreach($it as $key => $val)
35{
36	echo "$key=>$val\n";
37	var_dump($it->count());
38}
39var_dump($it->count());
40
41?>
42===DONE===
43<?php exit(0); ?>
44--EXPECT--
45===Array===
46int(3)
47zero=>0
48int(3)
49one=>1
50int(3)
51two=>2
52int(3)
53int(3)
54===Object===
55int(3)
56zero=>0
57int(3)
58one=>1
59int(3)
60two=>2
61int(3)
62int(3)
63===DONE===
64