From ecaa826c735dec6c8690df4415358425a9ebdd79 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Tue, 15 Feb 2022 16:08:52 +0200 Subject: [PATCH] Fix PHP 8.1 warning about the behavior change --- src/Escaper/AbstractEscaper.php | 4 +++- src/Escaper/HtmlEscaper.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Escaper/AbstractEscaper.php b/src/Escaper/AbstractEscaper.php index fc4f816..ddc760a 100644 --- a/src/Escaper/AbstractEscaper.php +++ b/src/Escaper/AbstractEscaper.php @@ -110,11 +110,13 @@ public function getEncoding() * * @param string $regex The regex to determine what characters to replace. * - * @return mixed The escaped value. + * @return string The escaped value. * */ protected function replace($raw, $regex) { + $raw = (string) $raw; + // pre-empt replacement if ($raw === '' || ctype_digit($raw)) { return $raw; diff --git a/src/Escaper/HtmlEscaper.php b/src/Escaper/HtmlEscaper.php index 4642e99..c05e98e 100644 --- a/src/Escaper/HtmlEscaper.php +++ b/src/Escaper/HtmlEscaper.php @@ -59,11 +59,13 @@ public function __construct($flags = null, $encoding = null) * * @param mixed $raw The value to be escaped. * - * @return mixed The escaped value. + * @return string The escaped value. * */ public function __invoke($raw) { + $raw = (string) $raw; + // pre-empt escaping if ($raw === '' || ctype_digit($raw)) { return $raw;