3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[\Attribute] class AttribWithName { public readonly string $name; public function __construct(?string $name = null) { if ($name) { $this->name = $name; } } public function fromReflection(\ReflectionClass $subject): void { $this->name ??= $subject->getShortName(); } } #[AttribWithName()] class C {} $attr = (new ReflectionClass(C::class))->getAttributes()[0]->newInstance(); print "Ok up to here.\n"; // And now the fatal. print $attr->name;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
166.7 ms | 1591 KiB | 8 Q