1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 16:52:18 +01:00
Files
archived-php-src/ext/reflection/tests/ReflectionEnumUnitCase_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

37 lines
724 B
PHP

--TEST--
ReflectionEnumUnitCase::__construct()
--FILE--
<?php
enum Foo {
case Bar;
const Baz = self::Bar;
}
echo (new ReflectionEnumUnitCase(Foo::class, 'Bar'))->getName() . "\n";
try {
new ReflectionEnumUnitCase(Foo::class, 'Baz');
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new ReflectionEnumUnitCase(Foo::class, 'Qux');
} catch (\Exception $e) {
echo $e->getMessage() . "\n";
}
try {
new ReflectionEnumUnitCase([], 'Foo');
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
Bar
Constant Foo::Baz is not a case
Constant Foo::Qux does not exist
ReflectionEnumUnitCase::__construct(): Argument #1 ($class) must be of type object|string, array given