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
Releases
latest 60 of 74-
8.4.007 Aug 2026Release notes
Open source →Added
Factory::setExporter()andFactory::exporter()for configuring theSebastianBergmann\Exporter\Exporterinstance that is used by comparators registered with the factory
Changed
- Comparators now use the
Exporterinstance configured for theirFactoryinstead 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
Release notes
Open source →Added
Factory::setExporter()andFactory::exporter()for configuring theSebastianBergmann\Exporter\Exporterinstance that is used by comparators registered with the factory
Changed
- Comparators now use the
Exporterinstance configured for theirFactoryinstead 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
-
8.3.005 Jun 2026 -
8.2.121 May 2026Release notes
Open source →Changed
- #136: Cleaner diff output for canonicalized list comparisons
- #160: Use by-value comparison for closures
Fixed
- #136: Canonicalized array comparison destroys string keys
Release notes
Open source →Changed
- #136: Cleaner diff output for canonicalized list comparisons
- #160: Use by-value comparison for closures
Fixed
- #136: Canonicalized array comparison destroys string keys
-
8.2.020 May 2026Release notes
Open source →Added
- #126:
DateIntervalComparatorfor comparingDateIntervalobjects with a delta tolerance
Fixed
- #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
- #87:
DOMNodeComparatorcrashes or returns false positives whenDOMNode::C14N()fails - #107:
DOMNodeComparatorreports XML documents as equal when they differ only in comments - #115:
DateTimeComparatordoes not track processed pairs, producing misleading diffs in nested structures - #158:
ComparisonFailurecannot be serialized when stack trace contains non-serializable objects
Release notes
Open source →Added
- #126:
DateIntervalComparatorfor comparingDateIntervalobjects with a delta tolerance
Fixed
- #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
- #87:
DOMNodeComparatorcrashes or returns false positives whenDOMNode::C14N()fails - #107:
DOMNodeComparatorreports XML documents as equal when they differ only in comments - #115:
DateTimeComparatordoes not track processed pairs, producing misleading diffs in nested structures - #158:
ComparisonFailurecannot be serialized when stack trace contains non-serializable objects
- #126:
-
8.1.415 May 2026Release notes
Open source →Changed
- #138: Use
StrictUnifiedDiffOutputBuilderinstead ofUnifiedDiffOutputBuilder
Release notes
Open source →Changed
- #138: Use
StrictUnifiedDiffOutputBuilderinstead ofUnifiedDiffOutputBuilder
- #138: Use
-
8.1.315 May 2026 -
8.1.214 Apr 2026Release notes
Open source →Fixed
- #141:
ArrayComparatorsorts objects byspl_object_id(), breaking canonicalized equality for arrays of equal objects
Release notes
Open source →Fixed
- #141:
ArrayComparatorsorts objects byspl_object_id(), breaking canonicalized equality for arrays of equal objects
- #141:
-
8.1.108 Apr 2026Release notes
Open source →Fixed
- #140:
sort()inArrayComparatorproduces non-deterministic results for arrays with mixed types
- #140:
-
8.1.006 Apr 2026 -
8.0.006 Feb 2026 -
7.1.821 May 2026Release notes
Open source →Changed
- #136: Cleaner diff output for canonicalized list comparisons
- #160: Use by-value comparison for closures
Fixed
- #136: Canonicalized array comparison destroys string keys
Release notes
Open source →Changed
- #136: Cleaner diff output for canonicalized list comparisons
- #160: Use by-value comparison for closures
Fixed
- #136: Canonicalized array comparison destroys string keys
-
7.1.720 May 2026Release notes
Open source →Fixed
- #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
- #87:
DOMNodeComparatorcrashes or returns false positives whenDOMNode::C14N()fails - #107:
DOMNodeComparatorreports XML documents as equal when they differ only in comments - #115:
DateTimeComparatordoes not track processed pairs, producing misleading diffs in nested structures - #158:
ComparisonFailurecannot be serialized when stack trace contains non-serializable objects
Release notes
Open source →Fixed
- #70: Non-ASCII text in XML diffs is rendered as numeric character references, making diffs unreadable
- #87:
DOMNodeComparatorcrashes or returns false positives whenDOMNode::C14N()fails - #107:
DOMNodeComparatorreports XML documents as equal when they differ only in comments - #115:
DateTimeComparatordoes not track processed pairs, producing misleading diffs in nested structures - #158:
ComparisonFailurecannot be serialized when stack trace contains non-serializable objects
-
7.1.614 Apr 2026Release notes
Open source →Fixed
- #141:
ArrayComparatorsorts objects byspl_object_id(), breaking canonicalized equality for arrays of equal objects
Release notes
Open source →Fixed
- #141:
ArrayComparatorsorts objects byspl_object_id(), breaking canonicalized equality for arrays of equal objects
- #141:
-
7.1.508 Apr 2026Release notes
Open source →Fixed
- #140:
sort()inArrayComparatorproduces non-deterministic results for arrays with mixed types
- #140:
-
7.1.424 Jan 2026 -
7.1.320 Aug 2025 -
7.1.210 Aug 2025Release notes
Open source →Fixed
SebastianBergmann\Comparator\Comparatorshould not have been marked as private implementation detail of this library
-
7.1.110 Aug 2025Release notes
Open source →Changed
- Do not use
SplObjectStoragemethods that will be deprecated in PHP 8.5
- Do not use
-
7.1.017 Jun 2025 -
7.0.107 Mar 2025 -
7.0.007 Feb 2025 -
6.3.324 Jan 2026 -
6.3.210 Aug 2025Release notes
Open source →Changed
- Do not use
SplObjectStoragemethods that will be deprecated in PHP 8.5
- Do not use
-
6.3.107 Mar 2025 -
6.3.006 Jan 2025 -
6.2.131 Oct 2024 -
6.2.030 Oct 2024Release notes
Open source →Changed
- #117: Remove common prefixes and suffixes from actual and expected single-line strings
-
6.1.118 Oct 2024 -
6.1.011 Sep 2024 -
6.0.212 Aug 2024Release notes
Open source →Fixed
- #112: Arrays with different keys and the same values are considered equal in canonicalize mode
-
6.0.103 Jul 2024Release notes
Open source →Changed
- This project now uses PHPStan instead of Psalm for static analysis
-
6.0.002 Feb 2024 -
5.0.524 Jan 2026 -
5.0.407 Sep 2025Release notes
Open source →Changed
- Do not use
SplObjectStoragemethods that will be deprecated in PHP 8.5
- Do not use
-
5.0.318 Oct 2024 -
5.0.212 Aug 2024Release notes
Open source →Fixed
- #112: Arrays with different keys and the same values are considered equal in canonicalize mode
-
5.0.114 Aug 2023Release notes
Open source →Fixed
MockObjectComparatoronly works on instances ofPHPUnit\Framework\MockObject\MockObject, but not on instances ofPHPUnit\Framework\MockObject\StubMockObjectComparatoronly ignores the$__phpunit_invocationMockerproperty, but not other properties with names prefixed with__phpunit_
-
5.0.003 Feb 2023Release notes
Open source →Changed
- Methods now have parameter and return type declarations
Comparator::$factoryis now private, useComparator::factory()insteadComparisonFailure,DOMNodeComparator,DateTimeComparator,ExceptionComparator,MockObjectComparator,NumericComparator,ResourceComparator,SplObjectStorageComparator, andTypeComparatorare nowfinalScalarComparatorandDOMNodeComparatornow usemb_strtolower($string, 'UTF-8')instead ofstrtolower($string)
Removed
- Removed
$identicalparameter fromComparisonFailure::__construct() - Removed
Comparator::$exporter - Removed support for PHP 7.3, PHP 7.4, and PHP 8.0
-
4.0.1024 Jan 2026 -
4.0.910 Aug 2025Release notes
Open source →Changed
- Do not use
SplObjectStoragemethods that will be deprecated in PHP 8.5
- Do not use
-
4.0.814 Sep 2022 -
4.0.714 Sep 2022 -
4.0.626 Oct 2020Release notes
Open source →Fixed
SebastianBergmann\Comparator\Exceptionnow correctly extends\Throwable
-
4.0.530 Sep 2020 -
4.0.428 Sep 2020Release notes
Open source →Changed
- Changed PHP version constraint in
composer.jsonfrom^7.3 || ^8.0to>=7.3
- Changed PHP version constraint in
-
4.0.326 Jun 2020 -
4.0.215 Jun 2020 -
4.0.115 Jun 2020 -
4.0.007 Feb 2020 -
3.0.724 Jan 2026 -
3.0.610 Aug 2025Release notes
Open source →Changed
- Do not use
SplObjectStoragemethods that will be deprecated in PHP 8.5
- Do not use
-
3.0.514 Sep 2022 -
3.0.414 Sep 2022 -
3.0.330 Nov 2020Release notes
Open source →Changed
- Changed PHP version constraint in
composer.jsonfrom^7.1to>=7.1
- Changed PHP version constraint in
-
3.0.212 Jul 2018Release notes
Open source →Changed
- By default,
MockObjectComparatoris now tried before all other (default) comparators
- By default,
-
3.0.114 Jun 2018 -
3.0.018 Apr 2018Release notes
Open source →Fixed
- #48:
DateTimeComparatordoes not support fractional second deltas
Removed
- Removed support for PHP 7.0
- #48:
-
2.1.301 Feb 2018Release notes
Open source →Changed
- This component is now compatible with version 3 of
sebastian/diff
- This component is now compatible with version 3 of
-
2.1.212 Jan 2018 -
2.1.122 Dec 2017