From d7dae0d3b962e3a12abbd9ab271b45268d618243 Mon Sep 17 00:00:00 2001 From: raxbg Date: Tue, 12 Nov 2019 16:47:36 +0200 Subject: [PATCH 1/2] Fix CSSList::replace with object as the new value --- lib/Sabberworm/CSS/CSSList/CSSList.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Sabberworm/CSS/CSSList/CSSList.php b/lib/Sabberworm/CSS/CSSList/CSSList.php index 5def89a0..06566056 100644 --- a/lib/Sabberworm/CSS/CSSList/CSSList.php +++ b/lib/Sabberworm/CSS/CSSList/CSSList.php @@ -238,10 +238,14 @@ public function remove($oItemToRemove) { * Replaces an item from the CSS list. * @param RuleSet|Import|Charset|CSSList $oItemToRemove May be a RuleSet (most likely a DeclarationBlock), a Import, a Charset or another CSSList (most likely a MediaQuery) */ - public function replace($oOldItem, $oNewItem) { + public function replace($oOldItem, $mNewItem) { $iKey = array_search($oOldItem, $this->aContents, true); if ($iKey !== false) { - array_splice($this->aContents, $iKey, 1, $oNewItem); + if (is_array($mNewItem)) { + array_splice($this->aContents, $iKey, 1, $mNewItem); + } else { + array_splice($this->aContents, $iKey, 1, [$mNewItem]); + } return true; } return false; From 0d8f3bde71afa6e7c3134a15be1d8b35c4bc581d Mon Sep 17 00:00:00 2001 From: raxbg Date: Tue, 12 Nov 2019 17:02:21 +0200 Subject: [PATCH 2/2] Fix PHP 5.3 compatibility --- lib/Sabberworm/CSS/CSSList/CSSList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Sabberworm/CSS/CSSList/CSSList.php b/lib/Sabberworm/CSS/CSSList/CSSList.php index 06566056..0665dae1 100644 --- a/lib/Sabberworm/CSS/CSSList/CSSList.php +++ b/lib/Sabberworm/CSS/CSSList/CSSList.php @@ -244,7 +244,7 @@ public function replace($oOldItem, $mNewItem) { if (is_array($mNewItem)) { array_splice($this->aContents, $iKey, 1, $mNewItem); } else { - array_splice($this->aContents, $iKey, 1, [$mNewItem]); + array_splice($this->aContents, $iKey, 1, array($mNewItem)); } return true; }