xref: /PHP-8.0/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--FILE--
4<?php
5
6$c = function() { var_dump($this); };
7$d = $c->bindTo(new stdClass);
8$d();
9$rm = new ReflectionFunction($d);
10var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure
11
12//should have the same effect
13$d = $c->bindTo(new stdClass, NULL);
14$d();
15$rm = new ReflectionFunction($d);
16var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure
17
18echo "Done.\n";
19?>
20--EXPECTF--
21object(stdClass)#%d (0) {
22}
23string(7) "Closure"
24object(stdClass)#%d (0) {
25}
26string(7) "Closure"
27Done.
28