Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected function processReturn(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
// somewhere in the function that returns something.
if (isset($tokens[$stackPtr]['scope_closer']) === true) {
$endToken = $tokens[$stackPtr]['scope_closer'];
$returnToken = $phpcsFile->findNext(T_RETURN, $stackPtr, $endToken);
$returnToken = $phpcsFile->findNext([T_RETURN, T_YIELD], $stackPtr, $endToken);
if ($returnToken === false) {
$error = 'Function return type is not void, but function has no return statement';
$phpcsFile->addError($error, $return, 'InvalidNoReturn');
Expand Down Expand Up @@ -380,6 +380,14 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
$suggestedTypeHint = '';
if (strpos($suggestedName, 'array') !== false) {
$suggestedTypeHint = 'array';
} else if (strpos($suggestedName, 'string') !== false) {
$suggestedTypeHint = 'string';
} else if (strpos($suggestedName, 'int') !== false) {
$suggestedTypeHint = 'int';
} else if (strpos($suggestedName, 'bool') !== false) {
$suggestedTypeHint = 'bool';
} else if (strpos($suggestedName, 'float') !== false) {
$suggestedTypeHint = 'float';
} else if (strpos($suggestedName, 'callable') !== false) {
$suggestedTypeHint = 'callable';
// TODO: AllowedTypes are the long version but we only allow the short version.
Expand Down