Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e158f7

Browse files
committed
Revert "Add a skipNullValues() method"
This reverts commit c76527b.
1 parent c76527b commit 0e158f7

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

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

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,15 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
3737
const DISABLE_TYPE_ENFORCEMENT = 'disable_type_enforcement';
3838
const SKIP_NULL_VALUES = 'skip_null_values';
3939

40-
/**
41-
* @var callable|null
42-
*/
43-
protected $maxDepthHandler;
44-
45-
/**
46-
* @var bool
47-
*/
48-
protected $skipNullValues = false;
49-
5040
private $propertyTypeExtractor;
5141
private $typesCache = array();
5242
private $attributesCache = array();
5343

44+
/**
45+
* @var callable|null
46+
*/
47+
private $maxDepthHandler;
48+
5449
/**
5550
* @var ClassDiscriminatorResolverInterface|null
5651
*/
@@ -226,14 +221,6 @@ public function setMaxDepthHandler(?callable $handler): void
226221
$this->maxDepthHandler = $handler;
227222
}
228223

229-
/**
230-
* Configures the normalizer to skip null values.
231-
*/
232-
public function skipNullValues()
233-
{
234-
$this->skipNullValues = true;
235-
}
236-
237224
/**
238225
* {@inheritdoc}
239226
*/
@@ -416,7 +403,7 @@ private function getTypes(string $currentClass, string $attribute)
416403
*/
417404
private function updateData(array $data, string $attribute, $attributeValue, string $class, ?string $format, array $context): array
418405
{
419-
if (null === $attributeValue && ($this->skipNullValues || ($context[self::SKIP_NULL_VALUES] ?? false))) {
406+
if (null === $attributeValue && ($context[self::SKIP_NULL_VALUES] ?? false)) {
420407
return $data;
421408
}
422409

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ public function testSkipNullValues()
170170
$normalizer = new ObjectNormalizer();
171171
$result = $normalizer->normalize($dummy, null, array(AbstractObjectNormalizer::SKIP_NULL_VALUES => true));
172172
$this->assertSame(array('bar' => 'present'), $result);
173-
174-
$normalizer->skipNullValues();
175-
$result = $normalizer->normalize($dummy);
176-
$this->assertSame(array('bar' => 'present'), $result);
177173
}
178174
}
179175

0 commit comments

Comments
 (0)