From da834c20d4aade8b6e105c963bf14d69d45d7fc1 Mon Sep 17 00:00:00 2001 From: Matias Navarro Carter Date: Sat, 23 Sep 2023 00:36:07 +0100 Subject: [PATCH] fix: key casting in context --- context/src/MissingContextValue.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/context/src/MissingContextValue.php b/context/src/MissingContextValue.php index 1f8de65..a6c5afb 100644 --- a/context/src/MissingContextValue.php +++ b/context/src/MissingContextValue.php @@ -23,6 +23,14 @@ class MissingContextValue extends \LogicException { public static function forKey(mixed $key): MissingContextValue { + if (is_object($key)) { + $key = get_class($key); + } + + if (!is_string($key)) { + $key = (string) $key; + } + return new self(\sprintf('Missing context value for key "%s"', $key)); } }