xref: /PHP-8.2/Zend/tests/enum/traits.phpt (revision 269c8dac)
1--TEST--
2Enum can use traits
3--FILE--
4<?php
5
6trait Rectangle {
7    public function shape(): string {
8        return "Rectangle";
9    }
10}
11
12enum Suit {
13    use Rectangle;
14
15    case Hearts;
16    case Diamonds;
17    case Clubs;
18    case Spades;
19}
20
21echo Suit::Hearts->shape() . PHP_EOL;
22echo Suit::Diamonds->shape() . PHP_EOL;
23echo Suit::Clubs->shape() . PHP_EOL;
24echo Suit::Spades->shape() . PHP_EOL;
25
26?>
27--EXPECT--
28Rectangle
29Rectangle
30Rectangle
31Rectangle
32