004.phpt 705 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. ReflectionMethod::invoke() with non object or null value
  3. --FILE--
  4. <?php
  5. class a {
  6. function __construct(){
  7. }
  8. }
  9. class b {
  10. }
  11. $b = new b();
  12. $a=new ReflectionClass("a");
  13. $m=$a->getMethod("__construct");
  14. try {
  15. $m->invoke(null);
  16. } catch (ReflectionException $E) {
  17. echo $E->getMessage()."\n";
  18. }
  19. try {
  20. $m->invoke($b);
  21. } catch (ReflectionException $E) {
  22. echo $E->getMessage()."\n";
  23. }
  24. $b = new a();
  25. try {
  26. $m->invoke($b);
  27. } catch (ReflectionException $E) {
  28. echo $E->getMessage()."\n";
  29. }
  30. ?>
  31. --EXPECT--
  32. Trying to invoke non static method a::__construct() without an object
  33. Given object is not an instance of the class this method was declared in