Arquivos
hhvm/hphp/test/quick/generator_method.php
T
Paul Tarjan 4da410ab58 Rename closures and generators
Closures and generators are really hard to reason about in backtraces.

For generators, I took the exact name of the method and put ##$continuation##. I put it at the end so it reads exactly like a method name since in WWW we use them almost the same as the method itself.

For closures, I named the class ##Closue$Class::method#num## where num is an optional autoincrementing number.

I decided to stop prefixing the methods with ##0## which is breaking the reflection tests.

This basically redoes D782498 and D750608 but it works in repo mode.
2013-05-20 13:52:30 -07:00

19 linhas
317 B
PHP

<?php
class A {
public function Gen() {
var_dump($this);
yield 1; yield 2; yield 3;
}
public static function SGen() {
var_dump(get_called_class());
yield 4; yield 5; yield 6;
}
}
$a = new A();
foreach ($a->Gen() as $num) { var_dump($num); }
foreach (A::SGen() as $num) { var_dump($num); }