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

Symfony.Commenting.FunctionComment.Missing not working for methods that use attributes #190

Open
vpassapera opened this issue Jun 17, 2021 · 3 comments

Comments

@vpassapera
Copy link

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.

@mmoll
Copy link
Contributor

mmoll commented Jul 10, 2021

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?

@mmoll
Copy link
Contributor

mmoll commented Jul 24, 2021

squizlabs/PHP_CodeSniffer#3396 might fix this.

@mmoll
Copy link
Contributor

mmoll commented Oct 18, 2021

phpc 3.6.1 got released, @vpassapera could you test, if that fixes this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants