TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
595 B
35 lines
595 B
--TEST--
|
|
enum 2
|
|
--FILE--
|
|
<?php
|
|
interface Colorful {
|
|
public function color(): string;
|
|
}
|
|
|
|
enum Suit implements Colorful {
|
|
case Hearts;
|
|
case Diamonds;
|
|
case Clubs;
|
|
case Spades;
|
|
|
|
public function color(): string {
|
|
return match ($this) {
|
|
self::Hearts, self::Diamonds => 'Red',
|
|
self::Clubs, self::Spades => 'Black',
|
|
};
|
|
}
|
|
}
|
|
|
|
function main()
|
|
{
|
|
echo Suit::Hearts->color() . "\n";
|
|
echo Suit::Diamonds->color() . "\n";
|
|
echo Suit::Clubs->color() . "\n";
|
|
echo Suit::Spades->color() . "\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Red
|
|
Red
|
|
Black
|
|
Black
|
|
|