Skip to content

Commit

Permalink
revert marko changes
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Oct 31, 2018
1 parent 16acff1 commit d93ed8c
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 74 deletions.
8 changes: 0 additions & 8 deletions doc/reference/annotations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ be serialized/unserialized. Works only in combination with AllExclusionPolicy.
If the ``ExpressionLanguageExclusionStrategy`` exclusion strategy is enabled, will
be possible to use ``@Expose(if="expression")`` to expose dynamically a property.

@DeserializeNull
~~~~~~~~~~~~~~~~
This annotation can be defined on a property to indicate that the property should
be deserialized even if the value is null. By default, if you have a custom handler
it won't be invoked if the value is null.

Use case for this is if you use a Null Object to represent your null values.

@SkipWhenEmpty
~~~~~~~~~~~~~~
This annotation can be defined on a property to indicate that the property should
Expand Down
1 change: 0 additions & 1 deletion doc/reference/xml_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ XML Reference
expose="true"
exclude-if="expr"
expose-if="expr"
deserialize-null="false"
skip-when-empty="false"
type="string"
serialized-name="foo"
Expand Down
1 change: 0 additions & 1 deletion doc/reference/yml_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ YAML Reference
expose: true
exclude_if: expr
expose_if: expr
deserialize_null: false
skip_when_empty: false
access_type: public_method # defaults to property
accessor: # access_type must be set to public_method
Expand Down
15 changes: 0 additions & 15 deletions src/Annotation/DeserializeNull.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/DeserializationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function increaseDepth(): void
}

/**
* Set if NULLs should be serialized (TRUE) ot not (FALSE)
* Set if NULLs should be deserialized (TRUE) ot not (FALSE)
*/
public function setDeserializeNull(bool $bool): self
{
Expand All @@ -49,8 +49,8 @@ public function setDeserializeNull(bool $bool): self
}

/**
* Returns TRUE when NULLs should be serialized
* Returns FALSE when NULLs should not be serialized
* Returns TRUE when NULLs should be deserialized
* Returns FALSE when NULLs should not be deserialized
*/
public function shouldDeserializeNull(): bool
{
Expand Down
2 changes: 0 additions & 2 deletions src/GraphNavigator/DeserializationGraphNavigator.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public function accept($data, ?array $type = null)
if (null === $type) {
throw new RuntimeException('The type must be given for all properties when deserializing.');
}

// Sometimes data can convey null but is not of a null type.
// Visitors can have the power to add this custom null evaluation
// If null is explicitly allowed we should skip this
Expand Down Expand Up @@ -227,7 +226,6 @@ public function accept($data, ?array $type = null)
$rs = $this->visitor->endVisitingObject($metadata, $data, $type);
$this->afterVisitingObject($metadata, $rs, $type);


return $rs;
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/Metadata/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\AccessorOrder;
use JMS\Serializer\Annotation\AccessType;
use JMS\Serializer\Annotation\DeserializeNull;
use JMS\Serializer\Annotation\Discriminator;
use JMS\Serializer\Annotation\Exclude;
use JMS\Serializer\Annotation\ExclusionPolicy;
Expand Down Expand Up @@ -182,8 +181,6 @@ public function loadMetadataForClass(\ReflectionClass $class): ?BaseClassMetadat
} else {
$isExclude = true;
}
} elseif ($annot instanceof DeserializeNull) {
$propertyMetadata->deserializeNull = true;
} elseif ($annot instanceof Type) {
$propertyMetadata->setType($this->typeParser->parse($annot->name));
} elseif ($annot instanceof XmlElement) {
Expand Down
4 changes: 0 additions & 4 deletions src/Metadata/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $path):
$pMetadata->excludeIf = (string) $excludeIf;
}

if (null !== $deserializeNull = $pElem->attributes()->{'deserialize-null'}) {
$pMetadata->deserializeNull = 'true' === strtolower((string) $deserializeNull);
}

if (null !== $skip = $pElem->attributes()->{'skip-when-empty'}) {
$pMetadata->skipWhenEmpty = 'true' === strtolower((string) $skip);
}
Expand Down
4 changes: 0 additions & 4 deletions src/Metadata/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ protected function loadMetadataFromFile(\ReflectionClass $class, string $file):
$pMetadata->excludeIf = (string) $pConfig['exclude_if'];
}

if (isset($pConfig['deserialize_null'])) {
$pMetadata->deserializeNull = (bool) $pConfig['deserialize_null'];
}

if (isset($pConfig['expose_if'])) {
$pMetadata->excludeIf = '!(' . $pConfig['expose_if'] . ')';
}
Expand Down
9 changes: 0 additions & 9 deletions src/Metadata/PropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ class PropertyMetadata extends BasePropertyMetadata
*/
public $forceReflectionAccess = false;

/**
* @var bool
*/
public $deserializeNull = false;

public function __construct(string $class, string $name)
{
parent::__construct($class, $name);
Expand Down Expand Up @@ -243,7 +238,6 @@ public function serialize()
'excludeIf' => $this->excludeIf,
'skipWhenEmpty' => $this->skipWhenEmpty,
'forceReflectionAccess' => $this->forceReflectionAccess,
'deserializeNull' => $this->deserializeNull,
]);
}

Expand Down Expand Up @@ -304,9 +298,6 @@ protected function unserializeProperties(string $str): string
if (isset($unserialized['forceReflectionAccess'])) {
$this->forceReflectionAccess = $unserialized['forceReflectionAccess'];
}
if (isset($unserialized['deserializeNull'])) {
$this->deserializeNull = $unserialized['deserializeNull'];
}

return $parentStr;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/Fixtures/ObjectWithNullObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

namespace JMS\Serializer\Tests\Fixtures;

use JMS\Serializer\Annotation\DeserializeNull;
use JMS\Serializer\Annotation\Type;

class ObjectWithNullObject
{
/**
* @var null
* @Type("NullObject")
* @DeserializeNull()
*/
private $nullProperty;

Expand Down
9 changes: 0 additions & 9 deletions tests/Metadata/Driver/BaseDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,6 @@ public function testVirtualProperty()
self::assertEquals($p, $m->propertyMetadata['virtualValue']);
}

public function testNullObject()
{
$m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ObjectWithNullObject'));

self::assertArrayHasKey('nullProperty', $m->propertyMetadata);

self::assertTrue($m->propertyMetadata['nullProperty']->deserializeNull);
}

public function testFirstClassListCollection()
{
$m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass(FirstClassListCollection::class));
Expand Down
6 changes: 0 additions & 6 deletions tests/Metadata/Driver/xml/ObjectWithNullObject.xml

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Metadata/Driver/yml/ObjectWithNullObject.yml

This file was deleted.

4 changes: 2 additions & 2 deletions tests/Serializer/BaseSerializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function testSerializeNullObject()
);
}

public function testDeserializeNullProperty()
public function testDeserializeNullObject()
{
if (!$this->hasDeserializer()) {
$this->markTestSkipped(sprintf('No deserializer available for format `%s`', $this->getFormat()));
Expand All @@ -192,7 +192,7 @@ public function testDeserializeNullProperty()
self::assertNull($dObj->getNullProperty());
}

public function testDeserializeNullObject()
public function testDeserializeNullObjectWithHandler()
{
if (!$this->hasDeserializer()) {
$this->markTestSkipped(sprintf('No deserializer available for format `%s`', $this->getFormat()));
Expand Down

0 comments on commit d93ed8c

Please sign in to comment.