vscode-php-docblocker icon indicating copy to clipboard operation
vscode-php-docblocker copied to clipboard

DocBlock empty when {id} in Route

Open youpilai opened this issue 2 years ago • 1 comments

First, apologize if it's a silly question, i'm new to VSCode

When providing Route with {id}, the generated block is empty :

/**
 * 
 */
#[Route('/pages/show/{id}', name: 'page.show', methods: ['GET'])]
public function show(PageRepository $repository, int $id): Response
{
    return $this->render('pages/admin/page.index.html.twig', [
        'controller_name' => 'TestController',
    ]);
}

As soon as i remove the {id} parameter, the block is generated as expected :

/**
 * Undocumented function
 *
 * @param PageRepository $repository
 * @param integer $id
 * @return Response
 */
#[Route('/pages/show', name: 'page.show', methods: ['GET'])]
public function show(PageRepository $repository, int $id): Response
{
    return $this->render('pages/admin/page.index.html.twig', [
        'controller_name' => 'TestController',
    ]);
}

tested in a fresh install of VSCode [v1.66] with only PHP Intelephense [v1.8.2] and PHP DocBlocker [v2.7.0] installed

Is there a setting to change to obtain the expected DocBlock ?

Thanks

youpilai avatar Apr 01 '22 10:04 youpilai

The plugin wasn't really designed to support the annotation you are using it expects that the function you are attempting to docblock is on the line below not two lines below which is why you are seeing unexpected behaviour.

Most frameworks have a way of doing route annotation inside a docblock perhaps there is an alternative way to declare it.

neild3r avatar May 17 '22 12:05 neild3r