From 72bc4f542dd413f88e7b7d6925ae7e087693fb65 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 6 Feb 2024 00:57:20 +0100 Subject: [PATCH] [CLEANUP] Make variable acces in `DeclarationBlock` more obvious --- config/phpstan-baseline.neon | 5 ----- src/RuleSet/DeclarationBlock.php | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index b730548c..243e36c4 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -10,11 +10,6 @@ parameters: count: 2 path: ../src/RuleSet/DeclarationBlock.php - - - message: "#^Variable \\$oRule might not be defined\\.$#" - count: 2 - path: ../src/RuleSet/DeclarationBlock.php - - message: "#^Variable \\$oVal might not be defined\\.$#" count: 1 diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index de487bc1..b218bd8c 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -565,6 +565,7 @@ public function expandListStyleShorthand() public function createShorthandProperties(array $aProperties, $sShorthand) { $aRules = $this->getRulesAssoc(); + $oRule = null; $aNewValues = []; foreach ($aProperties as $sProperty) { if (!isset($aRules[$sProperty])) { @@ -585,7 +586,7 @@ public function createShorthandProperties(array $aProperties, $sShorthand) $this->removeRule($sProperty); } } - if (count($aNewValues)) { + if ($aNewValues !== [] && $oRule instanceof Rule) { $oNewRule = new Rule($sShorthand, $oRule->getLineNo(), $oRule->getColNo()); foreach ($aNewValues as $mValue) { $oNewRule->addValue($mValue);