Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
$suggestedTypeHint = 'callable';
} else if (strpos($suggestedName, 'callback') !== false) {
$suggestedTypeHint = 'callable';
} else if (preg_match('/^([^<]+)<[^>]+>$/', $suggestedName, $matches) === 1) {
$suggestedTypeHint = $matches[1];
} else if (in_array($suggestedName, Common::$allowedTypes, true) === false) {
$suggestedTypeHint = $suggestedName;
}
Expand Down
12 changes: 12 additions & 0 deletions src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,18 @@ public function ignored() {
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}

/**
* Using generic as a type hint should satisfy a specified object parameter type.
* @see https://phpstan.org/blog/generics-in-php-using-phpdocs
*
* @param Collection<int, string> $values An object with int, string pairs.
*
* @return void
*/
public function genericType(Collection $values) {

}// end genericType()

/**
* When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,18 @@ public function ignored() {
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}

/**
* Using generic as a type hint should satisfy a specified object parameter type.
* @see https://phpstan.org/blog/generics-in-php-using-phpdocs
*
* @param Collection<int, string> $values An object with int, string pairs.
*
* @return void
*/
public function genericType(Collection $values) {

}// end genericType()

/**
* When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error
*
Expand Down
Loading