src/Entity/Hydrator/EntityHydrator.php
public function hydrate(array $data, $object)
    {
        if (!$object instanceof EntityInterface) {
            return array();
            //@todo Error-Handling
        }
        $setters = array_filter(
            get_class_methods($object),
            function ($methodName) {
                return "set" === substr($methodName, 0, 3);
            }
        );
        
        foreach ($setters as $setter) {
            $propertyName = lcfirst(substr($setter, 3));
            if (isset($data[$propertyName])) {
                $value = $this->hydrateValue($propertyName, $data[$propertyName]);
                if (null !== $value) {
                    $object->$setter($value);
                }
                unset($data[$propertyName]);
            }
        }
        
        foreach ($data as $key => $value) {
            if ($value instanceof \MongoId) {
                $object->setId($value->__toString());
            }
        }
        
        return $object;
    }
public function hydrate(array $data, $object)
    {
        if (!$object instanceof EntityInterface) {
            return array();
            //@todo Error-Handling
        }
        $setters = array_filter(
            get_class_methods($object),
            function ($methodName) {
                return "set" === substr($methodName, 0, 3);
            }
        );
        
        foreach ($setters as $setter) {
            $propertyName = lcfirst(substr($setter, 3));
            if (isset($data[$propertyName])) {
                $value = $this->hydrateValue($propertyName, $data[$propertyName]);
                if (null !== $value) {
                    $object->$setter($value);
                }
                unset($data[$propertyName]);
            }
        }
        
        foreach ($data as $key => $value) {
            if ($value instanceof \MongoId) {
                $object->setId($value->__toString());
            }
        }
        
        return $object;
    }
/* (non-PHPdoc)
@see \Zend\Hydrator\HydratorInterface::hydrate()