xref: /PHP-7.1/ext/spl/tests/fixedarray_003.phpt (revision 28e0a580)
1--TEST--
2SPL: FixedArray: Iterators
3--FILE--
4<?php
5class A extends SplFixedArray {
6	public $prop1 = "dummy";
7	public $prop2 = "dummy";
8
9    public function current() {
10        echo "A::current\n";
11        return parent::current();
12    }
13    public function key() {
14        echo "A::key\n";
15        return parent::key();
16    }
17    public function rewind() {
18        echo "A::rewind\n";
19        return parent::rewind();
20    }
21    public function valid() {
22        echo "A::valid\n";
23        return parent::valid();
24    }
25    public function next() {
26        echo "A::next\n";
27        return parent::next();
28    }
29}
30
31echo "==Direct instance==\n";
32$a = new SplFixedArray(5);
33$a[0] = "a";
34$a[1] = "c";
35$a[2] = "d";
36$a[3] = "e";
37$a[4] = "f";
38foreach ($a as $k => $v) {
39    echo "$k => $v\n";
40}
41echo "==Child instance==\n";
42$a = new A(5);
43$a[0] = "a";
44$a[1] = "c";
45$a[2] = "d";
46$a[3] = "e";
47$a[4] = "f";
48foreach ($a as $k => $v) {
49    echo "$k => $v\n";
50}
51?>
52===DONE===
53--EXPECTF--
54==Direct instance==
550 => a
561 => c
572 => d
583 => e
594 => f
60==Child instance==
61A::rewind
62A::valid
63A::current
64A::key
650 => a
66A::next
67A::valid
68A::current
69A::key
701 => c
71A::next
72A::valid
73A::current
74A::key
752 => d
76A::next
77A::valid
78A::current
79A::key
803 => e
81A::next
82A::valid
83A::current
84A::key
854 => f
86A::next
87A::valid
88===DONE===
89