We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a181d7d commit 4f82ed0Copy full SHA for 4f82ed0
Zend/tests/enum/traits-constants.phpt
@@ -0,0 +1,33 @@
1
+--TEST--
2
+Enum can use traits having constants
3
+--FILE--
4
+<?php
5
+
6
+trait Rectangle {
7
+ private const MESSAGE_RECTANGLE = 'Rectangle';
8
9
+ public function shape(): string {
10
+ return self::MESSAGE_RECTANGLE;
11
+ }
12
+}
13
14
+enum Suit {
15
+ use Rectangle;
16
17
+ case Hearts;
18
+ case Diamonds;
19
+ case Clubs;
20
+ case Spades;
21
22
23
+echo Suit::Hearts->shape() . PHP_EOL;
24
+echo Suit::Diamonds->shape() . PHP_EOL;
25
+echo Suit::Clubs->shape() . PHP_EOL;
26
+echo Suit::Spades->shape() . PHP_EOL;
27
28
+?>
29
+--EXPECT--
30
+Rectangle
31
32
33
0 commit comments