8000 [Validator] fix LegacyTranslatorProxy · symfony/symfony@56e5cfb · GitHub
[go: up one dir, main page]

Skip to content

Commit 56e5cfb

Browse files
[Validator] fix LegacyTranslatorProxy
1 parent cc497a5 commit 56e5cfb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,26 @@ class LegacyTranslatorProxy implements LegacyTranslatorInterface, TranslatorInte
2222
{
2323
private $translator;
2424

25-
public function __construct(TranslatorInterface $translator)
25+
/**
26+
* @param LegacyTranslatorInterface|TranslatorInterface $translator
27+
*/
28+
public function __construct($translator)
2629
{
30+
if (!$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
31+
throw new \InvalidArgumentException(sprintf('The translator passed to "%s()" must implement "%s" or "%s".', __METHOD__, TranslatorInterface::class, LegacyTranslatorInterface::class));
32+
}
33+
2734
if (!$translator instanceof LocaleAwareInterface) {
2835
throw new \InvalidArgumentException(sprintf('The translator passed to "%s()" must implement "%s".', __METHOD__, LocaleAwareInterface::class));
2936
}
37+
3038
$this->translator = $translator;
3139
}
3240

33-
public function getTranslator(): TranslatorInterface
41+
/**
42+
* @return LegacyTranslatorInterface|TranslatorInterface
43+
*/
44+
public function getTranslator()
3445
{
3546
return $this->translator;
3647
}

0 commit comments

Comments
 (0)
0