@param \SimpleXMLElement $node
@param string            $className
@param \ReflectionClass  $reflection

@return array
505841
public function buildRelationshipsMetadata(\SimpleXMLElement $node, $className, \ReflectionClass $reflection)
    {
        $relationships = [];
        foreach ($node->relationship as $relationshipNode) {
            $relationships[] = $this->buildRelationshipMetadata($relationshipNode, $className, $reflection);
        }

        return $relationships;
    }
1190042
private function exprClass(Node $class_name) {
    $colon_node = new PartialNode();
    $this->mustMatch(T_DOUBLE_COLON, $colon_node);
    if ($this->currentType === T_STRING) {
      $class_constant = $this->mustMatchToken(T_STRING);
      if ($this->currentType === '(') {
        return $this->classMethodCall($class_name, $colon_node, $class_constant);
      }
      else {
        return $this->classConstant($class_name, $colon_node, $class_constant);
      }
    }
    elseif ($this->currentType === T_CLASS) {
      return $this->classNameScalar($class_name, $colon_node);
    }
    else {
      return $this->classVariable($class_name, $colon_node);
    }
  }
901187
public function getClassAnnotations($className, $annotationClassName = null)
    {
        $className = $this->prepareClassReflectionForUsage($className);

        $annotationClassName = $annotationClassName === null ? null : $this->cleanClassName($annotationClassName);
        if (!isset($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS])) {
            return [];
        }
        if ($annotationClassName === null) {
            return $this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS];
        }

        $annotations = [];
        foreach ($this->classReflectionData[$className][self::DATA_CLASS_ANNOTATIONS] as $annotation) {
            if ($annotation instanceof $annotationClassName) {
                $annotations[] = $annotation;
            }
        }

        return $annotations;
    }
1292345
private function buildPropertyMetadata(\SimpleXMLElement $propertyNode, $className, \ReflectionClass $reflection)
    {
        if (!isset($propertyNode['name']) || !isset($propertyNode['type'])) {
            throw new MappingException(
                sprintf('Class "%s" OGM XML property configuration is missing "name" or "type" attribute', $className)
            );
        }
        $name = (string) $propertyNode['name'];
        $nullable = true;
        if (isset($propertyNode['nullable'])) {
            if ((string) $propertyNode['nullable'] === 'true') {
                $nullable = true;
            }
            if ((string) $propertyNode['nullable'] === 'false') {
                $nullable = false;
            }
        }

        return new EntityPropertyMetadata(
            $name,
            $reflection->getProperty($name),
            new PropertyAnnotationMetadata(
                (string) $propertyNode['type'],
                isset($propertyNode['key']) ? (string) $propertyNode['key'] : null,
                $nullable
            )
        );
    }
189040
private function findClasses()
    {
        $classes       = array();
        $namespaceName = $this->getName();
        // classes can be only top-level nodes in the namespace, so we can scan them directly
        foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
            if ($namespaceLevelNode instanceof ClassLike) {
                $classShortName = $namespaceLevelNode->name->toString();
                $className = $namespaceName ? $namespaceName .'\\' . $classShortName : $classShortName;

                $namespaceLevelNode->setAttribute('fileName', $this->fileName);
                $classes[$className] = new ReflectionClass($className, $namespaceLevelNode);
            }
        }

        return $classes;
    }
327666
public static function getEventNames($className)
    {
        $result = [];
        $reflection = new \ReflectionClass($className);
        foreach ($reflection->getConstants() as $name => $value) {
            if (!preg_match('/^EVENT/', $name)) {
                continue;
            }
            $result[$name] = $value;
        }
        return $result;
    }
431717
private function fetchReflectionClass(Node\Name $node)
    {
        $className  = $node->toString();
        $isFQNClass = $node instanceof Node\Name\FullyQualified;
        if ($isFQNClass) {
            // check to see if the class is already loaded and is safe to use
            // PHP's ReflectionClass to determine if the class is user defined
            if (class_exists($className, false)) {
                $refClass = new \ReflectionClass($className);
                if (!$refClass->isUserDefined()) {
                    return $refClass;
                }
            }
            return new ReflectionClass($className);
        }

        if ('self' === $className) {
            if ($this->context instanceof \ReflectionClass) {
                return $this->context;
            } elseif (method_exists($this->context, 'getDeclaringClass')) {
                return $this->context->getDeclaringClass();
            }
        }

        if ('parent' === $className) {
            if ($this->context instanceof \ReflectionClass) {
                return $this->context->getParentClass();
            } elseif (method_exists($this->context, 'getDeclaringClass')) {
                return $this->context->getDeclaringClass()->getParentClass();
            }
        }

        if (method_exists($this->context, 'getFileName')) {
            /** @var ReflectionFileNamespace|null $fileNamespace */
            $fileName      = $this->context->getFileName();
            $namespaceName = $this->resolveScalarMagicConstNamespace();

            $fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName);
            return $fileNamespace->getClass($className);
        }

        throw new ReflectionException("Can not resolve class $className");
    }
795976
protected static function getClassProperties($className)
    {
        if (\class_exists($className, true)) {
            $reflection = new ReflectionClass($className);
            $value = $reflection->newInstanceWithoutConstructor();

            if (\is_subclass_of($value, Model::class, true)) {
                $attributes = Schema::getColumnListing($value->getTable());

                self::$eloquentClasses[$className] = $attributes;
            }
        }

        return (!empty(self::$eloquentClasses[$className])) ? self::$eloquentClasses[$className] : parent::getClassProperties($className);
    }
995902
private function getClassValidator($node)
    {
        $classStringName = $node['_type'].'_validator';
        $classStringNamespace = '\Volan\Validator\\';

        $classNames = [];
        $classNames[] = $classStringNamespace.$classStringName;
        $classNames[] = $classStringNamespace.$this->getPSRCompatibleClassName($classStringName);

        if (class_exists($classNames[0])) {
            $validatorClass = new $classNames[0]();
        } elseif (class_exists($classNames[1])) {
            $validatorClass = new $classNames[1]();
        } else {
            throw new Exception("Class validator {$classNames[0]}/{$classNames[1]} not found", ValidatorResult::ERROR_VALIDATOR_CLASS_NOT_FOUND);
        }

        $this->getLogger()->info("Class validator ".get_class($validatorClass)." exists");

        return $validatorClass;
    }
825001
private function getJoinsFields(string $className): array
    {
        $fields = [];
        $associations = $this->entityManager->getClassMetadata($className)->associationMappings;
        foreach ($associations as $association) {
            $field = [
                'name' => $association['fieldName'],
                'type' => $this->types->getJoinOn($association['targetEntity']),
            ];

            $fields[] = $field;
        }

        return $fields;
    }
437912
static public function getParents($className)
    {
        $parents = [];
        $parent = new \ReflectionClass($className);
        while (true) {
            $parent = $parent->getParentClass();
            if (!$parent) {
                break;
            } else {
                $parents[] = $parent->getName();
            }
        }
        return $parents;
    }
709271
public function create(string $className): array
    {
        $this->findIdentityField($className);

        $class = $this->metadata->getReflectionClass();
        $methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
        $fieldConfigurations = [];
        foreach ($methods as $method) {
            // Skip non-callable or non-instance
            if ($method->isAbstract() || $method->isStatic()) {
                continue;
            }

            // Skip non-getter methods
            $name = $method->getName();
            if (!preg_match($this->getMethodPattern(), $name)) {
                continue;
            }

            // Skip exclusion specified by user
            if ($this->isExcluded($method)) {
                continue;
            }

            $configuration = $this->methodToConfiguration($method);
            if ($configuration) {
                $fieldConfigurations[] = $configuration;
            }
        }

        return $fieldConfigurations;
    }
922370
private function prepareClassTreeInterfaces($className)
    {
        $interfacesArr = array();
        $reflection = new ReflectionClass($className);
        $interfacesArr[] = $reflection->getInterfaceNames();
        if (empty($interfacesArr[0])) {
            return array();
        }
        $classParents = class_parents($className);
        foreach ($classParents as $parentClass) {
            $reflection = new ReflectionClass($parentClass);
            $tmpInterfaces = $reflection->getInterfaceNames();
            if (empty($tmpInterfaces)) {
                return $interfacesArr;
            }
            array_unshift($interfacesArr, $tmpInterfaces);
        }
        return $interfacesArr;
    }
374579
public function compile(Node\File $node): array {
        if (is_null($node->class)) {
            throw new UnexpectedValueException('File without class cannot be saved');
        }

        $result = $node->uses;

        if (is_a($node->class, Node\Class_::class)) {
            $result[] = $this->compileClass($node->class);
        } else if (is_a($node->class, Node\Enum::class)) {
            $result[] = $this->compileEnum($node->class);
        }

        if (!is_null($node->namespace)) {
            $result = [new PHPNode\Stmt\Namespace_($node->namespace, $result)];
        }

        return $result;
    }
1340053
private function getCountChildren($nodeUid, $classname)
    {
        $query = sprintf(
                'SELECT COUNT(%s) FROM %s WHERE %s = ?', 
                $this->requiredFields['uid'], 
                $this->em->getClassMetadata($classname)->getTableName(), 
                $this->requiredFields['parent_uid']
        );

        $result = $this->em->getConnection()
                ->executeQuery($query, array($nodeUid), array(Type::STRING))
                ->fetchAll(\PDO::FETCH_COLUMN);

        return array_pop($result);
    }
1300683
protected function getClassNodeTransfer(ClassNode $node): ClassNodeTransfer
    {
        $className = $node->getName();
        $classNamespace = $node->getNamespaceName();
        $classFilePath = $node->getFileName();
        $classModuleName = $this->getFacade()->getModuleName($node);

        $pathTransfer = $this->getFacade()->getPath($classFilePath);
        $reflectionNodeClass = $this->getFacade()->getReflectionClassByNode($node);

        $classNodeTransfer = new ClassNodeTransfer();

        $classNodeTransfer->setClassName($className);
        $classNodeTransfer->setClassNamespace($classNamespace);
        $classNodeTransfer->setClassFilePath($classFilePath);
        $classNodeTransfer->setClassModuleName($classModuleName);
        $classNodeTransfer->setNode($node);
        $classNodeTransfer->setReflectionClass($reflectionNodeClass);
        $classNodeTransfer->setPathTransfer($pathTransfer);

        return $classNodeTransfer;
    }
892330
protected function parseMethods(SimpleXMLElement $class)
    {
        $methods = [];

        $className = (string)$class->full_name;
        $className = ltrim($className, '\\');

        foreach ($class->method as $method) {
            $methodName = (string)$method->name;

            $return = $method->xpath('docblock/tag[@name="return"]');

            if (count($return)) {
                $return = (string)$return[0]['type'];
            } else {
                $return = 'mixed';
            }

            $arguments = [];

            foreach ($method->argument as $argument) {
                $nArgument = [
                    'type' => (string)$argument->type,
                    'name' => (string)$argument->name
                ];

                $tags = $method->xpath(
                    sprintf('docblock/tag[@name="param" and @variable="%s"]', $nArgument['name'])
                );

                if (count($tags)) {
                    $tag = $tags[0];

                    if ((string)$tag['type']) {
                        $nArgument['type'] = (string)$tag['type'];
                    }

                    if ((string)$tag['description']) {
                        $nArgument['description'] = (string)$tag['description'];
                    }

                    if ((string)$tag['variable']) {
                        $nArgument['name'] = (string)$tag['variable'];
                    }
                }

                $arguments[] = $nArgument;
            }

            $argumentStr = implode(', ', array_map(function($argument) {
                $return = $argument['name'];

                if ($argument['type']) {
                    $return = $argument['type'] . ' ' . $return;
                }

                return $return;
            }, $arguments));

            $signature = sprintf('%s %s::%s(%s)', $return, $className, $methodName, $argumentStr);

            $methods[$methodName] = [
                'name'        => $methodName,
                'description' => (string)$method->docblock->description . "\n\n" . (string)$method->docblock->{'long-description'},
                'visibility'  => (string)$method['visibility'],
                'abstract'    => ((string)$method['abstract']) == "true",
                'static'      => ((string)$method['static']) == "true",
                'deprecated'  => count($class->xpath('docblock/tag[@name="deprecated"]')) > 0,
                'signature'   => $signature,
                'arguments'   => $arguments,
                'definedBy'   => $className,
            ];
        }

        return $methods;
    }