From 52f810d2041453bd51c8f7d42e6cd67a0ce86fc1 Mon Sep 17 00:00:00 2001 From: Adam Charron Date: Wed, 13 Sep 2023 02:45:37 -0400 Subject: [PATCH] Fix withContext on contextException --- src/ContextException.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ContextException.php b/src/ContextException.php index d0c83f1..31f0948 100644 --- a/src/ContextException.php +++ b/src/ContextException.php @@ -27,16 +27,17 @@ public function __construct(string $message = "", int $code = 0, array $context /** * Add extra context to an exception. * + * This can't be an immutable clone because exceptions aren't cloneable. + * * @param array $context * * @return $this */ public function withContext(array $context): self { - $ex = clone $this; - $ex->context = array_replace($ex->context, $context); + $this->context = array_replace($this->context, $context); - return $ex; + return $this; } /**