Skip to content

Commit 7c5dbc1

Browse files
authored
Fix binary UUID hydrator (#2868)
Hydrator closures may not return, as that would terminate hydration for all fields.
1 parent f15acf4 commit 7c5dbc1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

lib/Doctrine/ODM/MongoDB/Types/BinaryUuidType.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,13 @@ public function closureToPHP(): string
6060
return <<<'PHP'
6161
if ($value instanceof \Symfony\Component\Uid\Uuid) {
6262
$return = $value;
63-
return;
64-
}
65-
66-
if (! $value instanceof \MongoDB\BSON\Binary) {
63+
} elseif (! $value instanceof \MongoDB\BSON\Binary) {
6764
throw new \InvalidArgumentException(sprintf('Invalid data of type "%s" received for Uuid', get_debug_type($value)));
68-
}
69-
70-
if ($value->getType() !== \MongoDB\BSON\Binary::TYPE_UUID) {
65+
} elseif ($value->getType() !== \MongoDB\BSON\Binary::TYPE_UUID) {
7166
throw new \InvalidArgumentException(sprintf('Invalid binary data of type %d received for Uuid', $value->getType()));
67+
} else {
68+
$return = \Symfony\Component\Uid\Uuid::fromBinary($value->getData());
7269
}
73-
74-
$return = \Symfony\Component\Uid\Uuid::fromBinary($value->getData());
7570
PHP;
7671
}
7772
}

0 commit comments

Comments
 (0)