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 c703b35

Browse filesBrowse files
committed
[Serializer] Remove last deprecated/obsolete paths
1 parent e281087 commit c703b35
Copy full SHA for c703b35

File tree

Expand file treeCollapse file tree

12 files changed

+19
-124
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+19
-124
lines changed

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ Serializer
423423

424424
were removed, use the default context instead.
425425
* The `AbstractNormalizer::handleCircularReference()` method has two new `$format` and `$context` arguments.
426+
* Removed support for instantiating a `DataUriNormalizer` with a default MIME type guesser when the `symfony/mime` component isn't installed.
426427

427428
Translation
428429
-----------

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@
9393
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
9494
use Symfony\Component\Serializer\Encoder\DecoderInterface;
9595
use Symfony\Component\Serializer\Encoder\EncoderInterface;
96-
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
97-
use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer;
98-
use Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer;
9996
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
10097
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
10198
use Symfony\Component\Stopwatch\Stopwatch;
@@ -1280,19 +1277,6 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
12801277
{
12811278
$loader->load('serializer.xml');
12821279

1283-
if (!class_exists(DateIntervalNormalizer::class)) {
1284-
$container->removeDefinition('serializer.normalizer.dateinterval');
1285-
}
1286-
1287-
if (!class_exists(ConstraintViolationListNormalizer::class)) {
1288-
$container->removeDefinition('serializer.normalizer.constraint_violation_list');
1289-
}
1290-
1291-
if (!class_exists(ClassDiscriminatorFromClassMetadata::class)) {
1292-
$container->removeAlias('Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface');
1293-
$container->removeDefinition('serializer.mapping.class_discriminator_resolver');
1294-
}
1295-
12961280
$chainLoader = $container->getDefinition('serializer.mapping.chain_loader');
12971281

12981282
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {

‎src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,13 @@
1515
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1616
use Symfony\Component\Cache\Adapter\NullAdapter;
1717
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
18-
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
1918
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
2019
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
2120

2221
class SerializerCacheWarmerTest extends TestCase
2322
{
2423
public function testWarmUp()
2524
{
26-
if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
27-
$this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.');
28-
}
29-
3025
$loaders = [
3126
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
3227
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
@@ -48,10 +43,6 @@ public function testWarmUp()
4843

4944
public function testWarmUpWithoutLoader()
5045
{
51-
if (!class_exists(CacheClassMetadataFactory::class) || !method_exists(XmlFileLoader::class, 'getMappedClasses') || !method_exists(YamlFileLoader::class, 'getMappedClasses')) {
52-
$this->markTestSkipped('The Serializer default cache warmer has been introduced in the Serializer Component version 3.2.');
53-
}
54-
5546
$file = sys_get_temp_dir().'/cache-serializer-without-loader.php';
5647
@unlink($file);
5748

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,10 +1033,6 @@ public function testDataUriNormalizerRegistered()
10331033

10341034
public function testDateIntervalNormalizerRegistered()
10351035
{
1036-
if (!class_exists(DateIntervalNormalizer::class)) {
1037-
$this->markTestSkipped('The DateIntervalNormalizer has been introduced in the Serializer Component version 3.4.');
1038-
}
1039-
10401036
$container = $this->createContainerFromFile('full');
10411037

10421038
$definition = $container->getDefinition('serializer.normalizer.dateinterval');

‎src/Symfony/Component/Serializer/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CHANGELOG
1616
use the default context instead.
1717
* removed `XmlEncoder::setRootNodeName()` & `XmlEncoder::getRootNodeName()`, use the default context instead.
1818
* removed individual encoders/normalizers options as constructor arguments.
19+
* removed support for instantiating a `DataUriNormalizer` with a default MIME type guesser when the `symfony/mime` component isn't installed.
1920

2021
4.3.0
2122
-----

‎src/Symfony/Component/Serializer/Encoder/JsonDecode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/JsonDecode.php
+1-15Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,8 @@ class JsonDecode implements DecoderInterface
4040
self::RECURSION_DEPTH => 512,
4141
];
4242

43-
/**
44-
* Constructs a new JsonDecode instance.
45-
*
46-
* @param array $defaultContext
47-
*/
48-
public function __construct($defaultContext = [], int $depth = 512)
43+
public function __construct(array $defaultContext = [])
4944
{
50-
if (!\is_array($defaultContext)) {
51-
@trigger_error(sprintf('Using constructor parameters that are not a default context is deprecated since Symfony 4.2, use the "%s" and "%s" keys of the context instead.', self::ASSOCIATIVE, self::RECURSION_DEPTH), E_USER_DEPRECATED);
52-
53-
$defaultContext = [
54-
self::ASSOCIATIVE => (bool) $defaultContext,
55-
self::RECURSION_DEPTH => $depth,
56-
];
57-
}
58-
5945
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
6046
}
6147

‎src/Symfony/Component/Serializer/Encoder/JsonEncode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/JsonEncode.php
+2-11Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,9 @@ class JsonEncode implements EncoderInterface
2626
self::OPTIONS => 0,
2727
];
2828

29-
/**
30-
* @param array $defaultContext
31-
*/
32-
public function __construct($defaultContext = [])
29+
public function __construct(array $defaultContext = [])
3330
{
34-
if (!\is_array($defaultContext)) {
35-
@trigger_error(sprintf('Passing an integer as first parameter of the "%s()" method is deprecated since Symfony 4.2, use the "json_encode_options" key of the context instead.', __METHOD__), E_USER_DEPRECATED);
36-
37-
$this->defaultContext[self::OPTIONS] = (int) $defaultContext;
38-
} else {
39-
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
40-
}
31+
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
4132
}
4233

4334
/**

‎src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
+3-23Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -203,24 +203,14 @@ protected function isCircularReference($object, &$context)
203203
* If a circular reference handler is set, it will be called. Otherwise, a
204204
* {@class CircularReferenceException} will be thrown.
205205
*
206-
* @final since Symfony 4.2
207-
*
208-
* @param object $object
209-
* @param string|null $format
210-
* @param array $context
206+
* @final
211207
*
212208
* @return mixed
213209
*
214210
* @throws CircularReferenceException
215211
*/
216-
protected function handleCircularReference($object/*, string $format = null, array $context = []*/)
212+
protected function handleCircularReference(object $object, string $format = null, array $context = [])
217213
{
218-
if (\func_num_args() < 2 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
219-
@trigger_error(sprintf('The "%s()" method will have two new "string $format = null" and "array $context = []" arguments in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
220-
}
221-
$format = \func_num_args() > 1 ? func_get_arg(1) : null;
222-
$context = \func_num_args() > 2 ? func_get_arg(2) : [];
223-
224214
$circularReferenceHandler = $context[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER];
225215
if ($circularReferenceHandler) {
226216
return $circularReferenceHandler($object, $format, $context);
@@ -450,20 +440,10 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
450440
}
451441

452442
/**
453-
* @param array $parentContext
454-
* @param string $attribute Attribute name
455-
* @param string|null $format
456-
*
457-
* @return array
458-
*
459443
* @internal
460444
*/
461-
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
445+
protected function createChildContext(array $parentContext, string $attribute, ?string $format): array
462446
{
463-
if (\func_num_args() < 3) {
464-
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
465-
$format = null;
466-
}
467447
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
468448
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
469449
} else {

‎src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+1-10Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -540,18 +540,9 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str
540540
* We must not mix up the attribute cache between parent and children.
541541
*
542542
* {@inheritdoc}
543-
*
544-
* @param string|null $format
545543
*/
546-
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
544+
protected function createChildContext(array $parentContext, string $attribute, ?string $format): array
547545
{
548-
if (\func_num_args() >= 3) {
549-
$format = \func_get_arg(2);
550-
} else {
551-
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
552-
$format = null;
553-
}
554-
555546
$context = parent::createChildContext($parentContext, $attribute, $format);
556547
$context['cache_key'] = $this->getCacheKey($format, $context);
557548

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php
+7-21Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
namespace Symfony\Component\Serializer\Normalizer;
1313

1414
use Symfony\Component\HttpFoundation\File\File;
15-
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
16-
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as DeprecatedMimeTypeGuesserInterface;
1715
use Symfony\Component\Mime\MimeTypeGuesserInterface;
1816
use Symfony\Component\Mime\MimeTypes;
1917
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
@@ -38,22 +36,10 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
3836
*/
3937
private $mimeTypeGuesser;
4038

41-
/**
42-
* @param MimeTypeGuesserInterface|null $mimeTypeGuesser
43-
*/
44-
public function __construct($mimeTypeGuesser = null)
39+
public function __construct(MimeTypeGuesserInterface $mimeTypeGuesser = null)
4540
{
46-
if ($mimeTypeGuesser instanceof DeprecatedMimeTypeGuesserInterface) {
47-
@trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedMimeTypeGuesserInterface::class, __METHOD__, MimeTypeGuesserInterface::class), E_USER_DEPRECATED);
48-
} elseif (null === $mimeTypeGuesser) {
49-
if (class_exists(MimeTypes::class)) {
50-
$mimeTypeGuesser = MimeTypes::getDefault();
51-
} elseif (class_exists(MimeTypeGuesser::class)) {
52-
@trigger_error(sprintf('Passing null to "%s()" to use a default MIME type guesser without Symfony Mime installed is deprecated since Symfony 4.3. Try running "composer require symfony/mime".', __METHOD__), E_USER_DEPRECATED);
53-
$mimeTypeGuesser = MimeTypeGuesser::getInstance();
54-
}
55-
} elseif (!$mimeTypeGuesser instanceof MimeTypes) {
56-
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be an instance of "%s" or null, %s given.', __METHOD__, MimeTypes::class, \is_object($mimeTypeGuesser) ? \get_class($mimeTypeGuesser) : \gettype($mimeTypeGuesser)));
41+
if (!$mimeTypeGuesser && class_exists(MimeTypes::class)) {
42+
$mimeTypeGuesser = MimeTypes::getDefault();
5743
}
5844

5945
$this->mimeTypeGuesser = $mimeTypeGuesser;
@@ -112,6 +98,10 @@ public function denormalize($data, $class, $format = null, array $context = [])
11298
try {
11399
switch ($class) {
114100
case 'Symfony\Component\HttpFoundation\File\File':
101+
if (!class_exists(File::class)) {
102+
throw new InvalidArgumentException(sprintf('Cannot denormalize to a "%s" without the HttpFoundation component installed. Try running "composer require symfony/http-foundation".', File::class));
103+
}
104+
115105
return new File($data, false);
116106

117107
case 'SplFileObject':
@@ -154,10 +144,6 @@ private function getMimeType(\SplFileInfo $object)
154144
return $object->getMimeType();
155145
}
156146

157-
if ($this->mimeTypeGuesser instanceof DeprecatedMimeTypeGuesserInterface && $mimeType = $this->mimeTypeGuesser->guess($object->getPathname())) {
158-
return $mimeType;
159-
}
160-
161147
if ($this->mimeTypeGuesser && $mimeType = $this->mimeTypeGuesser->guessMimeType($object->getPathname())) {
162148
return $mimeType;
163149
}

‎src/Symfony/Component/Serializer/Serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Serializer.php
+1-14Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface
5656
*/
5757
protected $decoder;
5858

59-
/**
60-
* @internal since Symfony 4.1
61-
*/
62-
protected $normalizers = [];
63-
64-
private $cachedNormalizers;
59+
private $normalizers = [];
6560
private $denormalizerCache = [];
6661
private $normalizerCache = [];
6762

@@ -220,10 +215,6 @@ public function supportsDenormalization($data, $type, $format = null, array $con
220215
*/
221216
private function getNormalizer($data, ?string $format, array $context)
222217
{
223-
if ($this->cachedNormalizers !== $this->normalizers) {
224-
$this->cachedNormalizers = $this->normalizers;
225-
$this->denormalizerCache = $this->normalizerCache = [];
226-
}
227218
$type = \is_object($data) ? \get_class($data) : 'native-'.\gettype($data);
228219

229220
if (!isset($this->normalizerCache[$format][$type])) {
@@ -263,10 +254,6 @@ private function getNormalizer($data, ?string $format, array $context)
263254
*/
264255
private function getDenormalizer($data, string $class, ?string $format, array $context)
265256
{
266-
if ($this->cachedNormalizers !== $this->normalizers) {
267-
$this->cachedNormalizers = $this->normalizers;
268-
$this->denormalizerCache = $this->normalizerCache = [];
269-
}
270257
if (!isset($this->denormalizerCache[$format][$class])) {
271258
$this->denormalizerCache[$format][$class] = [];
272259

‎src/Symfony/Component/Serializer/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"symfony/config": "^4.4|^5.0",
2525
"symfony/property-access": "^4.4|^5.0",
2626
"symfony/http-foundation": "^4.4|^5.0",
27+
"symfony/mime": "^4.4|^5.0",
2728
"symfony/cache": "^4.4|^5.0",
2829
"symfony/property-info": "^4.4|^5.0",
2930
"symfony/validator": "^4.4|^5.0",
@@ -45,7 +46,7 @@
4546
"symfony/yaml": "For using the default YAML mapping loader.",
4647
"symfony/config": "For using the XML mapping loader.",
4748
"symfony/property-access": "For using the ObjectNormalizer.",
48-
"symfony/http-foundation": "For using a MIME type guesser within the DataUriNormalizer.",
49+
"symfony/mime": "For using a MIME type guesser within the DataUriNormalizer.",
4950
"doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.",
5051
"doctrine/cache": "For using the default cached annotation reader and metadata cache."
5152
},

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.