xref: /PHP-5.6/Zend/tests/closure_042.phpt (revision 38ff70ef)
1--TEST--
2Closure 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
8$c = function() { var_dump($this); };
9$d = $c->bindTo(new stdClass);
10$d();
11$rm = new ReflectionFunction($d);
12var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure
13
14//should have the same effect
15$d = $c->bindTo(new stdClass, NULL);
16$d();
17$rm = new ReflectionFunction($d);
18var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure
19
20echo "Done.\n";
21
22--EXPECTF--
23object(stdClass)#%d (0) {
24}
25string(7) "Closure"
26object(stdClass)#%d (0) {
27}
28string(7) "Closure"
29Done.
30