php-src/ext/reflection/tests/ReflectionEnum_construct.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

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