Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cannot use "yield from" inside a by-reference generator

Description

yield from only emit data by value, not by reference.

Example

<?php

function &foo() {
    yield from [1,2,3];
}

?>

Alternatives

  • Remove the reference sign from the function signature.
  • Refactor the code to use yield instead.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See