php-src/Zend/tests/enum/traits.phpt
Ilija Tovilo 269c8dac1d
Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00

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