Generators cannot return values using “return”¶
Description¶
In PHP 5.x, generators were not allowed to have return values. This feature was added in PHP 7.0, and, after running the full course, generator deliver their return value when calling the getReturn
method.
Example¶
<?php
function foo() {
yield 1;
return 2;
}
?>
Solutions¶
Upgrade to PHP 7.0 or more recent.
Use a global variable to export data from the method.