1.2.499. Generator Cannot Return¶
Generators could not use return and yield at the same time. In PHP 7.0, generator <https://www.php.net/`generator>`_ can now use both of them.
<?php
// This is not allowed until PHP 7.0
function foo() {
yield 1;
return 'b';
}
?>
1.2.499.1. Connex PHP features¶
1.2.499.1.1. Suggestions¶
Remove the return
1.2.499.1.2. Specs¶
Short name |
Functions/GeneratorCannotReturn |
Rulesets |
All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56 |
Exakat since |
1.8.7 |
PHP Version |
With PHP 7.0 and more recent |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |