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;
Output for git.master, git.master_jit
Ok up to here. Fatal error: Uncaught Error: Typed property AttribWithName::$name must not be accessed before initialization in /in/CUgYv:27 Stack trace: #0 {main} thrown in /in/CUgYv on line 27
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
44.75 ms | 405 KiB | 5 Q