3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace A { class T {} } namespace { class Test { public function first(string $str) : Closure { return function() use ($str) : int { return strlen($str); }; } public function second(): self { return self; } } $t = new Test; echo ($t->second()->first("hello"))(); }
based on cHa3M
Output for 7.2.0 - 7.2.11
Warning: Use of undefined constant self - assumed 'self' (this will throw an Error in a future version of PHP) in /in/mToOC on line 19 Fatal error: Uncaught TypeError: Return value of Test::second() must be an instance of Test, string returned in /in/mToOC:19 Stack trace: #0 /in/mToOC(24): Test->second() #1 {main} thrown in /in/mToOC on line 19
Process exited with code 255.
Output for 7.0.0 - 7.1.23
Notice: Use of undefined constant self - assumed 'self' in /in/mToOC on line 19 Fatal error: Uncaught TypeError: Return value of Test::second() must be an instance of Test, string returned in /in/mToOC:19 Stack trace: #0 /in/mToOC(24): Test->second() #1 {main} thrown in /in/mToOC on line 19
Process exited with code 255.
Output for hhvm-3.22.0
Notice: Use of undefined constant self - assumed 'self' in /in/mToOC on line -1 Fatal error: Uncaught TypeError: Value returned from method Test::second() must be of type Test, string given in /in/mToOC:-1 Stack trace: #0 /in/mToOC(-1): Test->second() #1 {main}
Process exited with code 255.
Output for hhvm-3.12.14 - 3.21.3
Notice: Use of undefined constant self - assumed 'self' in /in/mToOC on line 19 Fatal error: Uncaught TypeError: Value returned from method Test::second() must be of type Test, string given in /in/mToOC:19 Stack trace: #0 /in/mToOC(24): Test->second() #1 {main}
Process exited with code 255.
Output for hhvm-3.11.1
Fatal error: Uncaught Error: syntax error, unexpected ':', expecting '{' in /in/mToOC:12 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.1
Fatal error: Syntax only allowed in Hack files (<?hh) or with -v Eval.EnableHipHopSyntax=true in /in/mToOC on line 10
Process exited with code 255.
Output for 5.3.0 - 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/mToOC on line 10
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/mToOC on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/mToOC on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/mToOC on line 3
Process exited with code 255.