mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
269c8dac1d
RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
35 lines
606 B
PHP
35 lines
606 B
PHP
--TEST--
|
|
ReflectionEnum::__construct()
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo {}
|
|
class Bar {}
|
|
|
|
echo (new ReflectionEnum(Foo::class))->getName() . "\n";
|
|
|
|
try {
|
|
new ReflectionEnum('Bar');
|
|
} catch (\Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
new ReflectionEnum('Baz');
|
|
} catch (\Exception $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
new ReflectionEnum([]);
|
|
} catch (Error $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Foo
|
|
Class "Bar" is not an enum
|
|
Class "Baz" does not exist
|
|
ReflectionEnum::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given
|