3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private static $foo = 123; protected static function bar() { echo 'scope is: ', static::class, ' value of self::$foo is: ', self::$foo, PHP_EOL; } } class B extends A { private static $foo = 456; public static function bar() { $closure = self::getStaticInvoker('A', 'bar')->bindTo(null, B::class); $closure(); } private static function getStaticInvoker($className, $method) { return function (array $args) use ($className, $method) { return forward_static_call_array(array($className, $method), $args); }; } } B::bar();
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function B::{closure}(), 0 passed in /in/25GLe on line 15 and exactly 1 expected in /in/25GLe:20 Stack trace: #0 /in/25GLe(15): B::{closure}() #1 /in/25GLe(26): B::bar() #2 {main} thrown in /in/25GLe on line 20
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught TypeError: Argument 1 passed to B::{closure}() must be of the type array, none given, called in /in/25GLe on line 15 and defined in /in/25GLe:20 Stack trace: #0 /in/25GLe(15): B::{closure}() #1 /in/25GLe(26): B::bar() #2 {main} thrown in /in/25GLe on line 20
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Catchable fatal error: Argument 1 passed to B::{closure}() must be of the type array, none given, called in /in/25GLe on line 15 and defined in /in/25GLe on line 20
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/25GLe on line 6
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /in/25GLe on line 6
Process exited with code 255.