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