From ebc7061251915bda547e70a85e16f0c621bf7bad Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 13 Nov 2025 10:17:12 +0100 Subject: [PATCH] [CLEANUP] Reformat the code with the PER-2 configuration Also switch a test string from heredoc to a string literal to avoid the string from getting indented. --- src/RuleSet/DeclarationBlock.php | 12 +++++------ tests/Comment/CommentTest.php | 14 +++++++++---- tests/OutputFormatTest.php | 34 +++++++++++++++++++++----------- tests/ParserTest.php | 8 ++++---- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index 4d077546..5dee1b54 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -216,9 +216,9 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void } /** - * @see RuleSet::getRules() - * * @return array, Rule> + * + * @see RuleSet::getRules() */ public function getRules(?string $searchPattern = null): array { @@ -226,9 +226,9 @@ public function getRules(?string $searchPattern = null): array } /** - * @see RuleSet::setRules() - * * @param array $rules + * + * @see RuleSet::setRules() */ public function setRules(array $rules): void { @@ -236,9 +236,9 @@ public function setRules(array $rules): void } /** - * @see RuleSet::getRulesAssoc() - * * @return array + * + * @see RuleSet::getRulesAssoc() */ public function getRulesAssoc(?string $searchPattern = null): array { diff --git a/tests/Comment/CommentTest.php b/tests/Comment/CommentTest.php index 52c3de55..6c36dbdc 100644 --- a/tests/Comment/CommentTest.php +++ b/tests/Comment/CommentTest.php @@ -19,7 +19,8 @@ final class CommentTest extends TestCase public function keepCommentsInOutput(): void { $cssDocument = TestsParserTest::parsedStructureForFile('comments'); - self::assertSame('/** Number 11 **/ + self::assertSame( + '/** Number 11 **/ /** * Comments @@ -43,7 +44,9 @@ public function keepCommentsInOutput(): void position: absolute; } } -', $cssDocument->render(OutputFormat::createPretty())); +', + $cssDocument->render(OutputFormat::createPretty()) + ); self::assertSame( '/** Number 11 **//**' . "\n" . ' * Comments' . "\n" @@ -61,7 +64,8 @@ public function keepCommentsInOutput(): void public function stripCommentsFromOutput(): void { $css = TestsParserTest::parsedStructureForFile('comments'); - self::assertSame(' + self::assertSame( + ' @import url("some/url.css") screen; .foo, #bar { @@ -73,7 +77,9 @@ public function stripCommentsFromOutput(): void position: absolute; } } -', $css->render(OutputFormat::createPretty()->setRenderComments(false))); +', + $css->render(OutputFormat::createPretty()->setRenderComments(false)) + ); self::assertSame( '@import url("some/url.css") screen;' . '.foo,#bar{background-color:#000}' diff --git a/tests/OutputFormatTest.php b/tests/OutputFormatTest.php index 3a8deb30..30737ddf 100644 --- a/tests/OutputFormatTest.php +++ b/tests/OutputFormatTest.php @@ -18,8 +18,7 @@ final class OutputFormatTest extends TestCase /** * @var string */ - private const TEST_CSS = <<setSpaceBetweenRules("\n") ->setSpaceAfterRules("\n"); - self::assertSame('.main, .test { + self::assertSame( + '.main, .test { font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif; background: white; } @@ -195,7 +194,9 @@ public function spaceRules(): void background-size: 100% 100%; font-size: 1.3em; background-color: #fff; - }}', $this->document->render($outputFormat)); + }}', + $this->document->render($outputFormat) + ); } /** @@ -208,12 +209,15 @@ public function spaceBlocks(): void ->setSpaceBetweenBlocks("\n") ->setSpaceAfterBlocks("\n"); - self::assertSame(' + self::assertSame( + ' .main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;} @media screen { .main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;} } -', $this->document->render($outputFormat)); +', + $this->document->render($outputFormat) + ); } /** @@ -229,7 +233,8 @@ public function spaceBoth(): void ->setSpaceBetweenBlocks("\n") ->setSpaceAfterBlocks("\n"); - self::assertSame(' + self::assertSame( + ' .main, .test { font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif; background: white; @@ -241,7 +246,9 @@ public function spaceBoth(): void background-color: #fff; } } -', $this->document->render($outputFormat)); +', + $this->document->render($outputFormat) + ); } /** @@ -273,7 +280,8 @@ public function indentation(): void ->setSpaceAfterBlocks("\n") ->setIndentation(''); - self::assertSame(' + self::assertSame( + ' .main, .test { font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif; background: white; @@ -285,7 +293,9 @@ public function indentation(): void background-color: #fff; } } -', $this->document->render($outputFormat)); +', + $this->document->render($outputFormat) + ); } /** diff --git a/tests/ParserTest.php b/tests/ParserTest.php index b80280a7..a1da3a2e 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -571,10 +571,10 @@ public function comments(): void { $document = self::parsedStructureForFile('comments'); $expected = <<render()); }