Allow objects with __toString in IDType

This commit is contained in:
Jáchym Toušek 2017-12-12 08:56:03 +01:00 committed by GitHub
parent 3536280fac
commit 25e341e9d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,7 +43,7 @@ When expected as an input type, any string (such as `"4"`) or integer
if ($value === null) {
return 'null';
}
if (!is_scalar($value)) {
if (!is_scalar($value) && (!is_object($value) || !method_exists($value, '__toString'))) {
throw new InvariantViolation("ID type cannot represent non scalar value: " . Utils::printSafe($value));
}
return (string) $value;