closures_004.phpt 674 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. ===DONE===
  23. --EXPECTF--
  24. Invoked!
  25. Invoked!
  26. Invoked!
  27. Invoked!
  28. Invoked!
  29. Invoked!
  30. Invoked!
  31. Invoked!
  32. ===DONE===