Totally agree. I would also do ```$this->identityMap[$className][(string) $id] = $document;```