1--TEST-- 2Test failing readonly assignment with coercion 3--FILE-- 4<?php 5 6class Foo { 7 public readonly string $bar; 8 9 public function __construct() { 10 $this->bar = 'bar'; 11 try { 12 $this->bar = 42; 13 } catch (Error $e) { 14 echo $e->getMessage(), "\n"; 15 } 16 } 17} 18 19new Foo(); 20 21?> 22--EXPECTF-- 23Cannot modify readonly property Foo::$bar 24