1--TEST-- 2Variable assignment in catch must respect typed references 3--FILE-- 4<?php 5 6class Test { 7 public int $i = 42; 8 public string $s = "str"; 9} 10 11$test = new Test; 12 13$ref =& $test->i; 14try { 15 try { 16 throw new Exception("ex"); 17 } catch (Exception $ref) { 18 echo "Unreachable\n"; 19 } 20} catch (TypeError $e) { 21 var_dump($test->i); 22 echo $e . "\n\n"; 23} 24 25$ref =& $test->s; 26try { 27 try { 28 throw new Exception("ex"); 29 } catch (Exception $ref) { 30 echo "Unreachable\n"; 31 } 32} catch (TypeError $e) { 33 var_dump($test->s); 34 echo $e . "\n\n"; 35} 36 37?> 38--EXPECTF-- 39int(42) 40TypeError: Cannot assign Exception to reference held by property Test::$i of type int in %s:%d 41Stack trace: 42#0 {main} 43 44string(3) "str" 45TypeError: Cannot assign Exception to reference held by property Test::$s of type string in %s:%d 46Stack trace: 47#0 {main} 48