Add a test case for the scope of a closure generator

Esse commit está contido em:
mwilliams
2013-04-01 09:28:11 -07:00
commit de Sara Golemon
commit 1c329e4ba8
2 arquivos alterados com 25 adições e 0 exclusões
+22
Ver Arquivo
@@ -0,0 +1,22 @@
<?php
class X {
private $priv = 'X';
function foo() {
return function ($x) {
yield $x->priv;
};
}
}
class Y extends X { private $priv = 'Y'; }
class Z extends X { private $priv = 'Z'; }
function test($x) {
$f = $x->foo();
foreach ($f($x) as $v) var_dump($v);
}
test(new X);
test(new Y);
test(new Z);
+3
Ver Arquivo
@@ -0,0 +1,3 @@
string(1) "X"
string(1) "X"
string(1) "X"