3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private function do_something (bool $str) { echo "private function"; } public function call_something(A $obj) { //call_user_func([$obj, 'do_something'], true); $obj->do_something(true); } } class B extends A { public function do_something (string $value) { echo "subclass"; } } class C extends B { private function do_something (string $value) { echo "subclass"; } } $a = new A(); $c = new C(); $c->call_something($a);
based on CcP9v
Output for 7.1.0 - 7.2.0
Fatal error: Access level to C::do_something() must be public (as in class B) in /in/UPRZC on line 25
Process exited with code 255.
Output for 7.0.20
private function
Output for 7.0.0 - 7.0.6
Warning: Declaration of B::do_something(string $value) should be compatible with A::do_something(bool $str) in /in/UPRZC on line 19 private function
Output for 5.6.28
Catchable fatal error: Argument 1 passed to A::do_something() must be an instance of bool, boolean given, called in /in/UPRZC on line 11 and defined in /in/UPRZC on line 5
Process exited with code 255.
Output for 5.4.10 - 5.6.21
Strict Standards: Declaration of B::do_something() should be compatible with A::do_something(bool $str) in /in/UPRZC on line 19 Catchable fatal error: Argument 1 passed to A::do_something() must be an instance of bool, boolean given, called in /in/UPRZC on line 11 and defined in /in/UPRZC on line 5
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Strict Standards: Declaration of B::do_something() should be compatible with that of A::do_something() in /in/UPRZC on line 19 Catchable fatal error: Argument 1 passed to A::do_something() must be an instance of bool, boolean given, called in /in/UPRZC on line 11 and defined in /in/UPRZC on line 5
Process exited with code 255.