diff --git a/CHANGELOG.md b/CHANGELOG.md index 7052cd6b2..85b7392cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ Please also have a look at our ### Fixed -- Use typesafe versions of PHP functions (#1379) +- Use typesafe versions of PHP functions (#1379, #1380) ### Documentation diff --git a/src/Value/Size.php b/src/Value/Size.php index 74e8baf7c..eac736d79 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -9,6 +9,9 @@ use Sabberworm\CSS\Parsing\UnexpectedEOFException; use Sabberworm\CSS\Parsing\UnexpectedTokenException; +use function Safe\preg_match; +use function Safe\preg_replace; + /** * A `Size` consists of a numeric `size` value and a unit. */ @@ -202,9 +205,9 @@ public function render(OutputFormat $outputFormat): string { $locale = \localeconv(); $decimalPoint = \preg_quote($locale['decimal_point'], '/'); - $size = \preg_match('/[\\d\\.]+e[+-]?\\d+/i', (string) $this->size) - ? \preg_replace("/$decimalPoint?0+$/", '', \sprintf('%f', $this->size)) : (string) $this->size; + $size = preg_match('/[\\d\\.]+e[+-]?\\d+/i', (string) $this->size) === 1 + ? preg_replace("/$decimalPoint?0+$/", '', \sprintf('%f', $this->size)) : (string) $this->size; - return \preg_replace(["/$decimalPoint/", '/^(-?)0\\./'], ['.', '$1.'], $size) . ($this->unit ?? ''); + return preg_replace(["/$decimalPoint/", '/^(-?)0\\./'], ['.', '$1.'], $size) . ($this->unit ?? ''); } }