closure_042.phpt 688 B

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