ReflectionEnum_construct.phpt 606 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. ReflectionEnum::__construct()
  3. --FILE--
  4. <?php
  5. enum Foo {}
  6. class Bar {}
  7. echo (new ReflectionEnum(Foo::class))->getName() . "\n";
  8. try {
  9. new ReflectionEnum('Bar');
  10. } catch (\Exception $e) {
  11. echo $e->getMessage() . "\n";
  12. }
  13. try {
  14. new ReflectionEnum('Baz');
  15. } catch (\Exception $e) {
  16. echo $e->getMessage() . "\n";
  17. }
  18. try {
  19. new ReflectionEnum([]);
  20. } catch (Error $e) {
  21. echo $e->getMessage() . "\n";
  22. }
  23. ?>
  24. --EXPECT--
  25. Foo
  26. Class "Bar" is not an enum
  27. Class "Baz" does not exist
  28. ReflectionEnum::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given