closures_004.phpt 650 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Reflection on closures: Segfault with getClosure() on closure itself
  3. --FILE--
  4. <?php
  5. $closure = function() { echo "Invoked!\n"; };
  6. $method = new ReflectionFunction ($closure);
  7. $closure2 = $method->getClosure ();
  8. $closure2 ();
  9. $closure2->__invoke ();
  10. unset ($closure);
  11. $closure2 ();
  12. $closure2->__invoke ();
  13. $closure = function() { echo "Invoked!\n"; };
  14. $method = new ReflectionMethod ($closure, '__invoke');
  15. $closure2 = $method->getClosure ($closure);
  16. $closure2 ();
  17. $closure2->__invoke ();
  18. unset ($closure);
  19. $closure2 ();
  20. $closure2->__invoke ();
  21. ?>
  22. --EXPECT--
  23. Invoked!
  24. Invoked!
  25. Invoked!
  26. Invoked!
  27. Invoked!
  28. Invoked!
  29. Invoked!
  30. Invoked!