Skip to content

Commit 987b690

Browse files
authored
Revert "Check nullable fields on handleTypeConversions method"
1 parent 57cf4bb commit 987b690

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

src/DoctrineModule/Stdlib/Hydrator/DoctrineObject.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,6 @@ public function hydrateValue($name, $value, $data = null)
272272
{
273273
$value = parent::hydrateValue($name, $value, $data);
274274

275-
if (is_null($value) && method_exists($this->metadata, 'isNullable') && $this->metadata->isNullable($name)) {
276-
return null;
277-
}
278-
279275
return $this->handleTypeConversions($value, $this->metadata->getTypeOfField($name));
280276
}
281277

@@ -539,10 +535,6 @@ function ($item) {
539535
*/
540536
protected function handleTypeConversions($value, $typeOfField)
541537
{
542-
if (is_null($value)) {
543-
return null;
544-
}
545-
546538
switch ($typeOfField) {
547539
case 'boolean':
548540
$value = (bool)$value;

tests/DoctrineModuleTest/Stdlib/Hydrator/DoctrineObjectTypeConversionsTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -621,26 +621,4 @@ public function testHandleTypeConversionsDecimal()
621621
$this->assertTrue(is_string($entity->getGenericField()));
622622
$this->assertEquals('12345', $entity->getGenericField());
623623
}
624-
625-
public function testHandleTypeConversionsNullable()
626-
{
627-
// When using hydration by value, it will use the public API of the entity to set values (setters)
628-
$this->configureObjectManagerForSimpleEntityWithGenericField(null);
629-
630-
$entity = new Asset\SimpleEntityWithGenericField();
631-
$data = ['genericField' => null];
632-
633-
$entity = $this->hydratorByValue->hydrate($data, $entity);
634-
635-
$this->assertTrue(is_null($entity->getGenericField()));
636-
$this->assertEquals(null, $entity->getGenericField());
637-
638-
$entity = new Asset\SimpleEntityWithGenericField();
639-
$data = ['genericField' => null];
640-
641-
$entity = $this->hydratorByReference->hydrate($data, $entity);
642-
643-
$this->assertTrue(is_null($entity->getGenericField()));
644-
$this->assertEquals(null, $entity->getGenericField());
645-
}
646624
}

0 commit comments

Comments
 (0)