Skip to content

Commit 400f3fd

Browse files
authored
[CLEANUP] Improve readability of instanceof calls (#856)
- Use parentheses for negated `instanceof` calls. - Use `assertInstanceOf` in the tests.
1 parent 3cd934a commit 400f3fd

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Rule/Rule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function addValue($mValue, $sType = ' '): void
206206
if (!\is_array($mValue)) {
207207
$mValue = [$mValue];
208208
}
209-
if (!$this->mValue instanceof RuleValueList || $this->mValue->getListSeparator() !== $sType) {
209+
if (!($this->mValue instanceof RuleValueList) || $this->mValue->getListSeparator() !== $sType) {
210210
$mCurrentValue = $this->mValue;
211211
$this->mValue = new RuleValueList($sType, $this->lineNumber);
212212
if ($mCurrentValue) {

src/Value/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private function getRealName(): string
260260
private function allComponentsAreNumbers(): bool
261261
{
262262
foreach ($this->aComponents as $component) {
263-
if (!$component instanceof Size || $component->getUnit() !== null) {
263+
if (!($component instanceof Size) || $component->getUnit() !== null) {
264264
return false;
265265
}
266266
}

tests/ParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function colorParsing(): void
9797
{
9898
$document = self::parsedStructureForFile('colortest');
9999
foreach ($document->getAllRuleSets() as $ruleSet) {
100-
if (!$ruleSet instanceof DeclarationBlock) {
100+
if (!($ruleSet instanceof DeclarationBlock)) {
101101
continue;
102102
}
103103
$selectors = $ruleSet->getSelectors();
@@ -405,7 +405,7 @@ public function ruleGetters(): void
405405
self::assertSame('background-color', $backgroundHeaderRules[1]->getRule());
406406
$backgroundHeaderRules = $headerBlock->getRulesAssoc('background-');
407407
self::assertCount(1, $backgroundHeaderRules);
408-
self::assertTrue($backgroundHeaderRules['background-color']->getValue() instanceof Color);
408+
self::assertInstanceOf(Color::class, $backgroundHeaderRules['background-color']->getValue());
409409
self::assertSame('rgba', $backgroundHeaderRules['background-color']->getValue()->getColorDescription());
410410
$headerBlock->removeRule($backgroundHeaderRules['background-color']);
411411
$backgroundHeaderRules = $headerBlock->getRules('background-');

0 commit comments

Comments
 (0)