From b53c79af3b6513d19e1d82a43b227fee073a2de4 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 31 Jan 2025 15:42:08 +0100 Subject: [PATCH] [CLEANUP] Improve readability of `instanceof` calls - use paranthesis for negated `instanceof` calls - use `assertInstanceOf` in the tests --- src/Rule/Rule.php | 2 +- src/Value/Color.php | 2 +- tests/ParserTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index 9375cef3..0fb9d494 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -206,7 +206,7 @@ public function addValue($mValue, $sType = ' '): void if (!\is_array($mValue)) { $mValue = [$mValue]; } - if (!$this->mValue instanceof RuleValueList || $this->mValue->getListSeparator() !== $sType) { + if (!($this->mValue instanceof RuleValueList) || $this->mValue->getListSeparator() !== $sType) { $mCurrentValue = $this->mValue; $this->mValue = new RuleValueList($sType, $this->lineNumber); if ($mCurrentValue) { diff --git a/src/Value/Color.php b/src/Value/Color.php index b657d66d..8b913d54 100644 --- a/src/Value/Color.php +++ b/src/Value/Color.php @@ -260,7 +260,7 @@ private function getRealName(): string private function allComponentsAreNumbers(): bool { foreach ($this->aComponents as $component) { - if (!$component instanceof Size || $component->getUnit() !== null) { + if (!($component instanceof Size) || $component->getUnit() !== null) { return false; } } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index fbff74e8..bdd1a1f4 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -97,7 +97,7 @@ public function colorParsing(): void { $document = self::parsedStructureForFile('colortest'); foreach ($document->getAllRuleSets() as $ruleSet) { - if (!$ruleSet instanceof DeclarationBlock) { + if (!($ruleSet instanceof DeclarationBlock)) { continue; } $selectors = $ruleSet->getSelectors(); @@ -405,7 +405,7 @@ public function ruleGetters(): void self::assertSame('background-color', $backgroundHeaderRules[1]->getRule()); $backgroundHeaderRules = $headerBlock->getRulesAssoc('background-'); self::assertCount(1, $backgroundHeaderRules); - self::assertTrue($backgroundHeaderRules['background-color']->getValue() instanceof Color); + self::assertInstanceOf(Color::class, $backgroundHeaderRules['background-color']->getValue()); self::assertSame('rgba', $backgroundHeaderRules['background-color']->getValue()->getColorDescription()); $headerBlock->removeRule($backgroundHeaderRules['background-color']); $backgroundHeaderRules = $headerBlock->getRules('background-');