phpdoc-parser icon indicating copy to clipboard operation
phpdoc-parser copied to clipboard

Rework comments support for pretty-printing

Open ondrejmirtes opened this issue 9 months ago • 0 comments

The current implementation (https://github.com/phpstan/phpdoc-parser/pull/264) has some drawbacks:

  • Printing with preserving format is pretty broken. For example, it does not notice when a comment is removed from a node.
  • The comment indexes are wrong, they are often out of bounds of the associated node. For example startIndex of node is 5, but its comment can start earlier, which causes problems in Printer
  • Comments are often associated with a weird node, for example:
array{
	// a is for apple
	a: int,
}

Associates the comment with the item keyName, not item itself.

This PR tries to fix it but absence of these fixes doesn't prevent us from releasing phpdoc-parser 2.1.0.

ondrejmirtes avatar Feb 19 '25 13:02 ondrejmirtes