1.2.1463. Yield Usage

Usage of generators, with yield keyword.

Yield was introduced in PHP 5.5, and is backward incompatible.

<?php

function prime() {
    $primes = [2, 3, 5, 7, 11, 13, 17, 19];
    foreach($primes as $prime) {
        yield $prime;
    }
}

?>

See also Generator Syntax, Deal with Memory Gently using “Yield” in PHP and Understanding PHP Generators.

1.2.1463.1. Connex PHP features

1.2.1463.1.1. Specs

Short name

Php/YieldUsage

Rulesets

All, Appinfo, CE, Changed Behavior

Exakat since

0.8.4

PHP Version

With PHP 5.5 and more recent

Severity

Time To Fix

Precision

Very high

Available in

Entreprise Edition, Community Edition, Exakat Cloud