From ba1dd60e1963c9fab39ffa092de94ef8656cebd5 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Tue, 27 Aug 2024 02:00:10 +0200 Subject: [PATCH] [BUGFIX] Fix type errors in PHP strict mode This is the backport of #664. --- CHANGELOG.md | 1 + src/Value/Size.php | 2 +- tests/ParserTest.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97d58097..ad908668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Fixed +- Fix type errors in PHP strict mode (#695) - Fix comment parsing to support multiple comments (#671) ## 8.6.0 diff --git a/src/Value/Size.php b/src/Value/Size.php index 5b5ab772..648c9a60 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -223,7 +223,7 @@ public function render(OutputFormat $oOutputFormat) $l = localeconv(); $sPoint = preg_quote($l['decimal_point'], '/'); $sSize = preg_match("/[\d\.]+e[+-]?\d+/i", (string)$this->fSize) - ? preg_replace("/$sPoint?0+$/", "", sprintf("%f", $this->fSize)) : $this->fSize; + ? preg_replace("/$sPoint?0+$/", "", sprintf("%f", $this->fSize)) : (string)$this->fSize; return preg_replace(["/$sPoint/", "/^(-?)0\./"], ['.', '$1.'], $sSize) . ($this->sUnit === null ? '' : $this->sUnit); } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 036fd033..200dcba8 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -279,7 +279,7 @@ public function specificity() new Selector('ol li::before', true), ], $oDoc->getSelectorsBySpecificity('< 100')); self::assertEquals([new Selector('li.green', true)], $oDoc->getSelectorsBySpecificity('11')); - self::assertEquals([new Selector('ol li::before', true)], $oDoc->getSelectorsBySpecificity(3)); + self::assertEquals([new Selector('ol li::before', true)], $oDoc->getSelectorsBySpecificity('3')); } /**