Skip to content

Add preview support for PHP Enumerations #100

Closed
@thekid

Description

@thekid

See https://wiki.php.net/rfc/enumerations

enum Suit implements Colorful {
  case Hearts;
  case Diamonds;
  case Clubs;
  case Spades;
 
  // Fulfills the interface contract.
  public function color(): string {
    return match ($this) {
      Suit::Hearts, Suit::Diamonds => 'Red',
      Suit::Clubs, Suit::Spaces => 'Black',
    };
  }
}

Currently, the XP syntax is implemented via https://github.com/xp-lang/xp-enums

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions