Skip to content

Commit 15d2acb

Browse files
Merge branch '4.2'
* 4.2: [HttpFoundation] fix tests [Routing] fix trailing slash matching with empty-matching trailing vars [Routing] fix matching trailing vars with defaults [Validator] fix LegacyTranslatorProxy call method with Translator component only bumped Symfony version to 4.2.8 updated VERSION for 4.2.7 updated CHANGELOG for 4.2.7 bumped Symfony version to 3.4.27 updated VERSION for 3.4.26 updated CHANGELOG for 3.4.26
2 parents 3159201 + 058b937 commit 15d2acb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

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)