sebastianbergmann/comparator is a PHP library that provides tools for checking whether two PHP values are equal to each other. It handles the full range of PHP value types, including objects, dates, arrays, and primitive values, and is designed to determine equality in a meaningful way rather than just checking whether two things are identical references. The library is primarily used as a dependency inside testing frameworks and similar tools rather than being called directly in application code. The most common use of this library is inside PHPUnit, the widely used PHP testing framework also maintained by the same author. To install it, you add the package using Composer, which is the standard dependency manager for PHP projects. If you only need the library during development to run tests, you can install it as a development-only dependency using the --dev flag. The README includes a short code example showing how to compare two DateTime objects. You create a Factory instance, ask it for a comparator appropriate for the two values you want to compare, and then call assertEquals on that comparator. If the values are equal the comparison passes silently. If they differ, the comparator throws a ComparisonFailure exception that contains information about how the two values differ. In the example, two date objects representing the same moment in different time zones are compared, and because the underlying moment in time is the same, they are treated as equal. The library has continuous integration testing and code coverage reporting set up, indicating it is actively maintained.
← sebastianbergmann on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.