1--TEST-- 2Reflection properties are read only 3--FILE-- 4<?php 5 6#[AllowDynamicProperties] 7class ReflectionMethodEx extends ReflectionMethod 8{ 9 public $foo = "xyz"; 10 11 function __construct($c,$m) 12 { 13 echo __METHOD__ . "\n"; 14 parent::__construct($c,$m); 15 } 16} 17 18$r = new ReflectionMethodEx('ReflectionMethodEx','getName'); 19 20var_dump($r->class); 21var_dump($r->name); 22var_dump($r->foo); 23@var_dump($r->bar); 24 25try 26{ 27 $r->class = 'bullshit'; 28} 29catch(ReflectionException $e) 30{ 31 echo $e->getMessage() . "\n"; 32} 33try 34{ 35$r->name = 'bullshit'; 36} 37catch(ReflectionException $e) 38{ 39 echo $e->getMessage() . "\n"; 40} 41 42$r->foo = 'bar'; 43$r->bar = 'baz'; 44 45var_dump($r->class); 46var_dump($r->name); 47var_dump($r->foo); 48var_dump($r->bar); 49 50?> 51--EXPECT-- 52ReflectionMethodEx::__construct 53string(26) "ReflectionFunctionAbstract" 54string(7) "getName" 55string(3) "xyz" 56NULL 57Cannot set read-only property ReflectionMethodEx::$class 58Cannot set read-only property ReflectionMethodEx::$name 59string(26) "ReflectionFunctionAbstract" 60string(7) "getName" 61string(3) "bar" 62string(3) "baz" 63