Skip to content

Commit cba7697

Browse files
authored
Fix null comparison (#807)
Fixes null not equal to null. Issue: #806
1 parent e9ac599 commit cba7697

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99
### Fixed
1010
- ensure numeric issues in const are correctly evaluated ([#805](https://github.com/jsonrainbow/json-schema/pull/805))
11+
- fix 6.3.0 regression with comparison of null values during validation ([#806](https://github.com/jsonrainbow/json-schema/issues/806))
1112

1213
## [6.3.0] - 2025-03-14
1314
### Fixed

src/JsonSchema/Tool/DeepComparer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class DeepComparer
1212
*/
1313
public static function isEqual($left, $right): bool
1414
{
15+
if ($left === null && $right === null) {
16+
return true;
17+
}
18+
1519
$isLeftScalar = is_scalar($left);
1620
$isRightScalar = is_scalar($right);
1721

tests/Tool/DeepComparerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function testComparesDeepEqualForNotEqualLeftAndRight($left, $right): voi
2727

2828
public function equalDataProvider(): \Generator
2929
{
30+
yield 'Null null' => [null, null];
3031
yield 'Boolean true' => [true, true];
3132
yield 'Boolean false' => [false, false];
3233

@@ -49,6 +50,7 @@ public function equalDataProvider(): \Generator
4950

5051
public function notEqualDataProvider(): \Generator
5152
{
53+
yield 'Null true' => [null, true];
5254
yield 'Boolean true/false' => [true, false];
5355

5456
yield 'Integer one/two' => [1, 2];

0 commit comments

Comments
 (0)