1--TEST--
2GH-16185: Hooked object iterator with readonly props
3--FILE--
4<?php
5
6class C {
7    public readonly int $prop;
8    public $dummy { set {} }
9
10    public function init() {
11        $this->prop = 1;
12    }
13}
14
15$c = new C;
16
17// Okay, as foreach skips over uninitialized properties.
18foreach ($c as &$prop) {}
19
20$c->init();
21
22try {
23    foreach ($c as &$prop) {}
24} catch (Error $e) {
25    echo $e->getMessage(), "\n";
26}
27
28?>
29--EXPECTF--
30Cannot acquire reference to readonly property C::$prop
31