From eecbdc389558624b69a7f813d22d5936c1983b7b Mon Sep 17 00:00:00 2001 From: n0nag0n Date: Sun, 20 Jul 2025 09:49:00 -0600 Subject: [PATCH] a few fixes from Copilot review --- flight/util/Json.php | 6 +++--- tests/EngineTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/util/Json.php b/flight/util/Json.php index 2d5e8b4..532fc2b 100644 --- a/flight/util/Json.php +++ b/flight/util/Json.php @@ -41,7 +41,7 @@ class Json try { return json_encode($data, $options, $depth); } catch (JsonException $e) { - throw new JsonException('JSON encoding failed: ' . $e->getMessage(), $e->getCode(), $e); + throw new Exception('JSON encoding failed: ' . $e->getMessage(), $e->getCode(), $e); } } @@ -56,13 +56,13 @@ class Json * @return mixed Decoded data * @throws Exception If decoding fails */ - public static function decode(string $json, bool $associative = false, int $depth = 512, int $options = self::DEFAULT_DECODE_OPTIONS) + public static function decode(string $json, bool $associative = false, int $depth = 512, int $options = 0) { $options = $options | self::DEFAULT_DECODE_OPTIONS; // Ensure default options are applied try { return json_decode($json, $associative, $depth, $options); } catch (JsonException $e) { - throw new JsonException('JSON decoding failed: ' . $e->getMessage(), $e->getCode(), $e); + throw new Exception('JSON decoding failed: ' . $e->getMessage(), $e->getCode(), $e); } } diff --git a/tests/EngineTest.php b/tests/EngineTest.php index 1b553ae..3e81c4f 100644 --- a/tests/EngineTest.php +++ b/tests/EngineTest.php @@ -398,7 +398,7 @@ class EngineTest extends TestCase public function testJsonThrowOnErrorByDefault() { $engine = new Engine(); - $this->expectException(JsonException::class); + $this->expectException(Exception::class); $this->expectExceptionMessage('Malformed UTF-8 characters, possibly incorrectly encoded'); $engine->json(['key1' => 'value1', 'key2' => 'value2', 'utf8_emoji' => "\xB1\x31"]); }