Symfony-coding-standard
Symfony-coding-standard copied to clipboard
Symfony.Commenting.FunctionComment.Missing not working for methods that use attributes
In my controller, I have:
/**
* Returns a single Feed Item.
*
* @OA\Tag(name="FeedItem")
* @OA\Get(
* @OA\Parameter(
* name="uuid",
* in="path",
* description="UUID for the FeedItem",
* required=true,
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="Returns a specific FeedItem by UUID.",
* @OA\MediaType(
* mediaType="application/json",
* @OA\Schema(ref=@Model(type=FeedItemResponse::class)),
* )
* ),
* @OA\Response(
* response=404,
* description="When the UUID is not found.",
* )
* )
*
* @Security(name="None")
*
* @param string $uuid
*
* @return FeedItemResponse
*/
#[Route('/{uuid}', name: 'get_feed_item', methods: ['GET'])]
public function getFeedItem(string $uuid): FeedItemResponse
{
try {
return $this->feedItemService->getFeedItemByUUID($uuid);
} catch (NoResultException $e) {
// Throw below...
}
throw $this->createNotFoundException(message: 'Feed item with that UUID was not found.', previous: $e);
}
Running PHP CS on this, returns:
FILE: /shared/httpd/tcgtop8-api/src/Controller/FeedItemController.php
------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------
133 | ERROR | Missing doc comment for function getFeedItem()
| | (Symfony.Commenting.FunctionComment.Missing)
It seems the sniff does not accept attributes in between the phpdoc block and the method. This seems incorrect.
It works if I move the attribute above the docblock, but that just seems lexically wrong.
AFAICT, this is a problem in PHP CodeSniffer's PEAR.FunctionCommentSniff
, which is only extended by Symfony.FunctionCommentSniff
. Could anybody verify this and report it to the upstream project?
https://github.com/squizlabs/PHP_CodeSniffer/pull/3396 might fix this.
phpc 3.6.1 got released, @vpassapera could you test, if that fixes this issue?