mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00

RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
23 lines
368 B
PHP
23 lines
368 B
PHP
--TEST--
|
|
Enum attributes
|
|
--FILE--
|
|
<?php
|
|
|
|
#[Attribute]
|
|
class EnumAttribute {
|
|
public function __construct(
|
|
public string $value,
|
|
) {}
|
|
}
|
|
|
|
#[EnumAttribute('Foo')]
|
|
enum Foo {}
|
|
|
|
var_dump((new \ReflectionClass(Foo::class))->getAttributes(EnumAttribute::class)[0]->newInstance());
|
|
|
|
?>
|
|
--EXPECT--
|
|
object(EnumAttribute)#1 (1) {
|
|
["value"]=>
|
|
string(3) "Foo"
|
|
}
|