From 03a8dd679702947095ae83a890117c759499a275 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 31 Jan 2025 15:38:58 +0100 Subject: [PATCH] [CLEANUP] Avoid Hungarian notation for `iKey` Part of #756 --- src/CSSList/CSSList.php | 20 ++++++++++---------- src/RuleSet/DeclarationBlock.php | 10 +++++----- src/RuleSet/RuleSet.php | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/CSSList/CSSList.php b/src/CSSList/CSSList.php index 898983cf..be05b94f 100644 --- a/src/CSSList/CSSList.php +++ b/src/CSSList/CSSList.php @@ -315,9 +315,9 @@ public function insertBefore($item, $sibling): void */ public function remove($itemToRemove) { - $iKey = \array_search($itemToRemove, $this->contents, true); - if ($iKey !== false) { - unset($this->contents[$iKey]); + $key = \array_search($itemToRemove, $this->contents, true); + if ($key !== false) { + unset($this->contents[$key]); return true; } return false; @@ -334,12 +334,12 @@ public function remove($itemToRemove) */ public function replace($oldItem, $newItem) { - $iKey = \array_search($oldItem, $this->contents, true); - if ($iKey !== false) { + $key = \array_search($oldItem, $this->contents, true); + if ($key !== false) { if (\is_array($newItem)) { - \array_splice($this->contents, $iKey, 1, $newItem); + \array_splice($this->contents, $key, 1, $newItem); } else { - \array_splice($this->contents, $iKey, 1, [$newItem]); + \array_splice($this->contents, $key, 1, [$newItem]); } return true; } @@ -371,7 +371,7 @@ public function removeDeclarationBlockBySelector($mSelector, $bRemoveAll = false if (!\is_array($mSelector)) { $mSelector = \explode(',', $mSelector); } - foreach ($mSelector as $iKey => &$mSel) { + foreach ($mSelector as $key => &$mSel) { if (!($mSel instanceof Selector)) { if (!Selector::isValid($mSel)) { throw new UnexpectedTokenException( @@ -383,12 +383,12 @@ public function removeDeclarationBlockBySelector($mSelector, $bRemoveAll = false $mSel = new Selector($mSel); } } - foreach ($this->contents as $iKey => $item) { + foreach ($this->contents as $key => $item) { if (!($item instanceof DeclarationBlock)) { continue; } if ($item->getSelectors() == $mSelector) { - unset($this->contents[$iKey]); + unset($this->contents[$key]); if (!$bRemoveAll) { return; } diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index c0c26fc5..4d87bd83 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -96,7 +96,7 @@ public function setSelectors($mSelector, $oList = null): void } else { $this->aSelectors = \explode(',', $mSelector); } - foreach ($this->aSelectors as $iKey => $mSelector) { + foreach ($this->aSelectors as $key => $mSelector) { if (!($mSelector instanceof Selector)) { if ($oList === null || !($oList instanceof KeyFrame)) { if (!Selector::isValid($mSelector)) { @@ -106,7 +106,7 @@ public function setSelectors($mSelector, $oList = null): void 'custom' ); } - $this->aSelectors[$iKey] = new Selector($mSelector); + $this->aSelectors[$key] = new Selector($mSelector); } else { if (!KeyframeSelector::isValid($mSelector)) { throw new UnexpectedTokenException( @@ -115,7 +115,7 @@ public function setSelectors($mSelector, $oList = null): void 'custom' ); } - $this->aSelectors[$iKey] = new KeyframeSelector($mSelector); + $this->aSelectors[$key] = new KeyframeSelector($mSelector); } } } @@ -131,9 +131,9 @@ public function removeSelector($mSelector): bool if ($mSelector instanceof Selector) { $mSelector = $mSelector->getSelector(); } - foreach ($this->aSelectors as $iKey => $selector) { + foreach ($this->aSelectors as $key => $selector) { if ($selector->getSelector() === $mSelector) { - unset($this->aSelectors[$iKey]); + unset($this->aSelectors[$key]); return true; } } diff --git a/src/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index 8888e9cd..458f0af5 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -230,9 +230,9 @@ public function removeRule($mRule): void if (!isset($this->aRules[$sRule])) { return; } - foreach ($this->aRules[$sRule] as $iKey => $rule) { + foreach ($this->aRules[$sRule] as $key => $rule) { if ($rule === $mRule) { - unset($this->aRules[$sRule][$iKey]); + unset($this->aRules[$sRule][$key]); } } } else {