Skip to content

Navigation Menu

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 d7114f0

Browse filesBrowse files
committed
Add deprecation notice
Update changelog
1 parent a1c164d commit d7114f0
Copy full SHA for d7114f0

File tree

11 files changed

+74
-74
lines changed
Filter options

11 files changed

+74
-74
lines changed

‎src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Mime/TemplatedEmailTest.php
+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testSymfonySerialize()
102102
EOF;
103103

104104
$extractor = new PhpDocExtractor();
105-
$propertyNormalizer = new PropertyNormalizer(null, null, $extractor);
105+
$propertyNormalizer = new PropertyNormalizer(null, null, $extractor, null, null, [], true);
106106
$serializer = new Serializer([
107107
new ArrayDenormalizer(),
108108
new MimeMessageNormalizer($propertyNormalizer),

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php
+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
service('serializer.mapping.class_discriminator_resolver')->ignoreOnInvalid(),
137137
null,
138138
[],
139+
false,
139140
])
140141

141142
->alias(PropertyNormalizer::class, 'serializer.normalizer.property')

‎src/Symfony/Component/Mime/Tests/EmailTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/EmailTest.php
+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public function testSymfonySerialize()
448448
EOF;
449449

450450
$extractor = new PhpDocExtractor();
451-
$propertyNormalizer = new PropertyNormalizer(null, null, $extractor);
451+
$propertyNormalizer = new PropertyNormalizer(null, null, $extractor, null, null, [], true);
452452
$serializer = new Serializer([
453453
new ArrayDenormalizer(),
454454
new MimeMessageNormalizer($propertyNormalizer),

‎src/Symfony/Component/Mime/Tests/MessageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/MessageTest.php
+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public function testSymfonySerialize()
245245
EOF;
246246

247247
$extractor = new PhpDocExtractor();
248-
$propertyNormalizer = new PropertyNormalizer(null, null, $extractor);
248+
$propertyNormalizer = new PropertyNormalizer(null, null, $extractor, null, null, [], true);
249249
$serializer = new Serializer([
250250
new ArrayDenormalizer(),
251251
new MimeMessageNormalizer($propertyNormalizer),

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/CHANGELOG.md
+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.2
5+
---
6+
* Add `allowNormalizationOfObjectsWithoutAnyProperties` option to `PropertyNormalizer`
7+
* Add `allowNormalizationOfObjectsWithoutAnyGetters` option to `GetSetMethodNormalizer`
8+
49
6.1
510
---
611

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public function __construct(
5454
) {
5555
parent::__construct($classMetadataFactory, $nameConverter, $propertyTypeExtractor, $classDiscriminatorResolver, $objectClassResolver, $defaultContext);
5656
$this->allowNormalizationOfObjectsWithoutAnyGetters = $allowNormalizationOfObjectsWithoutAnyGetters;
57+
58+
if (\func_num_args() < 7) {
59+
trigger_deprecation('symfony/serializer', '6.2', '$allowNormalizationOfObjectsWithoutAnyGetters parameter of %s() should be explicitly provided since the default value will change to `true` in symfony/serializer >=7.0', __METHOD__);
60+
}
5761
}
5862

5963
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php
+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function __construct(
4949
) {
5050
parent::__construct($classMetadataFactory, $nameConverter, $propertyTypeExtractor, $classDiscriminatorResolver, $objectClassResolver, $defaultContext);
5151
$this->allowNormalizationOfObjectsWithoutAnyProperties = $allowNormalizationOfObjectsWithoutAnyProperties;
52+
53+
if (\func_num_args() < 7) {
54+
trigger_deprecation('symfony/serializer', '6.2', '$allowNormalizationOfObjectsWithoutAnyProperties parameter of %s() should be explicitly provided since the default value will change to `true` in symfony/serializer >=7.0', __METHOD__);
55+
}
5256
}
5357

5458
/**

‎src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
+3-3
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ public function getNormalizer()
205205
{
206206
$extractor = new PhpDocExtractor();
207207

208-
yield [new PropertyNormalizer()];
209-
yield [new PropertyNormalizer(null, null, $extractor)];
208+
yield [new PropertyNormalizer(null, null, null, null, null, [], true)];
209+
yield [new PropertyNormalizer(null, null, $extractor, null, null, [], true)];
210210
yield [new ObjectNormalizer()];
211211
yield [new ObjectNormalizer(null, null, null, $extractor)];
212212
}
@@ -222,7 +222,7 @@ public function testIgnore()
222222
$dummy = new IgnoreDummy();
223223
$dummy->ignored1 = 'hello';
224224

225-
$normalizer = new PropertyNormalizer($this->classMetadata);
225+
$normalizer = new PropertyNormalizer($this->classMetadata, null, null, null, null, [], true);
226226

227227
$this->assertSame([], $normalizer->normalize($dummy));
228228
}

‎src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
+22-29
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function setUp(): void
7373
private function createNormalizer(array $defaultContext = [])
7474
{
7575
$this->serializer = $this->createMock(SerializerNormalizer::class);
76-
$this->normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext);
76+
$this->normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext, true);
7777
$this->normalizer->setSerializer($this->serializer);
7878
}
7979

@@ -234,20 +234,20 @@ protected function getNormalizerForCallbacksWithPropertyTypeExtractor(): GetSetM
234234
{
235235
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
236236

237-
return new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory), $this->getCallbackPropertyTypeExtractor());
237+
return new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory), $this->getCallbackPropertyTypeExtractor(), null, null, [], true);
238238
}
239239

240240
protected function getNormalizerForCallbacks(): GetSetMethodNormalizer
241241
{
242242
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
243243

244-
return new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory));
244+
return new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory), null, null, null, [], true);
245245
}
246246

247247
protected function getNormalizerForCircularReference(array $defaultContext): GetSetMethodNormalizer
248248
{
249249
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
250-
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory), null, null, null, $defaultContext);
250+
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory), null, null, null, $defaultContext, true);
251251
new Serializer([$normalizer]);
252252

253253
return $normalizer;
@@ -261,7 +261,7 @@ protected function getSelfReferencingModel()
261261
protected function getDenormalizerForConstructArguments(): GetSetMethodNormalizer
262262
{
263263
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
264-
$denormalizer = new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory));
264+
$denormalizer = new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory), null, null, null, [], true);
265265
new Serializer([$denormalizer]);
266266

267267
return $denormalizer;
@@ -271,20 +271,20 @@ protected function getNormalizerForGroups(): GetSetMethodNormalizer
271271
{
272272
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
273273

274-
return new GetSetMethodNormalizer($classMetadataFactory);
274+
return new GetSetMethodNormalizer($classMetadataFactory, null, null, null, null, [], true);
275275
}
276276

277277
protected function getDenormalizerForGroups(): GetSetMethodNormalizer
278278
{
279279
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
280280

281-
return new GetSetMethodNormalizer($classMetadataFactory);
281+
return new GetSetMethodNormalizer($classMetadataFactory, null, null, null, null, [], true);
282282
}
283283

284284
public function testGroupsNormalizeWithNameConverter()
285285
{
286286
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
287-
$this->normalizer = new GetSetMethodNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter());
287+
$this->normalizer = new GetSetMethodNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter(), null, null, null, [], true);
288288
$this->normalizer->setSerializer($this->serializer);
289289

290290
$obj = new GroupDummy();
@@ -305,7 +305,7 @@ public function testGroupsNormalizeWithNameConverter()
305305
public function testGroupsDenormalizeWithNameConverter()
306306
{
307307
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
308-
$this->normalizer = new GetSetMethodNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter());
308+
$this->normalizer = new GetSetMethodNormalizer($classMetadataFactory, new CamelCaseToSnakeCaseNameConverter(), null, null, null, [], true);
309309
$this->normalizer->setSerializer($this->serializer);
310310

311311
$obj = new GroupDummy();
@@ -326,7 +326,7 @@ public function testGroupsDenormalizeWithNameConverter()
326326
protected function getNormalizerForMaxDepth(): NormalizerInterface
327327
{
328328
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
329-
$normalizer = new GetSetMethodNormalizer($classMetadataFactory);
329+
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, null, null, null, [], true);
330330
$serializer = new Serializer([$normalizer]);
331331
$normalizer->setSerializer($serializer);
332332

@@ -336,7 +336,7 @@ protected function getNormalizerForMaxDepth(): NormalizerInterface
336336
protected function getDenormalizerForObjectToPopulate(): DenormalizerInterface
337337
{
338338
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
339-
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, new PhpDocExtractor());
339+
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, new PhpDocExtractor(), null, null, [], true);
340340
new Serializer([$normalizer]);
341341

342342
return $normalizer;
@@ -345,7 +345,7 @@ protected function getDenormalizerForObjectToPopulate(): DenormalizerInterface
345345
protected function getDenormalizerForTypeEnforcement(): DenormalizerInterface
346346
{
347347
$extractor = new PropertyInfoExtractor([], [new PhpDocExtractor(), new ReflectionExtractor()]);
348-
$normalizer = new GetSetMethodNormalizer(null, null, $extractor);
348+
$normalizer = new GetSetMethodNormalizer(null, null, $extractor, null, null, [], true);
349349
$serializer = new Serializer([new ArrayDenormalizer(), $normalizer]);
350350
$normalizer->setSerializer($serializer);
351351

@@ -357,40 +357,32 @@ public function testRejectInvalidKey()
357357
$this->markTestSkipped('This test makes no sense with the GetSetMethodNormalizer');
358358
}
359359

360-
protected function getNormalizerAllowingObjectsWithoutGetters(): GetSetMethodNormalizer
361-
{
362-
return new GetSetMethodNormalizer(null, null, null, null, null, [], true);
363-
}
364-
365360
public function testNormalizeObjectWithoutAnyProperties()
366361
{
367-
$normalizer = $this->getNormalizerAllowingObjectsWithoutGetters();
368362
$obj = new EmptyObjectDummy();
369363

370-
$this->assertTrue($normalizer->supportsNormalization($obj));
371-
364+
$this->assertTrue($this->normalizer->supportsNormalization($obj));
372365
$this->assertEquals(
373366
[],
374-
$normalizer->normalize($obj),
367+
$this->normalizer->normalize($obj),
375368
);
376369
}
377370

378371
public function testDenormalizeObjectWithoutAnyProperties()
379372
{
380-
$normalizer = $this->getNormalizerAllowingObjectsWithoutGetters();
381373
$obj = new EmptyObjectDummy();
382374

383-
$this->assertTrue($normalizer->supportsDenormalization($obj, \get_class($obj)));
375+
$this->assertTrue($this->normalizer->supportsDenormalization($obj, \get_class($obj)));
384376
$this->assertEquals(
385377
$obj,
386-
$normalizer->denormalize([], \get_class($obj)),
378+
$this->normalizer->denormalize([], \get_class($obj)),
387379
);
388380
}
389381

390382
protected function getNormalizerForIgnoredAttributes(): GetSetMethodNormalizer
391383
{
392384
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
393-
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, new PhpDocExtractor());
385+
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, new PhpDocExtractor(), null, null, [], true);
394386
new Serializer([$normalizer]);
395387

396388
return $normalizer;
@@ -399,7 +391,7 @@ protected function getNormalizerForIgnoredAttributes(): GetSetMethodNormalizer
399391
protected function getDenormalizerForIgnoredAttributes(): GetSetMethodNormalizer
400392
{
401393
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
402-
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, new PhpDocExtractor());
394+
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, new PhpDocExtractor(), null, null, [], true);
403395
new Serializer([$normalizer]);
404396

405397
return $normalizer;
@@ -457,7 +449,8 @@ public function testNoTraversableSupport()
457449

458450
public function testNoStaticGetSetSupport()
459451
{
460-
$this->assertFalse($this->normalizer->supportsNormalization(new ObjectWithJustStaticSetterDummy()));
452+
$normalizer = new GetSetMethodNormalizer(null, null, null, null, null, [], false);
453+
$this->assertFalse($normalizer->supportsNormalization(new ObjectWithJustStaticSetterDummy()));
461454
}
462455

463456
public function testPrivateSetter()
@@ -496,12 +489,12 @@ protected function getObjectCollectionWithExpectedArray(): array
496489

497490
protected function getNormalizerForCacheableObjectAttributesTest(): GetSetMethodNormalizer
498491
{
499-
return new GetSetMethodNormalizer();
492+
return new GetSetMethodNormalizer(null, null, null, null, null, [], true);
500493
}
501494

502495
protected function getNormalizerForSkipUninitializedValues(): NormalizerInterface
503496
{
504-
return new GetSetMethodNormalizer(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())));
497+
return new GetSetMethodNormalizer(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())), null, null, null, null, [], true);
505498
}
506499
}
507500

0 commit comments

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