8000 bug #31164 [Validator] fix LegacyTranslatorProxy (nicolas-grekas) · symfony/symfony@5379e73 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 script crossorigin="anonymous" defer="defer" type="application/javascript" src="https://github.githubassets.com/assets/sessions-1e75b15ae60a.js">

Commit 5379e73

Browse files
bug #31164 [Validator] fix LegacyTranslatorProxy (nicolas-grekas)
This PR was merged into the 4.2 branch. Discussion ---------- [Validator] fix LegacyTranslatorProxy | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31161 | License | MIT | Doc PR | - Commits ------- b1f3284 [Validator] fix LegacyTranslatorProxy
2 parents cc497a5 + b1f3284 commit 5379e73

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

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

Lines changed: 14 additions & 3 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
{
27-
if (!$translator instanceof LocaleAwareInterface) {
30+
if ($translator instanceof LegacyTranslatorInterface) {
31+
// no-op
32+
} elseif (!$translator instanceof TranslatorInterface) {
33+
throw new \InvalidArgumentException(sprintf('The translator passed to "%s()" must implement "%s" or "%s".', __METHOD__, TranslatorInterface::class, LegacyTranslatorInterface::class));
34+
} elseif (!$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