Skip to content

Instantly share code, notes, and snippets.

@shin1x1
Created July 11, 2021 01:53
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 shin1x1/9e438db47a0025cc825a560a22ab6a3f to your computer and use it in GitHub Desktop.
Save shin1x1/9e438db47a0025cc825a560a22ab6a3f to your computer and use it in GitHub Desktop.
<?php
enum Color: int {
case Red = 1;
case Blue = 2;
case Green = 3;
}
function foo(Color $color) {
var_dump($color);
var_dump($color->name);
}
foo(Color::Red);
foo(Color::from(2));
var_dump(Color::cases());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment