3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface factory { public static function new(): factory; } #[Value] class Value { public int $value; public function __construct(int $value) { $this->value = $value; } } #[Value(value: 42)] class One implements factory { public static function new(): One { return new One; } } #[Value(value: 2)] class Two implements factory { public static function new(): Two { return new Two; } } #[Value(value: 3)] class Three implements factory { public static function new(): Three { return new Three; } } $arrayOfClasses = [One::new(), Two::new(), Three::new()]; function dumpAttributeData(ReflectionClass $reflection) { $attributes = $reflection->getAttributes(); foreach ($attributes as $attribute) { var_dump($attribute->getName()); var_dump($attribute->getArguments()); } } foreach ($arrayOfClasses as $class) { dumpAttributeData(new ReflectionClass($class::class)); }
Output for git.master, git.master_jit, rfc.property-hooks
string(5) "Value" array(1) { ["value"]=> int(42) } string(5) "Value" array(1) { ["value"]=> int(2) } string(5) "Value" array(1) { ["value"]=> int(3) }

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:
49.18 ms | 401 KiB | 8 Q