1--TEST-- 2ReflectionFunction::isGenerator() 3--FILE-- 4<?php 5 6$closure1 = function() {return "this is a closure"; }; 7$closure2 = function($param) { 8 yield $param; 9}; 10 11$rf1 = new ReflectionFunction($closure1); 12var_dump($rf1->isGenerator()); 13 14$rf2 = new ReflectionFunction($closure2); 15var_dump($rf2->isGenerator()); 16 17function func1() { 18 return 'func1'; 19} 20 21function func2() { 22 yield 'func2'; 23} 24 25$rf1 = new ReflectionFunction('func1'); 26var_dump($rf1->isGenerator()); 27 28$rf2 = new ReflectionFunction('func2'); 29var_dump($rf2->isGenerator()); 30 31 32class Foo { 33 public function f1() { 34 } 35 36 public function f2() { 37 yield; 38 } 39} 40 41$rc = new ReflectionClass('Foo'); 42foreach($rc->getMethods() as $m) { 43 var_dump($m->isGenerator()); 44} 45?> 46--EXPECT-- 47bool(false) 48bool(true) 49bool(false) 50bool(true) 51bool(false) 52bool(true) 53