assertEquals is not like assertEquals - Change how values get compared with Comparators

Code
<?php

use PHPUnit\Framework\TestCase;
use 
SebastianBergmann\Comparator\Factory;
use 
SebastianBergmann\Comparator\Comparator;
use 
SebastianBergmann\Comparator\ComparisonFailure;

class 
ComparatorTest extends TestCase
{
    public function 
testStandardComparator() : void
    
{
        
self::assertEquals(
            new 
Foo(null),
            new 
Foo(0)
        );
    }
    
    public function 
testCustomComparator() : void
    
{
        
$fooComparator = new class() extends Comparator
        
{
            public function 
accepts($expected$actual)
            {
                return 
$expected instanceof Foo &&
                    
$actual instanceof Foo;
            }
            
            public function 
assertEquals($expected$actual$delta 0.0$canonicalize false$ignoreCase false)
            {
                if (
$expected->foo !== $actual->foo) {
                    throw new 
ComparisonFailure(
                        
$expected,
                        
$actual,
                        
$this->exporter->export($expected),
                        
$this->exporter->export($actual),
                        
false,
                        
'Failed asserting that two Foo objects are equal.'
                
);
                }
            }
        };
        
        
$comparatorFactory Factory::getInstance();
        
$comparatorFactory->register($fooComparator);

        
self::assertEquals(
            new 
Foo(null),
            new 
Foo(0)
        );
    }
}

class 
Foo
{
    public 
$foo;
    public function 
__construct(?int $foo)
    {
        
$this->foo $foo;
    }
}
Result
Time: 208 ms, Memory: 14.00 MB

There was 1 failure:

1) ComparatorTest::testCustomComparator
Failed asserting that two Foo objects are equal.

ComparatorTest.php:48

FAILURES!
Tests: 2, Assertions: 0, Failures: 1.
Used Versions
PHP 7.3, Zend 3.0, Symfony 4.3, Laravel 5.8, PHPUnit 8.0, Doctrine 2.10