Yield, Not ReturnΒΆ

This will display 1 2 3. This is because the ... operator will act as a foreach and runs the generator. It will then spread the values as arguments for the function call, and, in this case, it matches the needed arguments.

Note that named parameters are also supported, with the good PHP version.

The returned value of the generator is lost, in this case. If you need to access the returned values, you must get the generator, and call the getReturn() method.

../_images/yield_not_return.png