Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonicalizing array comparator leaks notices #79

Open
JKingweb opened this issue Mar 5, 2020 · 1 comment
Open

Canonicalizing array comparator leaks notices #79

JKingweb opened this issue Mar 5, 2020 · 1 comment
Labels

Comments

@JKingweb
Copy link

JKingweb commented Mar 5, 2020

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)
@sebastianbergmann
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants