Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@
$suggestedTypeHint = 'callable';
} else if (strpos($suggestedName, 'callback') !== false) {
$suggestedTypeHint = 'callable';
} else if (preg_match('/^([^<]+)<[^>]+>$/', $suggestedName, $matches)) {

Check failure on line 438 in src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php

View workflow job for this annotation

GitHub Actions / PHP: 7.4 (Linux)

Implicit true comparisons prohibited; use === TRUE instead
$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 @@ -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 @@ -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