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(foo $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 foo(); $c = new bar(); $c->call_something($a);
based on uK5Hc
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/CcP9v on line 25
Process exited with code 255.
Output for 7.0.20
Fatal error: Uncaught Error: Class 'foo' not found in /in/CcP9v:28 Stack trace: #0 {main} thrown in /in/CcP9v on line 28
Process exited with code 255.
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/CcP9v on line 19 Fatal error: Uncaught Error: Class 'foo' not found in /in/CcP9v:28 Stack trace: #0 {main} thrown in /in/CcP9v on line 28
Process exited with code 255.
Output for 5.6.28
Fatal error: Class 'foo' not found in /in/CcP9v on line 28
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/CcP9v on line 19 Fatal error: Class 'foo' not found in /in/CcP9v on line 28
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/CcP9v on line 19 Fatal error: Class 'foo' not found in /in/CcP9v on line 28
Process exited with code 255.