3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { static function f($f) { $rf = new \ReflectionFunction($f); $rf->getAttributes()[0]->getArguments(); } } $f = eval(' return #[A(self::U)] function () {}; '); C::f($f);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Cannot access "self" when no class scope is active in /in/EvSoU:7 Stack trace: #0 /in/EvSoU(7): ReflectionAttribute->getArguments() #1 /in/EvSoU(16): C::f(Object(Closure)) #2 {main} thrown in /in/EvSoU on line 7
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Call to undefined method ReflectionFunction::getAttributes() in /in/EvSoU:7 Stack trace: #0 /in/EvSoU(16): C::f(Object(Closure)) #1 {main} thrown in /in/EvSoU on line 7
Process exited with code 255.

preferences:
159.11 ms | 401 KiB | 122 Q