Skip to content

Preserve author-added empty lines between promoted constructor properties - #159

Merged
TomasVotruba merged 1 commit into
mainfrom
preserve-empty-lines-standalone-promoted-property
Oct 7, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
preserve-empty-lines-standalone-promoted-property

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Problem

StandaloneLinePromotedPropertyFixer collapsed intentional empty lines between promoted constructor properties. After each comma, TokensNewliner::breakItems() forced exactly one newline via ensureWhitespaceAtIndex(), wiping any blank line the author added to visually group #[Autowire(...)] properties.

Example that got mangled:

public function __construct(
    private DeviceDetectorFactoryInterface $deviceDetectorFactory,

    #[Autowire(env: 'float:MAUTIC_BOT_HELPER_BOT_RATIO_THRESHOLD')]
    private float $botRatioThreshold = 0.6,
) {
}

Fix

Skip whitespace normalization after a comma when the following whitespace already contains a blank line (2+ line endings). Single-line argument lists are still broken onto standalone lines as before.

Added fixture covering empty lines between attributed promoted properties.

@TomasVotruba
TomasVotruba merged commit 765bf70 into main Oct 7, 2026
19 checks passed
@TomasVotruba
TomasVotruba deleted the preserve-empty-lines-standalone-promoted-property branch October 7, 2026 19:34
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