3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait SimpleTrait { private function foo() {} } class TraitFixtureWithFinal { use SimpleTrait { foo as final; } } echo new ReflectionMethod(TraitFixtureWithFinal::class, 'foo');
Output for 8.3.2 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.13, 8.6.0
Warning: Private methods cannot be final as they are never overridden by other classes in /in/UIrg1 on line 9 Method [ <user> final private method foo ] { @@ /in/UIrg1 5 - 5 }
Output for 8.3.0
Method [ <user> final <visibility error> method foo ] { @@ /in/UIrg1 5 - 5 }
Output for 8.1.30 - 8.1.34, 8.2.0 - 8.2.36
Fatal error: Cannot use 'final' as method modifier in /in/UIrg1 on line 11
Process exited with code 255.

preferences:
29.84 ms | 1170 KiB | 6 Q