1.2.1452. Yield From Usage

Usage of generator <https://www.php.net/`generator>`_ delegation, with yield from keyword.

In PHP 7, generator <https://www.php.net/`generator>`_ delegation allows you to yield values from another Generator, Traversable object, or array by using the yield from.

Yield from was introduced in PHP 7.1, and is backward incompatible.

<?php

// Yield delegation
function foo() {
    yield from bar();
}

function bar() {
    yield 1;
}

?>

See also Generator Syntax and Understanding PHP Generators.

1.2.1452.1. Specs

Short name

Php/YieldFromUsage

Rulesets

All, Appinfo, CE

Exakat since

0.8.4

PHP Version

With PHP 7.0 and more recent

Severity

Time To Fix

Precision

Very high

Features

yield, yield-from

Available in

Entreprise Edition, Community Edition, Exakat Cloud