Last active
October 3, 2020 19:22
-
-
Save iluuu1994/a6fc5e77c4d51d4c0e80ee6927714bad to your computer and use it in GitHub Desktop.
Enum generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
enum Foo { | |
case Bar; | |
case Baz(int $qux); | |
} | |
// Gets compiled to | |
abstract class Foo | |
{ | |
public static function Bar(): Bar | |
{ | |
return new Bar(); | |
} | |
public static function Baz(int $qux): Baz | |
{ | |
return new Baz($qux); | |
} | |
} | |
final class Bar extends Foo | |
{ | |
protected function __construct() | |
{ | |
} | |
} | |
final class Baz extends Foo | |
{ | |
public $qux; | |
protected function __construct(int $qux) | |
{ | |
$this->qux = $qux; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment