xref: /PHP-8.1/Zend/tests/enum/implements.phpt (revision 269c8dac)
1--TEST--
2Enum implements
3--FILE--
4<?php
5
6interface Colorful {
7    public function color(): string;
8}
9
10enum Suit implements Colorful {
11    case Hearts;
12    case Diamonds;
13    case Clubs;
14    case Spades;
15
16    public function color(): string {
17        return match ($this) {
18            self::Hearts, self::Diamonds => 'Red',
19            self::Clubs, self::Spades => 'Black',
20        };
21    }
22}
23
24echo Suit::Hearts->color() . "\n";
25echo Suit::Diamonds->color() . "\n";
26echo Suit::Clubs->color() . "\n";
27echo Suit::Spades->color() . "\n";
28
29?>
30--EXPECT--
31Red
32Red
33Black
34Black
35