Проверка является ли класс корректным потомком \DoctrineModule\Stdlib\Hydrator\DoctrineObject

@param $hydratorClass

@return bool
515934
public function isValidDoctrineObjectHydratorClass($hydratorClass)
    {
        if (array_key_exists($hydratorClass, $this->validDoctrineObjectHydratorClass)) {
            return $this->validDoctrineObjectHydratorClass[$hydratorClass];
        }

        $r = array_key_exists($hydratorClass, $this->reflectionClassCache) ? $this->reflectionClassCache[$hydratorClass] : new ReflectionClass($hydratorClass);

        if (!$r->isInstantiable()) {
            $this->validDoctrineObjectHydratorClass[$hydratorClass] = false;
            return false;
        }

        if (!$r->isSubclassOf(DoctrineObject::class)) {
            $this->validDoctrineObjectHydratorClass[$hydratorClass] = false;
            return false;
        }

        $rConstructorParams = $r->getConstructor()->getParameters();

        $isConstructorParamValid = true;
        foreach ($rConstructorParams as $rParam) {
            if (0 === $rParam->getPosition()) {
                $rArgClass = $rParam->getClass();
                if (null !== $rArgClass && ObjectManager::class !== $rArgClass->getName()) {
                    $isConstructorParamValid = false;
                    break;
                }
                continue;
            }

            if (!$rParam->isOptional()) {
                $isConstructorParamValid = false;
                break;
            }
        }


        $this->validDoctrineObjectHydratorClass[$hydratorClass] = $isConstructorParamValid;

        return true;
    }
772755
protected function generateAst($realClass, $hydratorClass)
    {
        $originalClass = new \ReflectionClass($realClass);
        $builder = new ClassBuilder;
        $traverser = new NodeTraverser;

        $ast = $builder->fromReflection($originalClass);

        // Remove unused methods
        $traverser->addVisitor(new MethodDisablerVisitor(function() { return false; }));

        // Implement new methods and interfaces, extend original class
        $this->addMethodVisitors($originalClass, $traverser);
        $traverser->addVisitor(new ClassExtensionVisitor($realClass, $realClass));
        $traverser->addVisitor(new ClassImplementorVisitor($realClass, ['Indigo\\Hydra\\Hydrator']));

        // Renames class
        $traverser->addVisitor(new ClassRenamerVisitor($originalClass, $hydratorClass));

        return $traverser->traverse($ast);
    }
299999
public function hydrateObject($object, $data, $class, $format, $context)
    {
        $attributes = $this->getAttributes($class, $format, $context);
        foreach ($attributes as $attribute) {
            $value = isset($data[$attribute]) ? $data[$attribute] : null;
            $value = $this->denormalizeProperty($value, null, $attribute, $format, $context);

            $this->setAttributeValue($object, $attribute, $value, $format, $context);
        }

        return $object;
    }
907246
public function hydrateEntity(ClassMetadata $class, $document)
    {
        // TODO: add support for different result set types from different clients
        // perhaps by wrapping documents in a layer of abstraction
        $data = $document->getData();
        $fields = array_merge(
            $document->hasFields() ? $document->getFields() : array(),
            array('_version' => $document->getVersion())
        );

        foreach ($fields as $name => $value) {
            if (isset($class->parameters[$name])) {
                $data[$name] = $value;
            } else {
                foreach ($class->parameters as $param => $mapping) {
                    if (isset($mapping['fieldName']) && $mapping['fieldName'] == $name) {
                        $data[$param] = $value;
                        break;
                    }
                }
            }
        }

        $data[$class->getIdentifier()] = $document->getId();

        $entity = $this->sm->getSerializer()->deserialize($class->className, json_encode($data));

        if ($this->evm->hasListeners(Events::postLoad)) {
            $this->evm->dispatchEvent(Events::postLoad, new Event\LifecycleEventArgs($entity, $this->sm));
        }

        return $entity;
    }
86345
public function hydrate(array $data, $classNameOrObject)
    {
        $object = $this->buildObject($classNameOrObject);

        return parent::hydrate($data, $object);
    }
841691
protected function createInstance(\ReflectionClass $reflectedClass)
    {
        $constructor = $reflectedClass->getConstructor();

        if ($constructor && $constructor->getNumberOfRequiredParameters() > 0) {
            throw new \RuntimeException('Unable to hydrate an object requiring constructor param');
        }

        return $reflectedClass->newInstance();
    }
1011286
public function hydrate(array $data, $object)
    {
        if (! $object instanceof Entity) {
            return $object;
        }
                
        parent::hydrate($data, $object);
               
        $authEntity = parent::hydrate($data, new \Pacificnm\Auth\Entity\Entity());
        
        $object->setAuthEntity($authEntity);
        
        $aclRoleEntity = parent::hydrate($data, new \Pacificnm\AclRole\Entity\Entity());
        
        $object->getAuthEntity()->setAclRoleEntity($aclRoleEntity);
        
        return $object;
    }
1276028
public static function hydrate(stdClass $quota)
    {
        $hydrated = new QuotaEntity();

        if (isset($quota->id)) {
            $hydrated->setId($quota->id);
        }

        if (isset($quota->current_application)) {
            $hydrated->setCurrentApplication($quota->current_application);
        }

        if (isset($quota->current_scan)) {
            $hydrated->setCurrentScan($quota->current_scan);
        }

        if (isset($quota->current_user)) {
            $hydrated->setCurrentUser($quota->current_user);
        }

        if (isset($quota->max_applications)) {
            $hydrated->setMaxApplications($quota->max_applications);
        }

        if (isset($quota->max_scans)) {
            $hydrated->setMaxScans($quota->max_scans);
        }

        if (isset($quota->max_users)) {
            $hydrated->setMaxUsers($quota->max_users);
        }

        if (isset($quota->max_loc)) {
            $hydrated->setMaxLoc($quota->max_loc);
        }

        if (isset($quota->valid_from)) {
            $hydrated->setValidFrom(new DateTime($quota->valid_from));
        }

        if (isset($quota->valid_until)) {
            $hydrated->setValidUntil(new DateTime($quota->valid_until));
        }

        if (isset($quota->allowed_misses)) {
            $hydrated->setAllowedMisses($quota->allowed_misses);
        }

        if (isset($quota->public)) {
            $hydrated->setPublic($quota->public);
        }

        if (isset($quota->organization)) {
            $hydrated->setOrganization(OrgHydrator::hydrate($quota->organization));
        }

        if (isset($quota->created_at)) {
            $hydrated->setCreatedAt(new DateTime($quota->created_at));
        }

        if (isset($quota->languages) && is_array($quota->languages)) {
            $hydrated->setLanguages(LanguageHydrator::hydrateCollection($quota->languages));
        }

        if (isset($quota->notify)) {
            $hydrated->setNotify($quota->notify);
        }

        if (isset($quota->trial_issue_types) && is_array($quota->trial_issue_types)) {
            $hydrated->setTrialIssueTypes(TypeHydrator::hydrateCollection($quota->trial_issue_types));
        }

        if (isset($quota->issue_type_limit)) {
            $hydrated->setIssueTypeLimit($quota->issue_type_limit);
        }

        if (isset($quota->update_only)) {
            $hydrated->setUpdateOnly($quota->update_only);
        }

        if (isset($quota->flexible_applications)) {
            $hydrated->setFlexibleApplications($quota->flexible_applications);
        }

        return $hydrated;
    }
672120
public function getHydratorFor(string $className) : HydratorInterface
    {
        if (isset($this->hydrators[$className])) {
            return $this->hydrators[$className];
        }
        $hydratorClassName = str_replace('\\', '', $className) . 'Hydrator';
        $fqn               = $this->hydratorNamespace . '\\' . $hydratorClassName;
        $class             = $this->dm->getClassMetadata($className);

        if (! class_exists($fqn, false)) {
            $fileName = $this->hydratorDir . DIRECTORY_SEPARATOR . $hydratorClassName . '.php';
            switch ($this->autoGenerate) {
                case Configuration::AUTOGENERATE_NEVER:
                    require $fileName;
                    break;

                case Configuration::AUTOGENERATE_ALWAYS:
                    $this->generateHydratorClass($class, $hydratorClassName, $fileName);
                    require $fileName;
                    break;

                case Configuration::AUTOGENERATE_FILE_NOT_EXISTS:
                    if (! file_exists($fileName)) {
                        $this->generateHydratorClass($class, $hydratorClassName, $fileName);
                    }
                    require $fileName;
                    break;

                case Configuration::AUTOGENERATE_EVAL:
                    $this->generateHydratorClass($class, $hydratorClassName, null);
                    break;
            }
        }
        $this->hydrators[$className] = new $fqn($this->dm, $this->unitOfWork, $class);
        return $this->hydrators[$className];
    }
384205
public static function hydrate(stdClass $java)
    {
        $hydrated = new JavaEntity();

        if (isset($java->id)) {
            $hydrated->setId($java->id);
        }

        if (isset($java->major_version)) {
            $hydrated->setMajorVersion($java->major_version);
        }

        if (isset($java->minor_version)) {
            $hydrated->setMinorVersion($java->minor_version);
        }

        if (isset($java->release_version)) {
            $hydrated->setReleaseVersion($java->release_version);
        }

        if (isset($java->implementation)) {
            $hydrated->setImplementation($java->implementation);
        }

        if (isset($java->setting)) {
            $hydrated->setSetting(SettingHydrator::hydrate($java->setting));
        }

        return $hydrated;
    }
1063599
private function _hydrate($row)
    {
        $callback = $this->_hydrator;

        return isset($this->_hydrator) ? call_user_func($callback, $row) : $row;
    }
1372052
private function hydrate($item)
    {
        if ($item === null) {
            return null;
        }

        return $this->uow->getOrCreateDocument(
            $this->class,
            $item,
            null,
            $this->readOnly,
            $this->refresh
        );
    }
116199
public function hydrate($objectClass, array $data, $indexOfBy = false)
    {
        $this->objectClass = $objectClass;

        if (0 == count($data)) {

            yield $this->createObjectToHydrate($this->objectClass);
        } elseif (! is_array(current($data))) {

            yield $this->hydrateItem($this->objectClass, $data);
        } elseif (false === $indexOfBy) {

            foreach ($data as $item) {
                yield $this->hydrateItem($this->objectClass, $item);
            }
        } else {

            foreach ($this->hydrateBy($data, $indexOfBy) as $valueOfBy => $item) {
                yield $valueOfBy => $item;
            }
        }
    }
1108614
protected function buildDoctrineObjectHydratorPrototype($hydratorName)
    {
        if (!class_exists($hydratorName)) {
            $this->prototype[$hydratorName] = false;
            return false;
        }

        if (!$this->isValidDoctrineObjectHydratorClass($hydratorName)) {
            $this->prototype[$hydratorName] = false;
            return false;
        }

        $objectManagerAutoDetector = $this->getObjectManagerAutoDetector();
        if (false === $objectManagerAutoDetector->hasObjectManagerNameByClassName($hydratorName)) {
            $this->prototype[$hydratorName] = false;
            return false;
        }

        $objectManagerName = $objectManagerAutoDetector->getObjectManagerNameByClassName($hydratorName);

        $doctrineObjectManager = $this->getDoctrineObjectManager();

        if (false === $doctrineObjectManager->has($objectManagerName)) {
            $this->prototype[$hydratorName] = false;
            return false;
        }

        /** @var ObjectManager $objectManager */
        $objectManager = $doctrineObjectManager->get($objectManagerName);

        $r = array_key_exists($hydratorName, $this->reflectionClassCache) ? $this->reflectionClassCache[$hydratorName] : new ReflectionClass($hydratorName);

        $this->prototype[$hydratorName] = $r->newInstance($objectManager);


        return $this->prototype[$hydratorName];
    }
334553
public function load(string $class): HydratorInterface
    {
        if (isset($this->hydrators[$class])) {
            return $this->hydrators[$class];
        }

        /** @var ClassMetadata $classMetadata */
        $classMetadata = $this->metadataFactory->getMetadataForClass($class);

        if (null === $classMetadata) {
            throw new \RuntimeException(
                'No mapping file was found for class '.$class.
                '. Did you configure the correct paths for serializer?'
            );
        }

        $fqn = $this->configuration->getFQNClassName($classMetadata);

        if (\class_exists($fqn, false)) {
            return $this->hydrators[$class] = $this->factory->newInstance($classMetadata);
        }

        $this->compileAndLoad($classMetadata);

        return $this->hydrators[$class] = $this->factory->newInstance($classMetadata);
    }
854226
public static function hydrate(stdClass $taint)
    {
        $hydrated = new TaintEntity();

        if (isset($taint->id)) {
            $hydrated->setId($taint->id);
        }

        if (isset($taint->start_line)) {
            $hydrated->setStartLine($taint->start_line);
        }

        if (isset($taint->end_line)) {
            $hydrated->setEndLine($taint->end_line);
        }

        if (isset($taint->start_column)) {
            $hydrated->setStartColumn($taint->start_column);
        }

        if (isset($taint->end_column)) {
            $hydrated->setEndColumn($taint->end_column);
        }

        return $hydrated;
    }
11311
public function hydrate(array $data, $object)
    {
        if (!isset($data['album'])) {
            return $object;
        }

        $hydrators = new AggregateHydrator();
        $hydrators->add(new AlbumHydrator());
        $hydrators->add(new ImageCollectionAwareHydrator());

        $object->setAlbum($hydrators->hydrate($data['album'], new Album()));

        return $object;
    }