PackageTrack
Sign in Get early access

sebastian/comparator

Provides the functionality to compare PHP values for equality

8.4.0 952M downloads/mo #47 most downloaded on composer sebastianbergmann/comparator

What this package is like to depend on

Last release 16 days ago

07 Aug 2026

Release timing varies

gaps range from 1 weeks to 5 months

Most releases are documented

notes for 61 of 74 stable releases

Nothing withdrawn

no release was ever pulled

12 years old

74 releases · first in 2014

20 releases in the last 12 months

see the full history below

Release timeline

74 releases · May 2014 to Aug 2026
2015 2017 2019 2021 2023 2025
Release Pre-release

Releases

latest 60 of 74
  1. 8.4.0 07 Aug 2026
    Release notes

    Added

    • Factory::setExporter() and Factory::exporter() for configuring the SebastianBergmann\Exporter\Exporter instance that is used by comparators registered with the factory

    Changed

    • Comparators now use the Exporter instance configured for their Factory instead of creating their own instances (this allows customizing how values are represented in comparison failure messages)
    • When an object exporter provides the representation for the objects that are compared then that representation is used in the comparison failure message instead of the property-by-property representation; this does not apply to objects for which a comparator of their own exists (DateTimeComparator, for instance), as the representation such a comparator provides always has precedence
    Open source →
    Release notes

    Added

    • Factory::setExporter() and Factory::exporter() for configuring the SebastianBergmann\Exporter\Exporter instance that is used by comparators registered with the factory

    Changed

    • Comparators now use the Exporter instance configured for their Factory instead of creating their own instances (this allows customizing how values are represented in comparison failure messages)
    • When an object exporter provides the representation for the objects that are compared then that representation is used in the comparison failure message instead of the property-by-property representation; this does not apply to objects for which a comparator of their own exists (DateTimeComparator, for instance), as the representation such a comparator provides always has precedence
    Open source →
  2. 8.3.0 05 Jun 2026
    Release notes

    Added

    • #163: Expose detection of closure comparisons
    Open source →
    Release notes

    Added

    • #163: Expose detection of closure comparisons
    Open source →
  3. 8.2.1 21 May 2026
    Release notes

    Changed

    • #136: Cleaner diff output for canonicalized list comparisons
    • #160: Use by-value comparison for closures

    Fixed

    • #136: Canonicalized array comparison destroys string keys
    Open source →
    Release notes

    Changed

    • #136: Cleaner diff output for canonicalized list comparisons
    • #160: Use by-value comparison for closures

    Fixed

    • #136: Canonicalized array comparison destroys string keys
    Open source →
  4. 8.2.0 20 May 2026
    Release notes

    Added

    • #126: DateIntervalComparator for comparing DateInterval objects with a delta tolerance

    Fixed

    • #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
    • #87: DOMNodeComparator crashes or returns false positives when DOMNode::C14N() fails
    • #107: DOMNodeComparator reports XML documents as equal when they differ only in comments
    • #115: DateTimeComparator does not track processed pairs, producing misleading diffs in nested structures
    • #158: ComparisonFailure cannot be serialized when stack trace contains non-serializable objects
    Open source →
    Release notes

    Added

    • #126: DateIntervalComparator for comparing DateInterval objects with a delta tolerance

    Fixed

    • #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
    • #87: DOMNodeComparator crashes or returns false positives when DOMNode::C14N() fails
    • #107: DOMNodeComparator reports XML documents as equal when they differ only in comments
    • #115: DateTimeComparator does not track processed pairs, producing misleading diffs in nested structures
    • #158: ComparisonFailure cannot be serialized when stack trace contains non-serializable objects
    Open source →
  5. 8.1.4 15 May 2026
    Release notes

    Changed

    • #138: Use StrictUnifiedDiffOutputBuilder instead of UnifiedDiffOutputBuilder
    Open source →
    Release notes

    Changed

    • #138: Use StrictUnifiedDiffOutputBuilder instead of UnifiedDiffOutputBuilder
    Open source →
  6. 8.1.3 15 May 2026
    Release notes

    Changed

    • Pass configuration options introduced in sebastian/diff 8.3.0
    Open source →
    Release notes

    Changed

    • Pass configuration options introduced in sebastian/diff 8.3.0
    Open source →
  7. 8.1.2 14 Apr 2026
    Release notes

    Fixed

    • #141: ArrayComparator sorts objects by spl_object_id(), breaking canonicalized equality for arrays of equal objects
    Open source →
    Release notes

    Fixed

    • #141: ArrayComparator sorts objects by spl_object_id(), breaking canonicalized equality for arrays of equal objects
    Open source →
  8. 8.1.1 08 Apr 2026
    Release notes

    Fixed

    • #140: sort() in ArrayComparator produces non-deterministic results for arrays with mixed types
    Open source →
  9. 8.1.0 06 Apr 2026
    Release notes

    Added

    • #137: Make diff context lines configurable
    Open source →
  10. 8.0.0 06 Feb 2026
    Release notes

    Removed

    • Removed support for PHP 8.3
    Open source →
  11. 7.1.8 21 May 2026
    Release notes

    Changed

    • #136: Cleaner diff output for canonicalized list comparisons
    • #160: Use by-value comparison for closures

    Fixed

    • #136: Canonicalized array comparison destroys string keys
    Open source →
    Release notes

    Changed

    • #136: Cleaner diff output for canonicalized list comparisons
    • #160: Use by-value comparison for closures

    Fixed

    • #136: Canonicalized array comparison destroys string keys
    Open source →
  12. 7.1.7 20 May 2026
    Release notes

    Fixed

    • #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
    • #87: DOMNodeComparator crashes or returns false positives when DOMNode::C14N() fails
    • #107: DOMNodeComparator reports XML documents as equal when they differ only in comments
    • #115: DateTimeComparator does not track processed pairs, producing misleading diffs in nested structures
    • #158: ComparisonFailure cannot be serialized when stack trace contains non-serializable objects
    Open source →
    Release notes

    Fixed

    • #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
    • #87: DOMNodeComparator crashes or returns false positives when DOMNode::C14N() fails
    • #107: DOMNodeComparator reports XML documents as equal when they differ only in comments
    • #115: DateTimeComparator does not track processed pairs, producing misleading diffs in nested structures
    • #158: ComparisonFailure cannot be serialized when stack trace contains non-serializable objects
    Open source →
  13. 7.1.6 14 Apr 2026
    Release notes

    Fixed

    • #141: ArrayComparator sorts objects by spl_object_id(), breaking canonicalized equality for arrays of equal objects
    Open source →
    Release notes

    Fixed

    • #141: ArrayComparator sorts objects by spl_object_id(), breaking canonicalized equality for arrays of equal objects
    Open source →
  14. 7.1.5 08 Apr 2026
    Release notes

    Fixed

    • #140: sort() in ArrayComparator produces non-deterministic results for arrays with mixed types
    Open source →
  15. 7.1.4 24 Jan 2026
    Release notes

    Changed

    • #134: Suppress warning introduced in PHP 8.5
    Open source →
  16. 7.1.3 20 Aug 2025
    Release notes

    Changed

    • #130: Provide a diff when ClosureComparator fails
    Open source →
  17. 7.1.2 10 Aug 2025
    Release notes

    Fixed

    • SebastianBergmann\Comparator\Comparator should not have been marked as private implementation detail of this library
    Open source →
  18. 7.1.1 10 Aug 2025
    Release notes

    Changed

    • Do not use SplObjectStorage methods that will be deprecated in PHP 8.5
    Open source →
  19. 7.1.0 17 Jun 2025
    Release notes

    Added

    • #127: Support for comparing Closure objects
    Open source →
  20. 7.0.1 07 Mar 2025
    Release notes

    Fixed

    • #122: INF is considered equal to -INF
    Open source →
  21. 7.0.0 07 Feb 2025
    Release notes

    Removed

    • Removed support for PHP 8.2
    Open source →
  22. 6.3.3 24 Jan 2026
    Release notes

    Changed

    • #134: Suppress warning introduced in PHP 8.5
    Open source →
  23. 6.3.2 10 Aug 2025
    Release notes

    Changed

    • Do not use SplObjectStorage methods that will be deprecated in PHP 8.5
    Open source →
  24. 6.3.1 07 Mar 2025
    Release notes

    Fixed

    • #122: INF is considered equal to -INF
    Open source →
  25. 6.3.0 06 Jan 2025
    Release notes

    Added

    • #121: Support for BcMath\Number objects
    Open source →
  26. 6.2.1 31 Oct 2024
    Release notes

    Fixed

    • #119: Uninitialized string offset -1 warning
    Open source →
  27. 6.2.0 30 Oct 2024
    Release notes

    Changed

    • #117: Remove common prefixes and suffixes from actual and expected single-line strings
    Open source →
  28. 6.1.1 18 Oct 2024
    Release notes

    Fixed

    • Reverted #113 as it broke backward compatibility
    Open source →
  29. 6.1.0 11 Sep 2024
    Release notes

    Added

    • Specialized comparator for enumerations
    Open source →
  30. 6.0.2 12 Aug 2024
    Release notes

    Fixed

    • #112: Arrays with different keys and the same values are considered equal in canonicalize mode
    Open source →
  31. 6.0.1 03 Jul 2024
    Release notes

    Changed

    • This project now uses PHPStan instead of Psalm for static analysis
    Open source →
  32. 6.0.0 02 Feb 2024
    Release notes

    Removed

    • Removed support for PHP 8.1
    Open source →
  33. 5.0.5 24 Jan 2026
    Release notes

    Changed

    • #134: Suppress warning introduced in PHP 8.5
    Open source →
  34. 5.0.4 07 Sep 2025
    Release notes

    Changed

    • Do not use SplObjectStorage methods that will be deprecated in PHP 8.5
    Open source →
  35. 5.0.3 18 Oct 2024
    Release notes

    Fixed

    • Reverted #113 as it broke backward compatibility
    Open source →
  36. 5.0.2 12 Aug 2024
    Release notes

    Fixed

    • #112: Arrays with different keys and the same values are considered equal in canonicalize mode
    Open source →
  37. 5.0.1 14 Aug 2023
    Release notes

    Fixed

    • MockObjectComparator only works on instances of PHPUnit\Framework\MockObject\MockObject, but not on instances of PHPUnit\Framework\MockObject\Stub
    • MockObjectComparator only ignores the $__phpunit_invocationMocker property, but not other properties with names prefixed with __phpunit_
    Open source →
  38. 5.0.0 03 Feb 2023
    Release notes

    Changed

    • Methods now have parameter and return type declarations
    • Comparator::$factory is now private, use Comparator::factory() instead
    • ComparisonFailure, DOMNodeComparator, DateTimeComparator, ExceptionComparator, MockObjectComparator, NumericComparator, ResourceComparator, SplObjectStorageComparator, and TypeComparator are now final
    • ScalarComparator and DOMNodeComparator now use mb_strtolower($string, 'UTF-8') instead of strtolower($string)

    Removed

    • Removed $identical parameter from ComparisonFailure::__construct()
    • Removed Comparator::$exporter
    • Removed support for PHP 7.3, PHP 7.4, and PHP 8.0
    Open source →
  39. 4.0.10 24 Jan 2026
    Release notes

    Changed

    • #134: Suppress warning introduced in PHP 8.5
    Open source →
  40. 4.0.9 10 Aug 2025
    Release notes

    Changed

    • Do not use SplObjectStorage methods that will be deprecated in PHP 8.5
    Open source →
  41. 4.0.8 14 Sep 2022
    Release notes

    Fixed

    • #102: Fix float comparison precision
    Open source →
  42. 4.0.7 14 Sep 2022
    Release notes

    Fixed

    • #99: Fix weak comparison between '0' and false
    Open source →
  43. 4.0.6 26 Oct 2020
    Release notes

    Fixed

    • SebastianBergmann\Comparator\Exception now correctly extends \Throwable
    Open source →
  44. 4.0.5 30 Sep 2020
    Release notes

    Fixed

    • #89: Handle PHP 8 ValueError
    Open source →
  45. 4.0.4 28 Sep 2020
    Release notes

    Changed

    • Changed PHP version constraint in composer.json from ^7.3 || ^8.0 to >=7.3
    Open source →
  46. 4.0.3 26 Jun 2020
    Release notes

    Added

    • This component is now supported on PHP 8
    Open source →
  47. 4.0.2 15 Jun 2020
    Release notes

    Fixed

    • #85: Version 4.0.1 breaks backward compatibility
    Open source →
  48. 4.0.1 15 Jun 2020
    Release notes

    Changed

    • Tests etc. are now ignored for archive exports
    Open source →
  49. 4.0.0 07 Feb 2020
    Release notes

    Removed

    • Removed support for PHP 7.1 and PHP 7.2
    Open source →
  50. 3.0.7 24 Jan 2026
    Release notes

    Changed

    • #134: Suppress warning introduced in PHP 8.5
    Open source →
  51. 3.0.6 10 Aug 2025
    Release notes

    Changed

    • Do not use SplObjectStorage methods that will be deprecated in PHP 8.5
    Open source →
  52. 3.0.5 14 Sep 2022
    Release notes

    Fixed

    • #102: Fix float comparison precision
    Open source →
  53. 3.0.4 14 Sep 2022
    Release notes

    Fixed

    • #99: Fix weak comparison between '0' and false
    Open source →
  54. 3.0.3 30 Nov 2020
    Release notes

    Changed

    • Changed PHP version constraint in composer.json from ^7.1 to >=7.1
    Open source →
  55. 3.0.2 12 Jul 2018
    Release notes

    Changed

    • By default, MockObjectComparator is now tried before all other (default) comparators
    Open source →
  56. 3.0.1 14 Jun 2018
    Release notes

    Fixed

    • #53: DOMNodeComparator ignores $ignoreCase parameter
    • #58: ScalarComparator does not handle extremely ugly string comparison edge cases
    Open source →
  57. 3.0.0 18 Apr 2018
    Release notes

    Fixed

    • #48: DateTimeComparator does not support fractional second deltas

    Removed

    • Removed support for PHP 7.0
    Open source →
  58. 2.1.3 01 Feb 2018
    Release notes

    Changed

    • This component is now compatible with version 3 of sebastian/diff
    Open source →
  59. 2.1.2 12 Jan 2018
    Release notes

    Fixed

    • Fix comparison of DateTimeImmutable objects
    Open source →
  60. 2.1.1 22 Dec 2017
    Release notes

    Fixed

    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive