summaryrefslogtreecommitdiff
path: root/Zend/tests/enum/static-methods.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests/enum/static-methods.phpt')
-rw-r--r--Zend/tests/enum/static-methods.phpt28
1 files changed, 28 insertions, 0 deletions
diff --git a/Zend/tests/enum/static-methods.phpt b/Zend/tests/enum/static-methods.phpt
new file mode 100644
index 0000000000..361ee77664
--- /dev/null
+++ b/Zend/tests/enum/static-methods.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Enum supports static methods
+--FILE--
+<?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,
+ };
+ }
+}
+
+var_dump(Size::fromLength(23));
+var_dump(Size::fromLength(63));
+var_dump(Size::fromLength(123));
+
+?>
+--EXPECT--
+enum(Size::Small)
+enum(Size::Medium)
+enum(Size::Large)