3v4l.org

run code in 200+ php & hhvm versions
<?php abstract class Result { private final function __construct() { } public static function success() { return new Success(); } public static function failure() { return new Failure(); } } final class Success extends Result { public static function fakeIt() { return new self(); } } final class Failure extends Result { } var_dump(Result::success()); var_dump(Result::failure()); Success::fakeIt();
based on QbJaF

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for branch php-master
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Uncaught Error: Call to private Result::__construct() from context 'Success' in /in/5aK01:22 Stack trace: #0 /in/5aK01(34): Success::fakeIt() #1 {main} thrown in /in/5aK01 on line 22
Process exited with code 255.
Output for branch php-master+opcache
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Uncaught Error: Call to private Result::__construct() from context 'Success' in /in/5aK01:22 Stack trace: #0 /in/5aK01(34): Success::fakeIt() #1 {main} thrown in /in/5aK01 on line 22
Process exited with code 255.
Output for branch php-master+jit
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Uncaught Error: Call to private Result::__construct() from context 'Success' in /in/5aK01:22 Stack trace: #0 /in/5aK01(34): Success::fakeIt() #1 {main} thrown in /in/5aK01 on line 22
Process exited with code 255.
Output for Typed properties v2
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Uncaught Error: Call to private Result::__construct() from context 'Success' in /in/5aK01:22 Stack trace: #0 /in/5aK01(34): Success::fakeIt() #1 {main} thrown in /in/5aK01 on line 22
Process exited with code 255.
Output for Arrow functions
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Uncaught Error: Call to private Result::__construct() from context 'Success' in /in/5aK01:22 Stack trace: #0 /in/5aK01(34): Success::fakeIt() #1 {main} thrown in /in/5aK01 on line 22
Process exited with code 255.
Output for Object typehint
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Uncaught Error: Call to private Result::__construct() from context 'Success' in /in/5aK01:22 Stack trace: #0 /in/5aK01(34): Success::fakeIt() #1 {main} thrown in /in/5aK01 on line 22
Process exited with code 255.
Output for Array change keys
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Uncaught Error: Call to private Result::__construct() from context 'Success' in /in/5aK01:22 Stack trace: #0 /in/5aK01(34): Success::fakeIt() #1 {main} thrown in /in/5aK01 on line 22
Process exited with code 255.
Output for Lexical anon
object(Success)#1 (0) { } object(Failure)#1 (0) { } Fatal error: Call to private Result::__construct() from context 'Success' in /in/5aK01 on line 22
Process exited with code 255.

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page