Skip to content
Snippets Groups Projects
Commit c881f78d authored by Mitch Portier's avatar Mitch Portier Committed by Klaus Purer
Browse files

fix(FunctionComment): Recognise 'yield from' as valid return statement (#3106904 by Arkener)

parent bfd339cd
Branches
Tags
No related merge requests found
......@@ -279,7 +279,7 @@ class FunctionCommentSniff implements Sniff
$searchStart = $stackPtr;
$foundNonVoidReturn = false;
do {
$returnToken = $phpcsFile->findNext([T_RETURN, T_YIELD], $searchStart, $endToken);
$returnToken = $phpcsFile->findNext([T_RETURN, T_YIELD, T_YIELD_FROM], $searchStart, $endToken);
if ($returnToken === false && $foundReturnToken === false) {
$error = '@return doc comment specified, but function has no return statement';
$phpcsFile->addError($error, $return, 'InvalidNoReturn');
......
......@@ -506,3 +506,13 @@ class Small {
function test37(array $matches, array $sub_key, $to) {
}
/**
* Yield from should be a recognised return statement.
*
* @return Generator
* Generator value.
*/
function test38($a, $b) {
yield from [$a, $b];
}
......@@ -532,3 +532,13 @@ class Small {
function test37(array $matches, array $sub_key, $to) {
}
/**
* Yield from should be a recognised return statement.
*
* @return Generator
* Generator value.
*/
function test38($a, $b) {
yield from [$a, $b];
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment