- class_parents: documentation ( source)
- implode: documentation ( source)
<?php
readonly class Foobar
{
public function __construct(public string $foo) {}
}
try {
$reflection = new ReflectionClass(Foobar::class);
$obj = $reflection->newInstanceWithoutConstructor();
echo $obj->foo, PHP_EOL;
} catch (Throwable $exception) {
echo $exception->getMessage(), PHP_EOL,
$exception::class, PHP_EOL,
implode(PHP_EOL, class_parents($exception));
}