Skip to content

Commit 4e02928

Browse files
committed
fix: Uuid identifier normalizer should support only strings
1 parent e972102 commit 4e02928

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Bridge/RamseyUuid/Identifier/Normalizer/UuidNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public function denormalize($data, $class, $format = null, array $context = [])
4343
*/
4444
public function supportsDenormalization($data, $type, $format = null)
4545
{
46-
return is_a($type, UuidInterface::class, true);
46+
return is_string($data) && is_a($type, UuidInterface::class, true);
4747
}
4848
}

tests/Bridge/RamseyUuid/Normalizer/UuidNormalizerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,11 @@ public function testFailDenormalizeUuid()
4444
$this->assertTrue($normalizer->supportsDenormalization($uuid, Uuid::class));
4545
$normalizer->denormalize($uuid, Uuid::class);
4646
}
47+
48+
public function testDoNotSupportNotString()
49+
{
50+
$uuid = new Uuid();
51+
$normalizer = new UuidNormalizer();
52+
$this->assertFalse($normalizer->supportsDenormalization($uuid, Uuid::class));
53+
}
4754
}

0 commit comments

Comments
 (0)