<?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;
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`