mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00

RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
31 lines
450 B
PHP
31 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
|