mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
While internally enums are mostly the same as classes, their output in `ReflectionClass::__toString()` should show the enum as the developer wrote it, rather than as the engine stored it. Accordingly - Say that the enum is an enum, not a final class - Include the backing type, if any, in the declaration line - List enum cases separately from constants, and show the underlying values, if any GH-15766
43 lines
600 B
PHP
43 lines
600 B
PHP
--TEST--
|
|
ReflectionEnum::__toString()
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo {
|
|
case Bar;
|
|
}
|
|
|
|
echo new ReflectionEnum(Foo::class);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Enum [ <user> enum Foo implements UnitEnum ] {
|
|
@@ %sReflectionEnum_toString.php 3-5
|
|
|
|
- Enum cases [1] {
|
|
Case Bar
|
|
}
|
|
|
|
- Constants [0] {
|
|
}
|
|
|
|
- Static properties [0] {
|
|
}
|
|
|
|
- Static methods [1] {
|
|
Method [ <internal, prototype UnitEnum> static public method cases ] {
|
|
|
|
- Parameters [0] {
|
|
}
|
|
- Return [ array ]
|
|
}
|
|
}
|
|
|
|
- Properties [1] {
|
|
Property [ public protected(set) readonly string $name ]
|
|
}
|
|
|
|
- Methods [0] {
|
|
}
|
|
}
|