Skip to content

Printer: indent a new tag like the other tags - #329

Merged
ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:new-tag-indentation
Oct 26, 2026
Merged

ondrejmirtes merged 1 commit into
phpstan:2.3.xfrom
ondrejmirtes:new-tag-indentation

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

When printFormatPreserving() adds a child to a PHPDoc, it uses the largest indentation after * in the PHPDoc. The next lines of a multi-line description often have a larger indentation, so the new tag gets it too:

/**
 * @param int $foo multi
 *          line description
 *    @throws Exception
 */

Now the printer uses the indentation of the line where the last existing child starts:

/**
 * @param int $foo multi
 *          line description
 * @throws Exception
 */

If no child starts on its own line, e.g. /** @var int $x */, the printer uses the old logic.

@ondrejmirtes
ondrejmirtes force-pushed the new-tag-indentation branch 2 times, most recently from 368effa to 71d6613 Compare October 26, 2026 19:34
When the printer added a child to a PHPDoc, it used the largest
indentation after the asterisk in the PHPDoc. The next lines of a
multi-line description often have a larger indentation, so the new
tag got it too.

Now the printer uses the indentation of the line where the last
existing child starts.

Amp-Thread-ID: https://ampcode.com/threads/T-01a17930-0285-73c5-a957-4325c77aa1b2
@ondrejmirtes
ondrejmirtes merged commit 6b23b73 into phpstan:2.3.x Oct 26, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant