Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public function breakItems(BlockInfo $blockInfo, Tokens $tokens, int $kind): voi
continue;
}

if ($this->isFollowedByEmptyLine($tokens, $i)) {
continue;
}

$tokens->ensureWhitespaceAtIndex($i + 1, 0, $newlineIndentWhitespace);
}
}
Expand Down Expand Up @@ -113,4 +117,20 @@ private function isFollowedByComment(Tokens $tokens, int $i): bool

return $nextNextToken->isComment();
}

/**
* Keep author-added empty line between items
*
* @param Tokens<Token> $tokens
*/
private function isFollowedByEmptyLine(Tokens $tokens, int $i): bool
{
$nextToken = $tokens[$i + 1];
if (! $nextToken->isWhitespace()) {
return false;
}

$lineEnding = $this->whitespacesFixerConfig->getLineEnding();
return \substr_count($nextToken->getContent(), $lineEnding) >= 2;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Symplify\CodingStandard\Tests\Fixer\Spacing\StandaloneLinePromotedPropertyFixer\Fixture;

final class SkipEmptyLinesBetweenProperties
{
public function __construct(
private int $age,

#[SomeAttribute]
private string $name = 'default',

#[SomeAttribute]
private array $items = [],
) {
}
}
Loading