{"record":{"id":"95a2730a882ddaa8","repo":"sebastianbergmann/comparator","slug":"failed-asserting-that-two-objects-are-equal-95a273","errorCode":null,"errorMessage":"Failed asserting that two objects are equal.","messagePattern":"Failed asserting that two objects are equal\\.","errorType":"exception","errorClass":"ComparisonFailure","httpStatus":null,"severity":"error","filePath":"src/SplObjectStorageComparator.php","lineNumber":41,"sourceCode":"    public function accepts(mixed $expected, mixed $actual): bool\n    {\n        return $expected instanceof SplObjectStorage && $actual instanceof SplObjectStorage;\n    }\n\n    /**\n     * @throws ComparisonFailure\n     * @throws ObjectNotSupportedException\n     */\n    public function assertEquals(mixed $expected, mixed $actual, float $delta = 0.0, bool $canonicalize = false, bool $ignoreCase = false): void\n    {\n        assert($expected instanceof SplObjectStorage);\n        assert($actual instanceof SplObjectStorage);\n\n        $exporter = $this->exporter();\n\n        foreach ($actual as $object) {\n            if (!$expected->offsetExists($object)) {\n                throw new ComparisonFailure(\n                    $expected,\n                    $actual,\n                    $exporter->export($expected),\n                    $exporter->export($actual),\n                    'Failed asserting that two objects are equal.',\n                    $this->contextLines(),\n                );\n            }\n        }\n\n        foreach ($expected as $object) {\n            if (!$actual->offsetExists($object)) {\n                throw new ComparisonFailure(\n                    $expected,\n                    $actual,\n                    $exporter->export($expected),\n                    $exporter->export($actual),\n                    'Failed asserting that two objects are equal.',","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/sebastianbergmann/comparator/blob/00837a9d227b4e123b0b42a91736960f6b0b3583/src/SplObjectStorageComparator.php#L23-L59","documentation":"Thrown by SplObjectStorageComparator::assertEquals when two SplObjectStorage instances do not contain the same set of objects (and/or the same associated data per object). The comparator accepts only pairs where both operands are SplObjectStorage; it iterates the actual storage and checks membership/info in the expected one, throwing ComparisonFailure on the first difference. The faulting input is whichever storage contains an object missing from the other, or an object with different associated data.","triggerScenarios":"Thrown at src/SplObjectStorageComparator.php:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Compare counts first (count($storage)) to see which side is missing entries.","Check that objects are the same instances: SplObjectStorage uses object identity (spl_object_id), not equality, for membership.","Verify the per-object data attached via attach($obj, $data) matches on both sides.","Ensure the same object instances are attached in both storages if identity was intended, or switch to a comparator based on value equality.","Rebuild the actual storage deterministically (same attach order/data) if iteration order matters to downstream code."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"00837a9d227b4e123b0b42a91736960f6b0b3583","analyzedAt":"2026-09-15T03:36:55.154Z","contentChangedAt":"2026-09-15T03:36:55.154Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}