Skip to content

Commit 4b56a42

Browse files
committed
fix psalm
1 parent be3af30 commit 4b56a42

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Component/Serializer/Normalizer/TranslatableNormalizer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Serializer\Normalizer;
1313

14+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
1415
use Symfony\Contracts\Translation\TranslatableInterface;
1516
use Symfony\Contracts\Translation\TranslatorInterface;
1617

@@ -30,10 +31,14 @@ public function __construct(
3031
}
3132

3233
/**
33-
* @param TranslatableInterface $object
34+
* @throws InvalidArgumentException
3435
*/
3536
public function normalize(mixed $object, string $format = null, array $context = []): string
3637
{
38+
if (!$object instanceof TranslatableInterface) {
39+
throw new InvalidArgumentException(sprintf('The object must implement the "%s".', TranslatableInterface::class));
40+
}
41+
3742
return $object->trans($this->translator, $context[self::NORMALIZATION_LOCALE_KEY] ?? $this->defaultContext[self::NORMALIZATION_LOCALE_KEY]);
3843
}
3944

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy