3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class ThatRebinds { public function worksWith(Closure $callback): void { $callback->call($this); } private function methodAvailableToCallback(): void { echo __METHOD__; } } class ThatSupplies { public function __construct() { $object = new ThatRebinds(); $object->worksWith(function() { // and it can call $this->methodAvailableToCallback(); }); } } new ThatSupplies;
Output for hhvm-3.21.3 - 3.22.0, 7.1.0 - 7.3.0rc3
ThatRebinds::methodAvailableToCallback
Output for 7.0.30 - 7.0.31
ThatRebinds::methodAvailableToCallback Fatal error: Uncaught TypeError: Return value of ThatRebinds::methodAvailableToCallback() must be an instance of void, none returned in /in/jdq1o:8 Stack trace: #0 /in/jdq1o(16): ThatRebinds->methodAvailableToCallback() #1 [internal function]: ThatRebinds->{closure}() #2 /in/jdq1o(4): Closure->call(Object(ThatRebinds)) #3 /in/jdq1o(17): ThatRebinds->worksWith(Object(Closure)) #4 /in/jdq1o(20): ThatSupplies->__construct() #5 {main} thrown in /in/jdq1o on line 8
Process exited with code 255.
Output for hhvm-3.18.5
ThatRebinds::methodAvailableToCallback Fatal error: Uncaught TypeError: Value returned from method ThatRebinds::methodAvailableToCallback() must be of type void, null given in /in/jdq1o:8 Stack trace: #0 /in/jdq1o(16): ThatRebinds->methodAvailableToCallback() #1 (): Closure$ThatSupplies::__construct() #2 /in/jdq1o(4): Closure->call() #3 /in/jdq1o(17): ThatRebinds->worksWith() #4 /in/jdq1o(20): ThatSupplies->__construct() #5 {main}
Process exited with code 255.
Output for 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/jdq1o on line 3
Process exited with code 255.