From dd41bfee19580b13aa1737eef01bba3413f87699 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 18 Oct 2024 16:50:07 +0200 Subject: [PATCH 1/2] Revert "Fix for issue #112 - ArrayComparator in canonicalize mode" This reverts commit b021fdbabfd730c54cf1f69abd7bd63ee8b898d9. --- src/ArrayComparator.php | 10 ++------- tests/ArrayComparatorTest.php | 42 ----------------------------------- 2 files changed, 2 insertions(+), 50 deletions(-) diff --git a/src/ArrayComparator.php b/src/ArrayComparator.php index b2a4dc62..75508327 100644 --- a/src/ArrayComparator.php +++ b/src/ArrayComparator.php @@ -9,7 +9,6 @@ */ namespace SebastianBergmann\Comparator; -use function array_is_list; use function array_key_exists; use function assert; use function is_array; @@ -40,13 +39,8 @@ public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, assert(is_array($actual)); if ($canonicalize) { - if (array_is_list($expected)) { - sort($expected); - } - - if (array_is_list($actual)) { - sort($actual); - } + sort($expected); + sort($actual); } $remaining = $actual; diff --git a/tests/ArrayComparatorTest.php b/tests/ArrayComparatorTest.php index 07e3de96..8e16b532 100644 --- a/tests/ArrayComparatorTest.php +++ b/tests/ArrayComparatorTest.php @@ -67,30 +67,6 @@ public static function assertEqualsSucceedsProvider(): array ['true'], [true], ], - [ - [1, [1, 2, 3]], - [[3, 1, 2], 1], - 0, - true, - ], - [ - [1, [4, 7], [1, 2, 3], [0, 0, 0, 0]], - [[3, 1, 2], [0, 0, 0, 0], [4, 7], 1], - 0, - true, - ], - [ - [1, [4, [4, 5, 6, 7, 8]], [1, 2, 3]], - [[3, 1, 2], [[4, 8, 6, 7, 5], 4], 1], - 0, - true, - ], - [ - [null, null, 1, 1], - [1, null, 1, null], - 0, - true, - ], ]; } @@ -136,24 +112,6 @@ public static function assertEqualsFailsProvider(): array ['false'], [false], ], - [ - ['a' => '1', 'b' => '2'], - ['c' => '1', 'd' => '2'], - 0, - true, - ], - [ - ['a' => '1', 'b' => '2'], - ['a' => '2', 'b' => '1'], - 0, - true, - ], - [ - ['a' => '1', 'b' => '2'], - ['a' => '1', 'b' => '2', 'c' => '2'], - 0, - true, - ], ]; } From a18251eb0b7a2dcd2f7aa3d6078b18545ef0558e Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 18 Oct 2024 16:52:47 +0200 Subject: [PATCH 2/2] Prepare release --- ChangeLog.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index c6d122d5..d0ce173f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## [5.0.3] - 2024-10-18 + +### Fixed + +* Reverted [#113](https://github.com/sebastianbergmann/comparator/pull/113) as it broke backward compatibility + ## [5.0.2] - 2024-08-12 ### Fixed @@ -150,6 +156,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt * Added `SebastianBergmann\Comparator\Factory::reset()` to unregister all non-default comparators * Added support for `phpunit/phpunit-mock-objects` version `^5.0` +[5.0.3]: https://github.com/sebastianbergmann/comparator/compare/5.0.2...5.0.3 [5.0.2]: https://github.com/sebastianbergmann/comparator/compare/5.0.1...5.0.2 [5.0.1]: https://github.com/sebastianbergmann/comparator/compare/5.0.0...5.0.1 [5.0.0]: https://github.com/sebastianbergmann/comparator/compare/4.0.8...5.0.0