Skip to content

Commit 25e341e

Browse files
authored
Allow objects with __toString in IDType
1 parent 3536280 commit 25e341e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Type/Definition/IDType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function serialize($value)
4343
if ($value === null) {
4444
return 'null';
4545
}
46-
if (!is_scalar($value)) {
46+
if (!is_scalar($value) && (!is_object($value) || !method_exists($value, '__toString'))) {
4747
throw new InvariantViolation("ID type cannot represent non scalar value: " . Utils::printSafe($value));
4848
}
4949
return (string) $value;

0 commit comments

Comments
 (0)