1.2.677. Method Is A Generator

This rule marks functions, methods, that are using yield and yield from keywords. The usage of that keyword makes them Generator <https://www.php.net/manual/en/class.`generator.php>`_, as is show by the compulsory return type of Generator.

<?php

function generator() {
    yield from generator2();

    return 3;
}

function generator2() {
    yield 1;
    yield 2;
}

?>

See also Generators overview.

1.2.677.1. Specs

Short name

Functions/IsGenerator

Rulesets

All, Appinfo, CE, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Time To Fix

Precision

Very high

Features

generator, yield, yield-from

Available in

Entreprise Edition, Community Edition, Exakat Cloud