Skip to content

Dealing with erroneous docblock ? (request for feedback/comment) #3565

@drupol

Description

@drupol

Description
Hello,

I just took over a new project from a client and it's based on API Platform.
When running bin/console cache:clear -vvv, I get this issue: https://del.dog/unupowyghe.txt

It took me a while to figure out where was the issue. I added a couple of var_dump() to spot the erroneous docblock.

The issue was in the following entity (I stripped down the code to the relevant part):

<?php

namespace App\Entity;

class Foo
{
    /**
     * @var
     * @ORM\Id
     * @ORM\Column(name="FOO_ID", type="integer")
     */
    private $fooId;
}

Basically there is an error which is triggered because the tag @var without a value is an InvalidTag. As InvalidTag doesn't have the method getDescription(), it fails.

I was wondering what would be the best way to fix this for the people who, like me, are spending hours finding where such an issue could be in a huge project.

I investigated phpDocumentor/ReflectionDocBlock and changed InvalidTag so it extends BaseTag, and thus, have a getDescription() method.

Of course, when I do that, I can clear the cache of the project and I get no more issue.

Unfortunately, I have the feeling that this is not the proper way to fix the issue.

I think the best way to fix this would be to return a proper error to the user, a bit like this:

"InvalidTagException: The property tag @var cannot be empty, fix it or remove it in file [FILE] at property [PROPERTY]."

So, I don't mind taking care of the issue, but before, I'd like to have some feedback and some directions if possible.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions