3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This route does this and that. */ #[Route('/my/route/', name:'my_route')] function example() {} $reflector = new ReflectionFunction('example'); var_dump($reflector->getDocComment()); var_dump($reflector->getAttributes());
Output for 8.4.1 - 8.4.15, 8.5.0
string(41) "/** * This route does this and that. */" array(1) { [0]=> object(ReflectionAttribute)#2 (1) { ["name"]=> string(5) "Route" } }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28
string(41) "/** * This route does this and that. */" array(1) { [0]=> object(ReflectionAttribute)#2 (0) { } }
Output for 7.4.0 - 7.4.33
string(41) "/** * This route does this and that. */" Fatal error: Uncaught Error: Call to undefined method ReflectionFunction::getAttributes() in /in/YtVTQ:11 Stack trace: #0 {main} thrown in /in/YtVTQ on line 11
Process exited with code 255.

preferences:
167.66 ms | 408 KiB | 5 Q