Skip to content

Fix null comparison #807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/JsonSchema/Tool/DeepComparer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions tests/Tool/DeepComparerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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];
Expand Down
Loading