Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generics in docblock #3544

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -425,6 +425,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,19 @@ public function ignored() {

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

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

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

/**
/**
* @return void
* @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()