Remove redundant docblock tags
I was very excited about the feature to remove redundant docblock tags in 2023.2, but it isn't as smart as I had anticipated.
/**
* This is just some example I made up for the forum post.
*
* @param int $start
* @param int $count
* @return \DateTime[]
*/
function foo($start, int $count): array
{
return array_fill($start, $count, new \DateTime());
}
... becomes:
/**
* This is just some example I made up for the forum post.
*
* @param int $start
*/
function foo($start, int $count): array
{
return array_fill($start, $count, new \DateTime());
}
Is this a known limitation or something is broken in my setup?
请先登录再写评论。
According to this comment, the
Generate PHPDoc
andUpdate PHPDoc
actions are not yet affected by this change.Please vote for WI-72892.
P.S. I do share the opinion that without WI-72892, the fix is not complete, to say the least.
I actually referred to the
Remove all redundant PHPDoc tags
quick fix mentioned in the first comment. It seems to be a simple check like "param has type, tag is not needed", it doesn't verify if the tag actually provides more information than the raw type.In any case, I also tested it in home PC, running a different OS, and this is the way it is.
Oh. Sorry, I got it completely wrong.
I still don't understand the issue, though.
$start
doesn't have a type specified in the function signature, soint
being specified only in the PHPDoc is the only place the type is stored - hence, we don't delete the tag.What am I missing again?
@return \DateTime[] tells you the response array contains specific objects. If you remove it, it's just array. This is just a test snippet and PhpStorm can auto-detect the right type here anyway, but in my actual codebase it's an issue if you remove array types.
Okay, thank you for your patience. It took me much longer than it should have.
Extracted it as WI-73843.