### Install sebastian/comparator using Composer Source: https://github.com/sebastianbergmann/comparator/blob/main/README.md Demonstrates how to add the sebastian/comparator library to a project as a local or development dependency using Composer. ```bash composer require sebastian/comparator composer require --dev sebastian/comparator ``` -------------------------------- ### Compare PHP Date Objects Source: https://github.com/sebastianbergmann/comparator/blob/main/README.md Shows how to use the sebastian/comparator library to compare two PHP DateTime objects for equality. It utilizes a factory to get the appropriate comparator and handles potential comparison failures. ```php getComparatorFor($date1, $date2); try { $comparator->assertEquals($date1, $date2); print "Dates match"; } catch (ComparisonFailure $failure) { print "Dates don't match"; } ``` -------------------------------- ### Comparator Version 3.0.0 - Initial Release Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 3.0.0 marks the initial release of this version series. ```PHP ## [3.0.0] - 2018-04-18 ``` -------------------------------- ### Comparator Version 5.0.0 - Major Changes and Deprecations Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 5.0.0 introduced significant changes, including parameter and return type declarations for methods, making the `$factory` property private, finalizing several comparator classes, and updating string comparison to use `mb_strtolower`. Support for older PHP versions (7.3, 7.4, 8.0) was removed, and the `$identical` parameter from `ComparisonFailure::__construct()` was removed. ```PHP ## [5.0.0] - 2023-02-03 ### 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 ``` -------------------------------- ### Comparator Version 4.0.0 - PHP 7.1 and 7.2 Support Removed Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.0 removed support for PHP 7.1 and PHP 7.2. Users must be on a newer PHP version to use this release. ```PHP ## [4.0.0] - 2020-02-07 ### Removed * Removed support for PHP 7.1 and PHP 7.2 ``` -------------------------------- ### Comparator Version 6.0.1 - PHPStan Adoption Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.0.1 updated the project to use PHPStan for static analysis instead of Psalm. This change reflects a shift in the tools used for code quality assurance. ```PHP ## [6.0.1] - 2024-07-03 ### Changed * This project now uses PHPStan instead of Psalm for static analysis ``` -------------------------------- ### Comparator Version 3.0.1 - MockObjectComparator and ScalarComparator Fixes Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 3.0.1 fixed issues with `MockObjectComparator` and `ScalarComparator`. The `MockObjectComparator` now correctly handles stub instances and all `__phpunit_` prefixed properties. The `ScalarComparator` addresses edge cases in string comparison. ```PHP ## [3.0.1] - 2018-06-14 ### Fixed * [#53](https://github.com/sebastianbergmann/comparator/pull/53): `DOMNodeComparator` ignores `$ignoreCase` parameter * [#58](https://github.com/sebastianbergmann/comparator/pull/58): `ScalarComparator` does not handle extremely ugly string comparison edge cases ``` -------------------------------- ### Comparator Version 3.0.2 - MockObjectComparator Priority Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 3.0.2 changed the default behavior so that `MockObjectComparator` is tried before all other default comparators. This prioritizes mock object comparisons. ```PHP ## [3.0.2] - 2018-07-12 ### Changed * By default, `MockObjectComparator` is now tried before all other (default) comparators ``` -------------------------------- ### Comparator Version 5.0.1 - MockObjectComparator Improvements Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 5.0.1 improved the MockObjectComparator to correctly handle instances of PHPUnit\Framework\MockObject\Stub and to ignore all properties prefixed with '__phpunit_' instead of just '$__phpunit_invocationMocker'. ```PHP ## [5.0.1] - 2023-08-14 ### 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_` ``` -------------------------------- ### Comparator Version 4.0.6 - Exception Class Update Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.6 updated the `SebastianBergmann\Comparator\Exception` class to correctly extend `\Throwable`. This aligns the exception handling with modern PHP standards. ```PHP ## [4.0.6] - 2020-10-26 ### Fixed * `SebastianBergmann\Comparator\Exception` now correctly extends `\Throwable` ``` -------------------------------- ### Factory::reset() - Unregister Comparators Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Demonstrates the usage of `SebastianBergmann\Comparator\Factory::reset()` to unregister all non-default comparators. This is useful for resetting the comparator factory to its default state. ```PHP use SebastianBergmann\Comparator\Factory; // ... Factory::reset(); // All non-default comparators are now unregistered. ``` -------------------------------- ### Comparator Version 7.1.0 - Closure Comparison Support Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 7.1.0 introduced support for comparing Closure objects, addressing issue #127. This enhancement allows for more robust comparison of callable entities within the comparator. ```PHP ## [7.1.0] - 2025-06-17 ### Added * [#127](https://github.com/sebastianbergmann/comparator/issues/127): Support for comparing `Closure` objects ``` -------------------------------- ### Comparator Version 4.0.3 - PHP 8 Support Added Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.3 added support for PHP 8. This update ensures the comparator is compatible with the latest major PHP release. ```PHP ## [4.0.3] - 2020-06-26 ### Added * This component is now supported on PHP 8 ``` -------------------------------- ### Comparator Version 4.0.1 - Archive Export Changes Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.1 made changes to ignore tests and other files for archive exports. This optimization reduces the size of distributed archives. ```PHP ## [4.0.1] - 2020-06-15 ### Changed * Tests etc. are now ignored for archive exports ``` -------------------------------- ### Comparator Version 6.0.0 - PHP 8.1 Support Removed Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.0.0 removed support for PHP 8.1. This update may require users to upgrade their PHP environment. ```PHP ## [6.0.0] - 2024-02-02 ### Removed * Removed support for PHP 8.1 ``` -------------------------------- ### Comparator Version 7.0.0 - PHP 8.2 Support Removed Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 7.0.0 removed support for PHP 8.2. This change might affect projects relying on features specific to that PHP version. ```PHP ## [7.0.0] - 2025-02-07 ### Removed * Removed support for PHP 8.2 ``` -------------------------------- ### Comparator Version 5.0.3 - Reverted Backward Compatibility Break Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 5.0.3 reverted pull request #113 due to a backward compatibility break it introduced. This action aims to maintain stability for existing users. ```PHP ## [5.0.3] - 2024-10-18 ### Fixed * Reverted [#113](https://github.com/sebastianbergmann/comparator/pull/113) as it broke backward compatibility ``` -------------------------------- ### DateTimeComparator - Fractional Second Deltas Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Addresses an issue where `DateTimeComparator` did not support fractional second deltas. This snippet implies a fix or enhancement for comparing DateTime objects with microsecond precision. ```PHP // Example demonstrating comparison of DateTime objects with fractional seconds // (Actual implementation details would be within the library) ``` -------------------------------- ### Comparator Version 4.0.5 - PHP 8 ValueError Handling Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.5 added handling for PHP 8 `ValueError`, addressing pull request #89. This ensures the comparator functions correctly with PHP 8's new exception type. ```PHP ## [4.0.5] - 2020-09-30 ### Fixed * [#89](https://github.com/sebastianbergmann/comparator/pull/89): Handle PHP 8 `ValueError` ``` -------------------------------- ### Comparator Version 6.3.0 - BcMath Number Support Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.3.0 added support for BcMath\Number objects, addressing pull request #121. This allows the comparator to handle arbitrary-precision decimal numbers. ```PHP ## [6.3.0] - 2025-01-06 ### Added * [#121](https://github.com/sebastianbergmann/comparator/pull/121): Support for `BcMath\Number` objects ``` -------------------------------- ### Comparator Version 6.1.1 - Reverted Backward Compatibility Break Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.1.1 reverted pull request #113 due to a backward compatibility break it introduced. This action aims to maintain stability for existing users. ```PHP ## [6.1.1] - 2024-10-18 ### Fixed * Reverted [#113](https://github.com/sebastianbergmann/comparator/pull/113) as it broke backward compatibility ``` -------------------------------- ### Comparator Version 6.2.1 - Uninitialized String Offset Warning Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.2.1 fixed an 'Uninitialized string offset -1' warning, addressing pull request #119. This resolves a potential runtime notice related to string manipulation. ```PHP ## [6.2.1] - 2024-10-31 ### Fixed * [#119](https://github.com/sebastianbergmann/comparator/pull/119): `Uninitialized string offset -1` warning ``` -------------------------------- ### Comparator Version 4.0.7 - Weak Comparison Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.7 fixed a weak comparison issue between the string '0' and the boolean false, addressing pull request #99. This ensures correct behavior in loose comparisons. ```PHP ## [4.0.7] - 2022-09-14 ### Fixed * [#99](https://github.com/sebastianbergmann/comparator/pull/99): Fix weak comparison between `'0'` and `false` ``` -------------------------------- ### Comparator Version 3.0.4 - Weak Comparison Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 3.0.4 fixed a weak comparison issue between the string '0' and the boolean false, addressing pull request #99. This ensures correct behavior in loose comparisons. ```PHP ## [3.0.4] - 2022-09-14 ### Fixed * [#99](https://github.com/sebastianbergmann/comparator/pull/99): Fix weak comparison between `'0'` and `false` ``` -------------------------------- ### Comparator Version 5.0.2 - Canonicalize Mode Array Comparison Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 5.0.2 fixed an issue in canonicalize mode where arrays with different keys but the same values were considered equal, addressing issue #112. This ensures accurate array comparisons based on keys and values. ```PHP ## [5.0.2] - 2024-08-12 ### Fixed * [#112](https://github.com/sebastianbergmann/comparator/issues/112): Arrays with different keys and the same values are considered equal in canonicalize mode ``` -------------------------------- ### Comparator Version 4.0.2 - Backward Compatibility Break Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.2 fixed a backward compatibility break introduced in version 4.0.1, addressing issue #85. This restores expected behavior for users. ```PHP ## [4.0.2] - 2020-06-15 ### Fixed * [#85](https://github.com/sebastianbergmann/comparator/issues/85): Version 4.0.1 breaks backward compatibility ``` -------------------------------- ### Comparator Version 6.2.0 - String Prefix/Suffix Removal Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.2.0 changed the comparator to remove common prefixes and suffixes from actual and expected single-line strings, addressing pull request #117. This improves string comparison by normalizing differences in surrounding text. ```PHP ## [6.2.0] - 2024-10-30 ### Changed * [#117](https://github.com/sebastianbergmann/comparator/pull/117): Remove common prefixes and suffixes from actual and expected single-line strings ``` -------------------------------- ### Comparator Version 3.0.3 - Composer PHP Constraint Update Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 3.0.3 updated the PHP version constraint in `composer.json` from `^7.1` to `>=7.1`. This ensures compatibility with PHP 7.1 and later versions. ```PHP ## [3.0.3] - 2020-11-30 ### Changed * Changed PHP version constraint in `composer.json` from `^7.1` to `>=7.1` ``` -------------------------------- ### Comparator Version 6.0.2 - Canonicalize Mode Array Comparison Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.0.2 fixed an issue in canonicalize mode where arrays with different keys but the same values were considered equal, addressing issue #112. This ensures accurate array comparisons based on keys and values. ```PHP ## [6.0.2] - 2024-08-12 ### Fixed * [#112](https://github.com/sebastianbergmann/comparator/issues/112): Arrays with different keys and the same values are considered equal in canonicalize mode ``` -------------------------------- ### Comparator Version 7.0.1 - INF and -INF Equality Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 7.0.1 fixed an issue where INF (infinity) was not considered equal to -INF (negative infinity), addressing issue #122. This ensures correct numerical comparisons involving infinite values. ```PHP ## [7.0.1] - 2025-03-07 ### Fixed * [#122](https://github.com/sebastianbergmann/comparator/issues/122): `INF` is considered equal to `-INF` ``` -------------------------------- ### Comparator Version 4.0.4 - Composer PHP Constraint Update Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.4 updated the PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`. This broadens the compatibility range for PHP versions. ```PHP ## [4.0.4] - 2020-09-28 ### Changed * Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3` ``` -------------------------------- ### Comparator Version 6.1.0 - Enumeration Comparator Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.1.0 added a specialized comparator for enumerations. This provides specific logic for comparing enum types. ```PHP ## [6.1.0] - 2024-09-11 ### Added * Specialized comparator for enumerations ``` -------------------------------- ### DateTimeImmutable Comparison Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Details a fix for comparing `DateTimeImmutable` objects. This ensures accurate comparisons between immutable date and time instances. ```PHP // Example demonstrating comparison of DateTimeImmutable objects // (Actual implementation details would be within the library) ``` -------------------------------- ### PHPUnit Date Matching Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Resolves an issue related to unexpected failed date matching in PHPUnit, as reported in issue #2923. This snippet relates to the comparator's integration with PHPUnit. ```PHP // Example related to date matching in PHPUnit // (Actual implementation details would be within the library) ``` -------------------------------- ### Comparator Version 6.3.1 - INF and -INF Equality Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 6.3.1 fixed an issue where INF (infinity) was not considered equal to -INF (negative infinity), addressing issue #122. This ensures correct numerical comparisons involving infinite values. ```PHP ## [6.3.1] - 2025-03-07 ### Fixed * [#122](https://github.com/sebastianbergmann/comparator/issues/122): `INF` is considered equal to `-INF` ``` -------------------------------- ### Comparator Version 3.0.5 - Float Comparison Precision Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 3.0.5 fixed the precision of float comparisons, addressing pull request #102. This ensures more accurate comparisons of floating-point numbers. ```PHP ## [3.0.5] - 2022-09-14 ### Fixed * [#102](https://github.com/sebastianbergmann/comparator/pull/102): Fix `float` comparison precision ``` -------------------------------- ### Comparator Version 4.0.8 - Float Comparison Precision Fix Source: https://github.com/sebastianbergmann/comparator/blob/main/ChangeLog.md Version 4.0.8 fixed the precision of float comparisons, addressing pull request #102. This ensures more accurate comparisons of floating-point numbers. ```PHP ## [4.0.8] - 2022-09-14 ### Fixed * [#102](https://github.com/sebastianbergmann/comparator/pull/102): Fix `float` comparison precision ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.