Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: e081c55fb5
Fetching contributors…

Cannot retrieve contributors at this time

executable file 33 lines (26 sloc) 0.45 kb
--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)
Jump to Line
Something went wrong with that request. Please try again.