Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.1: Enumerations support #652

Closed
zonuexe opened this issue Mar 6, 2021 · 0 comments · Fixed by #653
Closed

PHP 8.1: Enumerations support #652

zonuexe opened this issue Mar 6, 2021 · 0 comments · Fixed by #653

Comments

@zonuexe
Copy link
Member

zonuexe commented Mar 6, 2021

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

<?php

enum Size
{
    case Small;
    case Medium;
    case Large;
 
    public static function fromLength(int $cm)
    {
        return match(true) {
            $cm < 50 => static::Small,
            $cm < 100 => static::Medium,
            default => static::Large,
        };
    }
}
zonuexe added a commit that referenced this issue Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant