sebastianbergmann / comparator

Provides the functionality to compare PHP values for equality.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

dpinheiro opened this issue · comments

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

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.

Hello

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

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

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