Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b1f3284

Browse filesBrowse files
[Validator] fix LegacyTranslatorProxy
1 parent cc497a5 commit b1f3284
Copy full SHA for b1f3284

File tree

Expand file treeCollapse file tree

1 file changed

+14
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Util/LegacyTranslatorProxy.php
+14-3Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.