Skip to content
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)) {
$suggestedTypeHint = $matches[1];
} else if (in_array($suggestedName, Common::$allowedTypes, true) === false) {
$suggestedTypeHint = $suggestedName;
}
Expand Down
14 changes: 13 additions & 1 deletion src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ public function ignored() {

// phpcs:set Squiz.Commenting.FunctionComment specialMethods[] __construct,__destruct

/**
/**
* @return void
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}
Expand Down Expand Up @@ -1158,3 +1158,15 @@ function paramVariation3($hasTypeNoComment): void {}
* @return void
*/
function paramVariation4($hasTypehasComment): void {}

/**
* 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()
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ public function ignored() {

// phpcs:set Squiz.Commenting.FunctionComment specialMethods[] __construct,__destruct

/**
/**
* @return void
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}
Expand Down Expand Up @@ -1158,3 +1158,15 @@ function paramVariation3($hasTypeNoComment): void {}
* @return void
*/
function paramVariation4($hasTypehasComment): void {}

/**
* 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()
Loading