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

comparing array with bool: true value doesn't throw a ComparisonException #110

Open mcsky opened 1 year ago

mcsky commented 1 year ago

Hello,

I'm using your library to compare array recursively in dev environment. One of my test was failing randomly while using generated data in it (with faker). I figured out that the case below doesn't throw an exception, I think it's a weird behaviour so I wanted to notice you, maybe I should not use your library this way, let me know. :)

public function testCompareArrayWeirdBehavior()
{
    $body = [
        'somestr' => true,
    ];
    $toCompareBody = [
        'somestr' => 'some other str',
    ];
    Factory::getInstance()->getComparatorFor($body, $toCompareBody)->assertEquals(
        $body,
        $toCompareBody
    );
}

version of the library: 4.0.8

Thanks for your work anyway ! 👍🏻