/**
  * Loads document proxy class into cache.
  *
  * @param \ReflectionClass $reflectionClass
  *
  * @return string Proxy document path.
  */
 public function load(\ReflectionClass $reflectionClass)
 {
     $cacheBundleDir = $this->getCacheDir($reflectionClass->getName());
     $cache = new ConfigCache($cacheBundleDir . DIRECTORY_SEPARATOR . md5(strtolower($reflectionClass->getShortName())) . '.php', $this->debug);
     if (!$cache->isFresh()) {
         $code = ProxyFactory::generate($reflectionClass);
         $cache->write($code, [new FileResource($reflectionClass->getFileName())]);
     }
     return $cache->getPath();
 }
 /**
  * Finds aliases for every property used in document including parent classes.
  *
  * @param \ReflectionClass $reflectionClass
  *
  * @return array
  */
 private function getAliases(\ReflectionClass $reflectionClass)
 {
     $reflectionName = $reflectionClass->getName();
     if (array_key_exists($reflectionName, $this->aliases)) {
         return $this->aliases[$reflectionName];
     }
     $alias = [];
     /** @var \ReflectionProperty $property */
     foreach ($this->getDocumentPropertiesReflection($reflectionClass) as $name => $property) {
         $type = $this->getPropertyAnnotationData($property);
         if ($type !== null) {
             $alias[$type->name] = ['propertyName' => $name, 'type' => $type->type];
             if ($type->objectName) {
                 $child = new \ReflectionClass($this->finder->getNamespace($type->objectName));
                 $alias[$type->name] = array_merge($alias[$type->name], ['multiple' => $type instanceof Property ? $type->multiple : false, 'aliases' => $this->getAliases($child), 'proxyNamespace' => ProxyFactory::getProxyNamespace($child, true), 'namespace' => $child->getName()]);
             }
         }
     }
     $this->aliases[$reflectionName] = $alias;
     return $this->aliases[$reflectionName];
 }
 /**
  * Gathers annotation data from class.
  *
  * @param \ReflectionClass $reflectionClass Document reflection class to read mapping from.
  *
  * @return array|null
  */
 private function getDocumentReflectionMapping(\ReflectionClass $reflectionClass)
 {
     $mapping = $this->parser->parse($reflectionClass);
     if ($mapping !== null) {
         $type = key($mapping);
         $this->proxyPaths[$mapping[$type]['proxyNamespace']] = $this->proxyLoader->load($reflectionClass);
         foreach ($mapping[$type]['objects'] as $namespace) {
             $objectReflection = new \ReflectionClass($namespace);
             $proxyObject = ProxyFactory::getProxyNamespace($objectReflection);
             if (!array_key_exists($proxyObject, $this->proxyPaths)) {
                 $this->proxyPaths[$proxyObject] = $this->proxyLoader->load($objectReflection);
             }
         }
     }
     return $mapping;
 }