claytonrcarter / tree-sitter-phpdoc

PHPDoc grammar for tree-sitter
22 stars 10 forks source link

@var description is not parsed if no variable name is used #6

Closed mikehaertl closed 2 years ago

mikehaertl commented 2 years ago

If @var is not followed by a variable name (like in a property declaration in a class) the description is not parsed as @text but as comment:

ts_var_string

This gets especially weird if the description contains linebreaks:

ts_phpdoc_linebreak

claytonrcarter commented 2 years ago

Yes, this makes sense for the moment. @var requires a variable name, so leaving it out means tree-sitter will not recognize that tag and generate a parse error. The phpDoc docs for @var state

The @var tag MUST contain the name of the element it documents. An exception to this is when a declaration only refers to a single property or constant. In that case, the name of the property or constant MAY be omitted.

And I have implemented this for the former, not the latter. psalm and phpstan also encourage/allow the element name to be omitted, and I have some local changes that support that, but they're not pushed yet.

claytonrcarter commented 2 years ago

I believe that this is now fixed in f54431c. Thanks!

mikehaertl commented 2 years ago

Confirmed. Thanks for the quick fix.