Skip to content

Commit

Permalink
SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing: Fixed fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Dec 13, 2022
1 parent 1123109 commit e7898e2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public function process(File $phpcsFile, $attributeOpenerPointer): void
}

if ($areOnSameLine) {
$indentation = IndentationHelper::getIndentation($phpcsFile, $attributeOpenerPointer);
$indentation = IndentationHelper::getIndentation(
$phpcsFile,
TokenHelper::findFirstNonWhitespaceOnLine($phpcsFile, $pointerAfter)
);

$phpcsFile->fixer->beginChangeset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ public function testErrors(): void
{
$report = self::checkFile(__DIR__ . '/data/attributeAndTargetSpacingErrors.php');

self::assertSame(4, $report->getErrorCount());
self::assertSame(6, $report->getErrorCount());

self::assertSniffError($report, 6, AttributeAndTargetSpacingSniff::CODE_INCORRECT_LINES_COUNT_BETWEEN_ATTRIBUTE_AND_TARGET);
self::assertSniffError($report, 12, AttributeAndTargetSpacingSniff::CODE_INCORRECT_LINES_COUNT_BETWEEN_ATTRIBUTE_AND_TARGET);
self::assertSniffError($report, 18, AttributeAndTargetSpacingSniff::CODE_INCORRECT_LINES_COUNT_BETWEEN_ATTRIBUTE_AND_TARGET);
self::assertSniffError($report, 22, AttributeAndTargetSpacingSniff::CODE_INCORRECT_LINES_COUNT_BETWEEN_ATTRIBUTE_AND_TARGET);
self::assertSniffError($report, 28, AttributeAndTargetSpacingSniff::CODE_INCORRECT_LINES_COUNT_BETWEEN_ATTRIBUTE_AND_TARGET);
self::assertSniffError($report, 29, AttributeAndTargetSpacingSniff::CODE_INCORRECT_LINES_COUNT_BETWEEN_ATTRIBUTE_AND_TARGET);

self::assertAllFixedInFile($report);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ public function method(
{
}

public function __construct(
#[ORM\Column(unique: true)]
protected string $name,
#[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'cities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')]
protected State|null $state = null,
) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ public function method(
{
}

public function __construct(
#[ORM\Column(unique: true)] protected string $name,
#[ORM\Cache] #[ORM\ManyToOne(targetEntity: 'State', inversedBy: 'cities')] #[ORM\JoinColumn(name: 'state_id', referencedColumnName: 'id')] protected State|null $state = null,
) {
}

}

0 comments on commit e7898e2

Please sign in to comment.