3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Service { } #[Attribute] class Inject{} class InjectAttributePresenter { #[Inject] public Service $service; } $reflector = new ReflectionProperty(InjectAttributePresenter::class, 'service'); var_dump($reflector->getAttributes(Inject::class));
Output for 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
array(1) { [0]=> object(ReflectionAttribute)#2 (1) { ["name"]=> string(6) "Inject" } }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.31, 8.3.0 - 8.3.31
array(1) { [0]=> object(ReflectionAttribute)#2 (0) { } }

preferences:
77.85 ms | 1136 KiB | 4 Q