Skip to content

DeepComparer returns false when compares null with null #806

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

Closed
forrest79 opened this issue Mar 17, 2025 · 3 comments
Closed

DeepComparer returns false when compares null with null #806

forrest79 opened this issue Mar 17, 2025 · 3 comments

Comments

@forrest79
Copy link

Hi,

I found out, that this code returns false: var_dump(DeepComparer::isEqual(null, null));.

I used temporary fix in our repo:

        $isLeftScalar = is_scalar($left) || is_null($left);
        $isRightScalar = is_scalar($right) || is_null($right);
Copy link

🚀 @forrest79, thanks for your contribution! Every idea, bug report, and discussion helps make this project better. Your input is invaluable, and we appreciate the time you took to share it. A maintainer will review it soon—stay awesome! 💡✨

⭐ Enjoying contributing? Star the project! ⭐Your contributions help this project grow, and we'd love your support in another way too! If you find this repo helpful, consider leaving a star 🌟 on GitHub.

@nicosp
Copy link
Contributor

nicosp commented Mar 17, 2025

Had the same issue as well. I fixed it by adding this at the beginning of DeepComparer::isEqual:

if ($left === null && $right === null) {
    return true;
}

Not sure if this is the right fix but it works.

DannyvdSluijs pushed a commit that referenced this issue Mar 18, 2025
Fixes null not equal to null.

Issue: #806
@DannyvdSluijs
Copy link
Collaborator

This was fixed in #807 and version 6.3.1 was just released containing this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants