Skip to content

Instantly share code, notes, and snippets.

@iluuu1994
Last active October 3, 2020 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iluuu1994/a6fc5e77c4d51d4c0e80ee6927714bad to your computer and use it in GitHub Desktop.
Save iluuu1994/a6fc5e77c4d51d4c0e80ee6927714bad to your computer and use it in GitHub Desktop.
Enum generation
<?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