From 08691564ab642af585965ebcfeb72bec585187f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bar=C3=A1=C5=A1ek?= Date: Thu, 4 Mar 2021 14:12:45 +0100 Subject: [PATCH] TranslatorFilter: Use mixed annotation --- src/Translator/TranslatorFilter.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Translator/TranslatorFilter.php b/src/Translator/TranslatorFilter.php index 5918037..d60dfa2 100644 --- a/src/Translator/TranslatorFilter.php +++ b/src/Translator/TranslatorFilter.php @@ -16,17 +16,19 @@ public function __construct( } - /** - * @param string|object $haystack - */ - public function __invoke(FilterInfo $info, $haystack): string + public function __invoke(FilterInfo $info, mixed $haystack): string { if (is_object($haystack)) { if (method_exists($haystack, '__toString')) { $haystack = (string) $haystack; } else { - throw new \InvalidArgumentException('Object "' . \get_class($haystack) . '" can not be serialized to string, because do not implement "__toString" method.'); + throw new \InvalidArgumentException( + 'Object "' . \get_debug_type($haystack) . '" can not be serialized to string, ' + . 'because do not implement "__toString" method.', + ); } + } elseif (is_scalar($haystack)) { + $haystack = (string) $haystack; } return ($this->translator ?? $this->getDefaultTranslator())->translate($haystack);