Printer: keep the "*" prefix on continuation lines of multi-line text - #318
Open
janedbal wants to merge 1 commit into
Open
Printer: keep the "*" prefix on continuation lines of multi-line text#318janedbal wants to merge 1 commit into
janedbal wants to merge 1 commit into
Conversation
PhpDocParser::parseText() and the description parsers join continuation lines with a bare newline and drop the " * " prefix. Printer::print() emitted that text verbatim, so a changed or inserted multi-line PhpDocTextNode or tag description printed continuation lines without the asterisk. printNodeFormatPreserving() falls back to print() when a string sub-node changes, so printFormatPreserving() had the same problem. print() now re-inserts the line prefix at every newline inside a text node or tag value. The default prefix is "\n * ". printFormatPreserving() uses the newline and before-asterisk indentation detected from the original tokens. The lexer strips exactly one space after the asterisk, so the prefix ends with a single space and any deeper indentation stays in the text. Blank lines print as " *" without a trailing space. Fixes phpstan#317 Co-Authored-By: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #317
PhpDocParser::parseText()and the description parsers join continuation lines with a bare\nand drop the*prefix.Printer::print()emitted that text verbatim, so a changed or inserted multi-linePhpDocTextNodeor tag description printed continuation lines without the asterisk.printNodeFormatPreserving()falls back toprint()when a string sub-node changes, soprintFormatPreserving()had the same problem.Change
print()re-inserts a line prefix at every newline inside aPhpDocTextNodeand inside a printedPhpDocTagValueNode. The default prefix is"\n * ".printFormatPreserving()sets the prefix from the original tokens: detected newline plus the before-asterisk indentation, followed by*. The lexer strips exactly one space after the asterisk (TOKEN_PHPDOC_EOL), so deeper indentation is still part of the text and is kept as is.*without a trailing space, same as an emptyPhpDocTextNodechild.Tests
dataPrintFormatPreserving: change a multi-line text node with a blank line inside and a multi-line@paramdescription; same with 5-space indentation; insert a new multi-line text node.dataPrintPhpDocNode:print()of a node with a multi-line text node, an empty text node and a multi-line description.make checkpasses.Claude
Co-Authored-By: Claude Code