Skip to content

Navigation Menu

Sign in
Appearance settings

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 b91ccac

Browse filesBrowse files
committed
Add guard check to be consistent with other normalizers
1 parent 642fcc0 commit b91ccac
Copy full SHA for b91ccac

File tree

1 file changed

+6
-0
lines changed
Filter options

1 file changed

+6
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Serializer\Normalizer;
1313

14+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
1415
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
1516
use Symfony\Component\Uid\AbstractUid;
1617
use Symfony\Component\Uid\Ulid;
@@ -23,6 +24,11 @@ final class UidNormalizer implements NormalizerInterface, DenormalizerInterface,
2324
*/
2425
public function normalize($object, string $format = null, array $context = [])
2526
{
27+
if (!$object instanceof AbstractUid) {
28+
throw new InvalidArgumentException('The object must be an instance of "Symfony\Component\Uid\AbstractUid".');
29+
}
30+
31+
2632
return (string) $object;
2733
}
2834

0 commit comments

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