1--TEST-- 2Test assign to typed property taken by reference 3--FILE-- 4<?php 5class A { 6 public $foo = 1; 7 public int $bar = 2; 8} 9class B { 10 public A $a; 11} 12$f = function (&$n) { 13 var_dump($n); 14 $n = "ops"; 15}; 16$o = new B; 17$o->a = new A; 18$f($o->a->foo); 19$f($o->a->bar); 20?> 21--EXPECTF-- 22int(1) 23int(2) 24 25Fatal error: Uncaught TypeError: Cannot assign string to reference held by property A::$bar of type int in %s:%d 26Stack trace: 27#0 %s(%d): {closure:%s:%d}(2) 28#1 {main} 29 thrown in %s on line %d 30