In several places through PHPLIB's test suite, Int64 objects are constructed via unserialize(). This can be refactored to use Int64::__construct(), which was made available in PHPC-1949.
Additionally, there two places where Int64 objects are cast to PHP integers using an intermediary string cast. We should be able to remove the string cast thanks to direct integer casting enabled in PHPC-2213. See:
- MongoDB\Tests\SpecTests\DocumentsMatchConstraint::prepareBSON() and
- MongoDB\Tests\UnifiedSpecTests\Constraint\Matches::prepare()
Note that we cannot remove preparation of Int64 objects entirely, as PHPUnit's default comparator immediately rejects comparisons between PHP integers and Int64 objects. Changing that would require registering a custom Comparator. That is something we might consider in a future ticket (PHPLIB-1148).
- depends on
-
PHPC-1949 Allow explicit construction of Int64 objects
- Closed
-
PHPC-2213 Support casting of Int64 objects to scalar integers
- Closed
- related to
-
PHPLIB-1165 Provide Int64Comparator as a library
- Backlog
-
PHPLIB-1148 Create Comparator for Int64 objects and numeric primitives
- Closed