ReflectionReference_errors.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. Various error conditions for ReflectionReference
  3. --FILE--
  4. <?php
  5. try {
  6. new ReflectionReference();
  7. } catch (Error $e) {
  8. echo $e->getMessage(), "\n";
  9. }
  10. try {
  11. ReflectionReference::fromArrayElement(new stdClass, "test");
  12. } catch (TypeError $e) {
  13. echo $e->getMessage(), "\n";
  14. }
  15. try {
  16. ReflectionReference::fromArrayElement([], []);
  17. } catch (TypeError $e) {
  18. echo $e->getMessage(), "\n";
  19. }
  20. try {
  21. $ary = [0, 1, 2];
  22. ReflectionReference::fromArrayElement($ary, 3);
  23. } catch (ReflectionException $e) {
  24. echo $e->getMessage(), "\n";
  25. }
  26. try {
  27. $ary = [&$ary];
  28. $ref = ReflectionReference::fromArrayElement($ary, 0);
  29. var_dump(serialize($ref));
  30. } catch (Exception $e) {
  31. echo $e->getMessage(), "\n";
  32. }
  33. try {
  34. var_dump(unserialize('O:19:"ReflectionReference":0:{}'));
  35. } catch (Exception $e) {
  36. echo $e->getMessage(), "\n";
  37. }
  38. ?>
  39. --EXPECTF--
  40. Call to private ReflectionReference::__construct() from global scope
  41. ReflectionReference::fromArrayElement(): Argument #1 ($array) must be of type array, stdClass given
  42. ReflectionReference::fromArrayElement(): Argument #2 ($key) must be of type string|int, array given
  43. Array key not found
  44. Serialization of 'ReflectionReference' is not allowed
  45. Unserialization of 'ReflectionReference' is not allowed