Skip to content

Commit 4f82ed0

Browse files
committed
Add a testcase for Enum using traits having constants
1 parent a181d7d commit 4f82ed0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Zend/tests/enum/traits-constants.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
Rectangle
32+
Rectangle
33+
Rectangle

0 commit comments

Comments
 (0)