From 265f883a406c1e38f0761a46eb66d36e729050bd Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Tue, 18 Mar 2025 10:30:31 +0200 Subject: [PATCH 1/2] Fix null comparison --- src/JsonSchema/Tool/DeepComparer.php | 4 ++++ tests/Tool/DeepComparerTest.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/JsonSchema/Tool/DeepComparer.php b/src/JsonSchema/Tool/DeepComparer.php index 70b16ef0..fb99b141 100644 --- a/src/JsonSchema/Tool/DeepComparer.php +++ b/src/JsonSchema/Tool/DeepComparer.php @@ -12,6 +12,10 @@ class DeepComparer */ public static function isEqual($left, $right): bool { + if ($left === null && $right === null) { + return true; + } + $isLeftScalar = is_scalar($left); $isRightScalar = is_scalar($right); diff --git a/tests/Tool/DeepComparerTest.php b/tests/Tool/DeepComparerTest.php index 112ace66..cb7b02aa 100644 --- a/tests/Tool/DeepComparerTest.php +++ b/tests/Tool/DeepComparerTest.php @@ -27,6 +27,7 @@ public function testComparesDeepEqualForNotEqualLeftAndRight($left, $right): voi public function equalDataProvider(): \Generator { + yield 'Null null' => [null, null]; yield 'Boolean true' => [true, true]; yield 'Boolean false' => [false, false]; @@ -49,6 +50,7 @@ public function equalDataProvider(): \Generator public function notEqualDataProvider(): \Generator { + yield 'Null true' => [null, true]; yield 'Boolean true/false' => [true, false]; yield 'Integer one/two' => [1, 2]; From e17f8ef5767a4c519e9da1318e8ef52916824f5b Mon Sep 17 00:00:00 2001 From: Nicos Panayides Date: Tue, 18 Mar 2025 15:17:29 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f799e49..8c01934e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed - ensure numeric issues in const are correctly evaluated ([#805](https://github.com/jsonrainbow/json-schema/pull/805)) +- fix 6.3.0 regression with comparison of null values during validation ([#806](https://github.com/jsonrainbow/json-schema/issues/806)) ## [6.3.0] - 2025-03-14 ### Fixed