xref: /PHP-5.4/ext/spl/tests/fixedarray_003.phpt (revision 0f5ddaf4)
1--TEST--
2SPL: FixedArray: Iterators
3--FILE--
4<?php
5class A extends SplFixedArray {
6
7    public function current() {
8        echo "A::current\n";
9        return parent::current();
10    }
11    public function key() {
12        echo "A::key\n";
13        return parent::key();
14    }
15    public function rewind() {
16        echo "A::rewind\n";
17        return parent::rewind();
18    }
19    public function valid() {
20        echo "A::valid\n";
21        return parent::valid();
22    }
23    public function next() {
24        echo "A::next\n";
25        return parent::next();
26    }
27}
28
29echo "==Direct instance==\n";
30$a = new SplFixedArray(5);
31$a[0] = "a";
32$a[1] = "c";
33$a[2] = "d";
34$a[3] = "e";
35$a[4] = "f";
36foreach ($a as $k => $v) {
37    echo "$k => $v\n";
38}
39echo "==Child instance==\n";
40$a = new A(5);
41$a[0] = "a";
42$a[1] = "c";
43$a[2] = "d";
44$a[3] = "e";
45$a[4] = "f";
46foreach ($a as $k => $v) {
47    echo "$k => $v\n";
48}
49?>
50===DONE===
51--EXPECTF--
52==Direct instance==
530 => a
541 => c
552 => d
563 => e
574 => f
58==Child instance==
59A::rewind
60A::valid
61A::current
62A::key
630 => a
64A::next
65A::valid
66A::current
67A::key
681 => c
69A::next
70A::valid
71A::current
72A::key
732 => d
74A::next
75A::valid
76A::current
77A::key
783 => e
79A::next
80A::valid
81A::current
82A::key
834 => f
84A::next
85A::valid
86===DONE===
87