Skip to content

Commit 770162a

Browse files
Merge branch '4.2' into 4.3
* 4.2: [Form] fix usage of legacy TranslatorInterface [Serializer] Fix DataUriNormalizer docblock & composer suggest section
2 parents 5c7b4a0 + 0364135 commit 770162a

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/Symfony/Component/Form/Extension/Core/Type/FileType.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
use Symfony\Component\Form\FormView;
2121
use Symfony\Component\OptionsResolver\Options;
2222
use Symfony\Component\OptionsResolver\OptionsResolver;
23-
use Symfony\Component\Translation\TranslatorInterface;
23+
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
24+
use Symfony\Contracts\Translation\TranslatorInterface;
2425

2526
class FileType extends AbstractType
2627
{
@@ -35,8 +36,14 @@ class FileType extends AbstractType
3536

3637
private $translator;
3738

38-
public function __construct(TranslatorInterface $translator = null)
39+
/**
40+
* @param TranslatorInterface|null $translator
41+
*/
42+
public function __construct($translator = null)
3943
{
44+
if (null !== $translator && !$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
45+
throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
46+
}
4047
$this->translator = $translator;
4148
}
4249

src/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Form\RequestHandlerInterface;
1818
use Symfony\Component\HttpFoundation\File\File;
1919
use Symfony\Component\HttpFoundation\File\UploadedFile;
20-
use Symfony\Component\Translation\TranslatorInterface;
20+
use Symfony\Contracts\Translation\TranslatorInterface;
2121

2222
class FileTypeTest extends BaseTypeTest
2323
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
3434
];
3535

3636
/**
37-
* @var MimeTypeGuesserInterface
37+
* @var MimeTypeGuesserInterface|null
3838
*/
3939
private $mimeTypeGuesser;
4040

src/Symfony/Component/Serializer/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"symfony/yaml": "For using the default YAML mapping loader.",
4646
"symfony/config": "For using the XML mapping loader.",
4747
"symfony/property-access": "For using the ObjectNormalizer.",
48-
"symfony/http-foundation": "To use the DataUriNormalizer.",
48+
"symfony/http-foundation": "For using a MIME type guesser within the DataUriNormalizer.",
4949
"doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.",
5050
"doctrine/cache": "For using the default cached annotation reader and metadata cache."
5151
},

0 commit comments

Comments
 (0)