xref: /PHP-8.1/Zend/tests/enum/static-methods.phpt (revision 269c8dac)
1--TEST--
2Enum supports static methods
3--FILE--
4<?php
5
6enum Size {
7    case Small;
8    case Medium;
9    case Large;
10
11    public static function fromLength(int $cm) {
12        return match(true) {
13            $cm < 50 => static::Small,
14            $cm < 100 => static::Medium,
15            default => static::Large,
16        };
17    }
18}
19
20var_dump(Size::fromLength(23));
21var_dump(Size::fromLength(63));
22var_dump(Size::fromLength(123));
23
24?>
25--EXPECT--
26enum(Size::Small)
27enum(Size::Medium)
28enum(Size::Large)
29