From 25e341e9d9309368f6399506febe71e09a0f2f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Tue, 12 Dec 2017 08:56:03 +0100 Subject: [PATCH] Allow objects with __toString in IDType --- src/Type/Definition/IDType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Type/Definition/IDType.php b/src/Type/Definition/IDType.php index 1e3deb5..5912973 100644 --- a/src/Type/Definition/IDType.php +++ b/src/Type/Definition/IDType.php @@ -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;