Annotation of embedaddon/php/Zend/tests/closure_036.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Closure 036: Rebinding closures, keep calling scope
! 3: --FILE--
! 4: <?php
! 5:
! 6: class A {
! 7: private $x;
! 8:
! 9: public function __construct($v) {
! 10: $this->x = $v;
! 11: }
! 12:
! 13: public function getIncrementor() {
! 14: return function() { return ++$this->x; };
! 15: }
! 16: }
! 17:
! 18: $a = new A(0);
! 19: $b = new A(10);
! 20:
! 21: $ca = $a->getIncrementor();
! 22: $cb = $ca->bindTo($b);
! 23: $cb2 = Closure::bind($ca, $b);
! 24:
! 25: var_dump($ca());
! 26: var_dump($cb());
! 27: var_dump($cb2());
! 28:
! 29: ?>
! 30: --EXPECTF--
! 31: int(1)
! 32: int(11)
! 33: int(12)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>