- var_dump: documentation ( source)
<?php
class Acme {
public function __construct(
public readonly int $changeMe,
) {}
}
$object = new Acme(1);
$reflection = new ReflectionClass($object);
$instance = $reflection->newInstanceWithoutConstructor();
$reflectionProperty = $reflection->getProperty('changeMe');
$reflectionProperty->setValue($instance, 33);
var_dump($reflectionProperty->getValue($instance));