ReflectionParameter_invalidMethodInConstructor.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. ReflectionParameter::__construct(): Invalid method as constructor
  3. --FILE--
  4. <?php
  5. // Invalid class name
  6. try {
  7. new ReflectionParameter (array ('A', 'b'), 0);
  8. } catch (ReflectionException $e) { echo $e->getMessage()."\n"; }
  9. // Invalid class method
  10. try {
  11. new ReflectionParameter (array ('C', 'b'), 0);
  12. } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; }
  13. // Invalid object method
  14. try {
  15. new ReflectionParameter (array (new C, 'b'), 0);
  16. } catch (ReflectionException $e) { echo $e->getMessage ()."\n"; }
  17. class C {
  18. }
  19. try {
  20. new ReflectionParameter(array ('A', 'b'));
  21. }
  22. catch(TypeError $e) {
  23. printf( "Ok - %s\n", $e->getMessage());
  24. }
  25. try {
  26. new ReflectionParameter(0, 0);
  27. }
  28. catch(ReflectionException $e) {
  29. printf( "Ok - %s\n", $e->getMessage());
  30. }
  31. echo "Done.\n";
  32. ?>
  33. --EXPECT--
  34. Class "A" does not exist
  35. Method C::b() does not exist
  36. Method C::b() does not exist
  37. Ok - ReflectionParameter::__construct() expects exactly 2 arguments, 1 given
  38. Ok - ReflectionParameter::__construct(): Argument #1 ($function) must be a string, an array(class, method), or a callable object, int given
  39. Done.