closure_042.phpt 606 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Closure 042: Binding an instance to a non-scoped non-static closures gives it a dummy scope
  3. --FILE--
  4. <?php
  5. $c = function() { var_dump($this); };
  6. $d = $c->bindTo(new stdClass);
  7. $d();
  8. $rm = new ReflectionFunction($d);
  9. var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure
  10. //should have the same effect
  11. $d = $c->bindTo(new stdClass, NULL);
  12. $d();
  13. $rm = new ReflectionFunction($d);
  14. var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure
  15. echo "Done.\n";
  16. ?>
  17. --EXPECTF--
  18. object(stdClass)#%d (0) {
  19. }
  20. string(7) "Closure"
  21. object(stdClass)#%d (0) {
  22. }
  23. string(7) "Closure"
  24. Done.