CakeFest 2024: The Official CakePHP Conference

ReflectionGenerator::getExecutingGenerator

(PHP 7, PHP 8)

ReflectionGenerator::getExecutingGeneratorRécupère l'objet Generator exécuté

Description

public ReflectionGenerator::getExecutingGenerator(): Generator

Récupère l'objet Generator exécuté.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne l'objet Generator actuellement exécuté.

Exemples

Exemple #1 Exemple avec ReflectionGenerator::getExecutingGenerator()

<?php

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

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

$reflectionGen = new ReflectionGenerator($gen);

$gen2 = $reflectionGen->getExecutingGenerator();

var_dump($gen2 === $gen);
var_dump($gen2->current());

Résultat de l'exemple ci-dessus est similaire à :

bool(true)
int(1);

Voir aussi

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top