1--TEST--
2GH-15187: Hooked iterator typed property ref tracking
3--FILE--
4<?php
5
6class C {
7    public $a { set {} }
8    public int $b;
9    public int $c = 1;
10    public $d = 2;
11}
12
13$c = new C();
14
15foreach ($c as $k => &$v) {
16    var_dump($v);
17    if ($k === 'c') {
18        try {
19            $v = 'foo';
20        } catch (Error $e) {
21            echo $e->getMessage(), "\n";
22        }
23    }
24    if ($k === 'd') {
25        $v = 'foo';
26    }
27}
28
29var_dump($c);
30
31?>
32--EXPECTF--
33int(1)
34Cannot assign string to reference held by property C::$c of type int
35int(2)
36object(C)#%d (2) {
37  ["b"]=>
38  uninitialized(int)
39  ["c"]=>
40  int(1)
41  ["d"]=>
42  &string(3) "foo"
43}
44