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.
 
 

43 lines
694 B

--TEST--
An enum may satisfy Trait abstract methods and implement interfaces
--FILE--
<?php
interface Labeled
{
public function label(): string;
}
trait RequiresLabel
{
abstract public function label(): string;
public function description(): string
{
return 'case=' . $this->label();
}
}
enum Suit implements Labeled
{
use RequiresLabel;
case Hearts;
public function label(): string
{
return $this->name;
}
}
function main(): void
{
var_dump(Suit::Hearts instanceof Labeled);
var_dump(Suit::Hearts->label());
var_dump(Suit::Hearts->description());
}
?>
--EXPECT--
bool(true)
string(6) "Hearts"
string(11) "case=Hearts"