3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute] enum DemoEnum {} #[Attribute] trait DemoTrait {} #[Attribute] abstract class DemoAbstract {} #[Attribute] interface DemoInterface {} #[DemoEnum] #[DemoTrait] #[DemoAbstract] #[DemoInterface] function usesWrongAttrib() {} $r = new ReflectionFunction( 'usesWrongAttrib' ); $a = $r->getAttributes(); var_dump( $a ); foreach ( $a as $attrib ) { try { $attrib->newInstance(); } catch ( Error $e ) { echo get_class( $e ) . ": " . $e->getMessage() . "\n"; } }

preferences:
26.75 ms | 404 KiB | 5 Q