Skip to content

PHP 8.1: Enumerations support #652

Description

@zonuexe

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,
        };
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions