Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #2906931: Yield should be a recognised return statement. #8

Merged
merged 1 commit into from Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -259,7 +259,7 @@ protected function processReturn(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
$searchStart = $stackPtr;
$foundNonVoidReturn = false;
do {
$returnToken = $phpcsFile->findNext(T_RETURN, $searchStart, $endToken);
$returnToken = $phpcsFile->findNext(array(T_RETURN, T_YIELD), $searchStart, $endToken);
if ($returnToken === false && $foundReturnToken === false) {
$error = '@return doc comment specified, but function has no return statement';
$phpcsFile->addError($error, $return, 'InvalidNoReturn');
Expand Down
12 changes: 12 additions & 0 deletions coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.inc
Expand Up @@ -429,3 +429,15 @@ function test32($a, $b) {
function test33($a, $b) {

}

/**
* Yield should be a recognised return statement.
*
* @return int
* Integer value.
*/
function test34($a, $b) {
for ($i = 1; $i <= 3; $i++) {
yield $i;
}
}
Expand Up @@ -455,3 +455,15 @@ function test32($a, $b) {
function test33($a, $b) {

}

/**
* Yield should be a recognised return statement.
*
* @return int
* Integer value.
*/
function test34($a, $b) {
for ($i = 1; $i <= 3; $i++) {
yield $i;
}
}