ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 三、ReflectionGenerator类用于获取生成器的信息 ## **[生成器反射类](https://www.php.net/manual/zh/class.reflectiongenerator.php#class.reflectiongenerator)** ``` <pre class="calibre10">``` ReflectionGenerator <span class="token3">{</span> <span class="token">/* 方法 */</span> public __construct <span class="token3">(</span> Generator $generator <span class="token3">)</span> <span class="token">//构造一个ReflectionGenerator对象</span> public getExecutingFile <span class="token3">(</span> void <span class="token3">)</span> <span class="token3">:</span> string <span class="token">//获取当前正在执行的生成器(Generator)的文件名</span> public getExecutingGenerator <span class="token3">(</span> void <span class="token3">)</span> <span class="token3">:</span> Generator <span class="token">//获取正在执行的生成器(Generator)对象</span> public getExecutingLine <span class="token3">(</span> void <span class="token3">)</span> <span class="token3">:</span> int <span class="token">//获取生成器的当前执行行</span> public getFunction <span class="token3">(</span> void <span class="token3">)</span> <span class="token3">:</span> ReflectionFunctionAbstract public getThis <span class="token3">(</span> void <span class="token3">)</span> <span class="token3">:</span> object <span class="token">//获取生成器的$this值</span> public getTrace <span class="token3">(</span><span class="token3">[</span> int $options <span class="token1">=</span> DEBUG_BACKTRACE_PROVIDE_OBJECT <span class="token3">]</span> <span class="token3">)</span> <span class="token3">:</span> array <span class="token">//获取正在执行的生成器的跟踪</span> <span class="token3">}</span> ``` ``` 什么是生成器参考预定义接口的Generator生成器类以及yield