1--TEST--
2SPL: FixedArray: overriding getIterator()
3--FILE--
4<?php
5class A extends SplFixedArray
6{
7  public function getIterator(): Iterator
8  {
9    $iterator = parent::getIterator();
10    while ($iterator->valid()) {
11      echo "In A: key={$iterator->key()} value={$iterator->current()}\n";
12      yield $iterator->key() => $iterator->current();
13      $iterator->next();
14    }
15  }
16}
17
18echo "==SplFixedArray instance==\n";
19$a = new SplFixedArray(3);
20$a[0] = "a";
21$a[1] = "b";
22$a[2] = "c";
23foreach ($a as $k => $v) {
24  echo "$k => $v\n";
25}
26
27echo "==Subclass instance==\n";
28$a = new A(3);
29$a[0] = "d";
30$a[1] = "e";
31$a[2] = "f";
32foreach ($a as $k => $v) {
33  echo "$k => $v\n";
34}
35--EXPECT--
36==SplFixedArray instance==
370 => a
381 => b
392 => c
40==Subclass instance==
41In A: key=0 value=d
420 => d
43In A: key=1 value=e
441 => e
45In A: key=2 value=f
462 => f
47