1.2.259. Could Be Generator¶
This rule reports methods, functions… where the return value may be typed Generator
. This is the case when the body of the function uses the yield
and yield from
keyword.
<?php
// Yield makes foo() a generator
function foo() {
yield 1;
// Returns an int
return $b + 8;
}
?>
See also class.
1.2.259.1. Connex PHP features¶
1.2.259.1.1. Suggestions¶
Add Generator typehint to the method.
1.2.259.1.2. Specs¶
Short name |
Typehints/CouldBeGenerator |
Rulesets |
|
Exakat since |
2.2.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |