Loading coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php +1 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ class FunctionCommentSniff implements Sniff $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'); Loading coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.inc +12 −0 Original line number Diff line number Diff line Loading @@ -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; } } coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.inc.fixed +12 −0 Original line number Diff line number Diff line Loading @@ -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; } } Loading
coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php +1 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ class FunctionCommentSniff implements Sniff $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'); Loading
coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.inc +12 −0 Original line number Diff line number Diff line Loading @@ -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; } }
coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.inc.fixed +12 −0 Original line number Diff line number Diff line Loading @@ -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; } }