1--TEST--
2foreach with iterator and &$value reference
3--FILE--
4<?php
5
6class MyIterator implements Iterator {
7    public function valid(): bool { return true; }
8    public function next(): void {}
9    public function rewind(): void {}
10    public function current(): mixed { return null; }
11    public function key(): mixed {return ""; }
12}
13
14$f = new MyIterator;
15echo "-----( Try to iterate with &\$value: )-----\n";
16foreach ($f as $k=>&$v) {
17    echo "$k => $v\n";
18}
19
20?>
21--EXPECTF--
22-----( Try to iterate with &$value: )-----
23
24Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:13
25Stack trace:
26#0 {main}
27  thrown in %s on line 13
28