array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'reflectiongenerator.getthis.php', 1 => 'ReflectionGenerator::getThis', 2 => 'Gets the $this value of the generator', ), 'up' => array ( 0 => 'class.reflectiongenerator.php', 1 => 'ReflectionGenerator', ), 'prev' => array ( 0 => 'reflectiongenerator.getfunction.php', 1 => 'ReflectionGenerator::getFunction', ), 'next' => array ( 0 => 'reflectiongenerator.gettrace.php', 1 => 'ReflectionGenerator::getTrace', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/reflection/reflectiongenerator/getthis.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

ReflectionGenerator::getThis

(PHP 7, PHP 8)

ReflectionGenerator::getThisGets the $this value of the generator

Опис

public ReflectionGenerator::getThis(): ?object

Get the $this value that the generator has access to.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

Returns the $this value, or null if the generator was not created in a class context.

Приклади

Приклад #1 ReflectionGenerator::getThis() example

<?php

class GenExample
{
public function
gen()
{
yield
1;
}
}

$gen = (new GenExample)->gen();

$reflectionGen = new ReflectionGenerator($gen);

var_dump($reflectionGen->getThis());

Поданий вище приклад виведе щось схоже на:

object(GenExample)#3 (0) {
}

Прогляньте також