File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
Zend /
tests /
closure_036.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 036: Rebinding closures, keep calling scope
--FILE--
<?php
class A {
private $x;
public function __construct($v) {
$this->x = $v;
}
public function getIncrementor() {
return function() { return ++$this->x; };
}
}
$a = new A(0);
$b = new A(10);
$ca = $a->getIncrementor();
$cb = $ca->bindTo($b);
$cb2 = Closure::bind($ca, $b);
var_dump($ca());
var_dump($cb());
var_dump($cb2());
?>
--EXPECTF--
int(1)
int(11)
int(12)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>