Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Запрещаем переопределение переменной в PHP с помощью класса SplEnum
* @link
* @link
class Month extends SplEnum
const __default = self::January;
const January = 1;
const February = 2;
const March = 3;
// ...
// Вернёт Month::January
$month = new Month;
// Бросит исключение UnexpectedValueException
$month = 'January';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.