Enums

From the PHP documentation:

Enums allow a developer to define a custom type that is limited to one of a discrete number of possible values.

THP enums are a 1 to 1 map of PHP enums, with a slightly different syntax.

Basic enums

Enums don’t have a scalar value by default.

enum Suit {
  Hearts,
  Diamonds,
  Clubs,
  Spades,
}

val suit = Suit::Heartsthp

Backed enums

Backed enums can have a scalar for each case. The scalar values can only be String or Int.

enum Suit(String) {
  Hearts = "H",
  Diamonds = "D",
  Clubs = "C",
  Spades = "S",
}thp

All cases must explicitly define their value, there is no automatic generation.