<?php
class My extends ReflectionMethod
{
public $name = 'test';
public $class;
}
$ref = new My(My::class, 'getDeclaringClass');
$ref->class = new stdClass;
echo $ref->name, get_class($ref->class);
Fatal error: Uncaught ReflectionException: Cannot set read-only property My::$class in /in/bjrPR:12
Stack trace:
#0 {main}
thrown in /in/bjrPR on line 12
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Uncaught exception 'ReflectionException' with message 'Cannot set read-only property My::$class' in /in/bjrPR:12
Stack trace:
#0 /in/bjrPR(12): unknown()
#1 {main}
thrown in /in/bjrPR on line 12
Process exited with code 255.