3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_PROPERTY)] enum Types { case Int32; case Int64; case Float32; } define('Float32', Types::Float32); define('Int64', Types::Int64); define('Int32', Types::Int32); class Test { #[Int32] #[Blah] public int $value; } $t = new Test(); $r = new ReflectionClass($t); $attr = $r->getProperty('value')->getAttributes(); foreach($attr as &$a) { if (class_exists($a->getName())) { $a = $a->newInstance(); } else if(defined($a->getName())) { $a = constant($a->getName()); } } var_dump($attr);

preferences:
32.4 ms | 409 KiB | 5 Q