sebastianbergmann / comparator

Provides the functionality to compare PHP values for equality.
BSD 3-Clause "New" or "Revised" License
6.99k stars 68 forks source link

ArrayComparator::assertEquals declaration not compatible with Comparator::assertEquals #103

Closed dpinheiro closed 1 year ago

dpinheiro commented 1 year ago

Hello and first of all thanks for making this package available to us all

Looks like that on the new version 5.0.0 there's a mismatch on the declaration of the abstract class Comparator and the ArrayComparator

public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void
abstract public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false): void;

this is causing a PHP fatal error (PHP@8.1.13)

PHP Fatal error:  Declaration of SebastianBergmann\Comparator\ArrayComparator::assertEquals(mixed $expected, mixed $actual, float $delta = 0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void must be compatible with SebastianBergmann\Comparator\Comparator::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false) in /var/www/symfony/vendor/sebastian/comparator/src/ArrayComparator.php on line 36

Best

sebastianbergmann commented 1 year ago

I cannot reproduce this issue. As you can see here, the tests for this library pass with PHP 8.1, PHP 8.2, and PHP 8.3.

vichanse commented 1 year ago

Hello

I have the same error as @dpinheiro. I just forced the version 4.0.8 while waiting for a fix

sebastianbergmann commented 1 year ago

As you can see here, the code in question works just fine. Must be something funky (mixed up installation?) on your end.

vichanse commented 1 year ago

You're right. It was due to mixed up installation. The problem was that Alice bundle use old version for comparator.

I had to add this in my composer.json file config section

    "optimize-autoloader": true,
    "prepend-autoloader": false,

Big up to @elitecolors