From 8b33f19e8eb9f03b715173a009ddc57137827230 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 --- src/Comment/Comment.php | 2 +- src/RuleSet/DeclarationBlock.php | 12 +++---- tests/Comment/CommentTest.php | 14 +++++--- tests/OutputFormatTest.php | 52 ++++++++++++++++----------- tests/Unit/Value/CalcFunctionTest.php | 1 + 5 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/Comment/Comment.php b/src/Comment/Comment.php index 33188988f..6f29682c2 100644 --- a/src/Comment/Comment.php +++ b/src/Comment/Comment.php @@ -5,9 +5,9 @@ namespace Sabberworm\CSS\Comment; use Sabberworm\CSS\OutputFormat; -use Sabberworm\CSS\Renderable; use Sabberworm\CSS\Position\Position; use Sabberworm\CSS\Position\Positionable; +use Sabberworm\CSS\Renderable; class Comment implements Positionable, Renderable { diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index 8a0f4e487..043d860da 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -221,9 +221,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 { @@ -231,9 +231,9 @@ public function getRules(?string $searchPattern = null): array } /** - * @see RuleSet::setRules() - * * @param array $rules + * + * @see RuleSet::setRules() */ public function setRules(array $rules): void { @@ -241,9 +241,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 52c3de550..6c36dbdcf 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 104ad7b5c..b1b589a53 100644 --- a/tests/OutputFormatTest.php +++ b/tests/OutputFormatTest.php @@ -16,18 +16,18 @@ final class OutputFormatTest extends TestCase { private const TEST_CSS = "\n" - . ".main, .test {\n" - . "\tfont: italic normal bold 16px/1.2 \"Helvetica\", Verdana, sans-serif;\n" - . "\tbackground: white;\n" - . "}\n" - . "\n" - . "@media screen {\n" - . "\t.main {\n" - . "\t\tbackground-size: 100% 100%;\n" - . "\t\tfont-size: 1.3em;\n" - . "\t\tbackground-color: #fff;\n" - . "\t}\n" - . "}\n"; + . ".main, .test {\n" + . "\tfont: italic normal bold 16px/1.2 \"Helvetica\", Verdana, sans-serif;\n" + . "\tbackground: white;\n" + . "}\n" + . "\n" + . "@media screen {\n" + . "\t.main {\n" + . "\t\tbackground-size: 100% 100%;\n" + . "\t\tfont-size: 1.3em;\n" + . "\t\tbackground-color: #fff;\n" + . "\t}\n" + . "}\n"; /** * @var Parser @@ -181,7 +181,8 @@ public function spaceRules(): void ->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; } @@ -189,7 +190,9 @@ public function spaceRules(): void background-size: 100% 100%; font-size: 1.3em; background-color: #fff; - }}', $this->document->render($outputFormat)); + }}', + $this->document->render($outputFormat) + ); } /** @@ -202,12 +205,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) + ); } /** @@ -223,7 +229,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; @@ -235,7 +242,9 @@ public function spaceBoth(): void background-color: #fff; } } -', $this->document->render($outputFormat)); +', + $this->document->render($outputFormat) + ); } /** @@ -267,7 +276,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; @@ -279,7 +289,9 @@ public function indentation(): void background-color: #fff; } } -', $this->document->render($outputFormat)); +', + $this->document->render($outputFormat) + ); } /** diff --git a/tests/Unit/Value/CalcFunctionTest.php b/tests/Unit/Value/CalcFunctionTest.php index f4907d477..65f23e131 100644 --- a/tests/Unit/Value/CalcFunctionTest.php +++ b/tests/Unit/Value/CalcFunctionTest.php @@ -47,6 +47,7 @@ public function parseSimpleCalc(): void self::assertSame(20.0, $components[2]->getSize()); self::assertSame('px', $components[2]->getUnit()); } + /** * @test */