You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
859 B

  1. --TEST--
  2. Test ReflectionProperty class constructor errors.
  3. --FILE--
  4. <?php
  5. class TestClass {
  6. }
  7. $a = 5;
  8. echo "Non-existent class:\n";
  9. try {
  10. $propInfo = new ReflectionProperty("NonExistentClass", "prop");
  11. }
  12. catch(Exception $e) {
  13. echo $e->getMessage();
  14. }
  15. echo "\n\nWrong property parameter type:\n";
  16. try {
  17. $propInfo = new ReflectionProperty($a, 'TestClass');
  18. }
  19. catch(ReflectionException $e) {
  20. echo $e->getMessage();
  21. }
  22. echo "\n\nNon-existent property:\n";
  23. try {
  24. $propInfo = new ReflectionProperty('TestClass', "nonExistentProperty");
  25. }
  26. catch(Exception $e) {
  27. echo $e->getMessage();
  28. }
  29. ?>
  30. --EXPECT--
  31. Non-existent class:
  32. Class NonExistentClass does not exist
  33. Wrong property parameter type:
  34. The parameter class is expected to be either a string or an object
  35. Non-existent property:
  36. Property TestClass::$nonExistentProperty does not exist