xref: /PHP-7.2/Zend/tests/closure_042.phpt (revision f1d7e3ca)
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--EXPECTF--
22object(stdClass)#%d (0) {
23}
24string(7) "Closure"
25object(stdClass)#%d (0) {
26}
27string(7) "Closure"
28Done.
29