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;