mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
32 lines
450 B
PHP
32 lines
450 B
PHP
--TEST--
|
|
Enum can use traits
|
|
--FILE--
|
|
<?php
|
|
|
|
trait Rectangle {
|
|
public function shape(): string {
|
|
return "Rectangle";
|
|
}
|
|
}
|
|
|
|
enum Suit {
|
|
use Rectangle;
|
|
|
|
case Hearts;
|
|
case Diamonds;
|
|
case Clubs;
|
|
case Spades;
|
|
}
|
|
|
|
echo Suit::Hearts->shape() . PHP_EOL;
|
|
echo Suit::Diamonds->shape() . PHP_EOL;
|
|
echo Suit::Clubs->shape() . PHP_EOL;
|
|
echo Suit::Spades->shape() . PHP_EOL;
|
|
|
|
?>
|
|
--EXPECT--
|
|
Rectangle
|
|
Rectangle
|
|
Rectangle
|
|
Rectangle
|