Skip to content

Commit

Permalink
Merge pull request #153 from CVO-Technologies/yield-error
Browse files Browse the repository at this point in the history
Resolve issue with yield and @return
  • Loading branch information
markstory committed Apr 1, 2016
2 parents c8d759b + 0bd53b6 commit fe95558
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CakePHP/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ protected function processReturn(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
continue;
}

if ($tokens[$returnToken]['code'] === T_RETURN) {
if ($tokens[$returnToken]['code'] === T_RETURN
|| $tokens[$returnToken]['code'] === T_YIELD
) {
break;
}
}
Expand All @@ -188,7 +190,7 @@ protected function processReturn(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
// If return type is not void, there needs to be a return statement
// somewhere in the function that returns something.
if (!in_array('mixed', $typeNames, true) && !in_array('void', $typeNames, true)) {
$returnToken = $phpcsFile->findNext(T_RETURN, $stackPtr, $endToken);
$returnToken = $phpcsFile->findNext(array(T_RETURN, T_YIELD), $stackPtr, $endToken);
if ($returnToken === false) {
$error = 'Function return type is not void, but function has no return statement';
$phpcsFile->addWarning($error, $return, 'InvalidNoReturn');
Expand Down

0 comments on commit fe95558

Please sign in to comment.