File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / closure_042.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:34:36 2012 UTC (12 years, 9 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, HEAD
php 5.4.3+patches

--TEST--
Closure 042: Binding an instance to a non-scoped non-static closures gives it a dummy scope
--SKIPIF--
<?php if(!extension_loaded("reflection")) print "skip no reflection"; ?>
--FILE--
<?php

$c = function() { var_dump($this); };
$d = $c->bindTo(new stdClass);
$d();
$rm = new ReflectionFunction($d);
var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure

//should have the same effect
$d = $c->bindTo(new stdClass, NULL);
$d();
$rm = new ReflectionFunction($d);
var_dump($rm->getClosureScopeClass()->name); //dummy sope is Closure

echo "Done.\n";

--EXPECTF--
object(stdClass)#%d (0) {
}
string(7) "Closure"
object(stdClass)#%d (0) {
}
string(7) "Closure"
Done.

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>