Canonicalizing array comparator leaks notices
JKingweb opened this issue · comments
class TestTest extends \PHPUnit\Framework\TestCase {
public function testEmitNotice(): void {
$exp = [1, new \stdClass];
$act = [1, new \stdClass];
$this->assertEqualsCanonicalizing($exp, $act);
}
}
PHPUnit 9.0.1 by Sebastian Bergmann and contributors.
PHP Notice: Object of class stdClass could not be converted to int in ./vendor/sebastian/comparator/src/ArrayComparator.php on line 49
PHP Notice: Object of class stdClass could not be converted to int in ./vendor/sebastian/comparator/src/ArrayComparator.php on line 50
. 1 / 1 (100%)
Time: 174 ms, Memory: 8.00 MB
OK (1 test, 1 assertion)
I am not sure there is anything that I can do here apart from suppressing the notice. sort()
simply should not be used on arrays that contain objects.