Uncallable FunctionΒΆ

The function foo() cannot be called. When the code does so, nothing happens.

The trick is the inclusion of a call to yield (or yield from) in the function. It turns the function into a generator, and calling it directly does nothing. It needs to be called with foreach() or iterator_to_array().

This trick applies to functions, arrow functions, closures and methods.

../_images/uncallable_function.png