Build all the annotation instances for an annotation tag.

@param \Wingu\OctopusCore\Reflection\Annotation\AnnotationDefinition[] $annotationDefinitions The annotation tag name.
@return \Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface[]
960034
protected function buildAnnotationsInstances(array $annotationDefinitions)
    {
        $result = array();
        foreach ($annotationDefinitions as $annotationDefinition) {
            $result[] = $this->buildAnnotationInstance($annotationDefinition);
        }

        return $result;
    }
222799
public function useSerialization(SerializationDefinition $definition)
    {
        $this->settings->set(SerializationDefinition::class, $definition);

        return $definition->createConfigurator($this->settings);
    }
308666
private function parseAnnotations($annotations)
    {
        // parse array from (numeric key => 'annotation <value>') to (annotation => value)
        $methodServices = [];
        foreach ($annotations as $annotation) {
            if (!preg_match('/^(\w+)\s+\$(\w+)\s+([\w\.\@\%]+)/', $annotation, $matches)) {
                continue;
            }

            array_shift($matches);
            $tag = array_shift($matches);
            if ($tag == self::SERVICE_DOC_TAG) {
                list($argument, $service) = $matches;
                $methodServices[$argument] = $service;
            }
        }

        return $methodServices;
    }
314881
private function parseClassAnnotations(string $className, array $annotation, array $classAnnotations)
    {
        foreach ($classAnnotations as $classAnnotation) {
            $annotationClassName = get_class($classAnnotation);
            $classNameTmp        = str_replace('\\', '/', $annotationClassName);
            $classFileName       = basename($classNameTmp);
            $beanNamespaceTmp    = dirname($classNameTmp, 2);
            $beanNamespace       = str_replace('/', '\\', $beanNamespaceTmp);

            $annotationWrapperClassName = "{$beanNamespace}\\Wrapper\\{$classFileName}Wrapper";

            if (!class_exists($annotationWrapperClassName)) {
                continue;
            }

            /* @var WrapperInterface $wrapper */
            $wrapper = new $annotationWrapperClassName($this);

            // wrapper extend
            foreach ($this->componentNamespaces as $componentNamespace) {
                $annotationWrapperExtendClassName = "{$componentNamespace}\\Bean\\Wrapper\\Extend\\{$classFileName}Extend";
                if (!class_exists($annotationWrapperExtendClassName)) {
                    continue;
                }
                $extend = new $annotationWrapperExtendClassName();
                $wrapper->addExtends($extend);
            }

            $objectDefinitionAry = $wrapper->doWrapper($className, $annotation);
            if ($objectDefinitionAry != null) {
                list($beanName, $objectDefinition) = $objectDefinitionAry;
                $this->definitions[$beanName] = $objectDefinition;
            }
        }
    }
189503
protected function filterContractAnnotation(array $annotations): array
    {
        $contractAnnotations = [];

        foreach ($annotations as $annotation) {
            $annotationClass = \get_class($annotation);

            if (\in_array($annotationClass, $this->expectedAnnotationTypes, true)) {
                $contractAnnotations[] = $annotation;
            }
        }

        return $contractAnnotations;
    }
202150
private function filterDefinitions(array $definitions): array
    {
        return \array_filter($definitions, function (Definition $definition) {
            foreach (self::SERVICE_SUBCLASS_TAG_MAPPING as $tagName) {
                if ($definition->hasTag($tagName)) {
                    return \is_subclass_of($definition->getClass(), AliasedInterface::class);
                }
            }

            return false;
        });
    }
271143
protected function buildSection($sectionName, array $sectionDefinition): SectionInterface
    {
        $section = $this->sectionBuilder->buildSection($sectionName, $sectionDefinition);

        foreach ($this->filterCommands($sectionDefinition) as $commandName => $commandDefinition) {
            $section->addCommand($this->commandBuilder->buildCommand($commandName, $commandDefinition));
        }

        return $section;
    }
690792
private function convertToFieldDefintionObject($identifier, $fieldDefinition)
    {
        if ($fieldDefinition instanceof FieldDefinitionObject) {
            return $fieldDefinition;
        } else {
            return new FieldDefinitionObject($identifier, $this, $fieldDefinition);
        }
    }
227827
public function setDefinition($reportDefinition)
    {
        if ($reportDefinition instanceof ReportDefinitionBuilder) {
            $reportDefinition = $reportDefinition->build();
        }

        $this->definition = $reportDefinition;

        return $this;
    }
348632
public function groupFieldDefinitions(array $fieldDefinitions): array
    {
        $fieldDefinitionsByGroup = [];
        foreach ($this->fieldsGroupsListHelper->getGroups() as $groupId => $groupName) {
            $fieldDefinitionsByGroup[$groupId] = [
                'name' => $groupName,
                'fieldDefinitions' => [],
            ];
        }

        foreach ($fieldDefinitions as $fieldDefinition) {
            $groupId = $fieldDefinition->fieldGroup;
            if (!$groupId) {
                $groupId = $this->fieldsGroupsListHelper->getDefaultGroup();
            }

            $fieldDefinitionsByGroup[$groupId]['fieldDefinitions'][] = $fieldDefinition;
            $fieldDefinitionsByGroup[$groupId]['name'] = $fieldDefinitionsByGroup[$groupId]['name'] ?? $groupId;
        }

        return $fieldDefinitionsByGroup;
    }
1068894
public function compile($definition)
    {
        $validators = [];

        if (isset($definition->validators)) {
            if (isset($definition->validators['properties'])) {
                foreach ($definition->validators['properties'] as $property => $validatorDefinitions) {
                    foreach ($validatorDefinitions as $validator) {
                        $validators[$property][] = parent::compile($validator);
                    }
                }
            }
        }

        return new ObjectValidator($validators);
    }
721138
public function addDefinitions(array $definitions)
    {
        foreach ($definitions as $name => $definition) {
            if (!($definition instanceof DefinitionInterface)) {
                throw new DcGeneralInvalidArgumentException(
                    'Definition ' . $name . ' does not implement DefinitionInterface.'
                );
            }

            $this->setDefinition($name, $definition);
        }

        return $this;
    }
651827
protected function indexAnnotationsByType(array $annotations)
    {
        $indexed = array();

        // if we are receiving annotations indexed by number, transform it to by class name
        if ($annotations && is_numeric(key($annotations))) {
            foreach ($annotations as $annotation) {
                $annotationType = get_class($annotation);

                if (isset($indexed[$annotationType]) && !is_array($indexed[$annotationType])) {
                    $indexed[$annotationType] = array($indexed[$annotationType], $annotation);
                } elseif (isset($indexed[$annotationType])) {
                    $indexed[$annotationType][] = $annotation;
                } else {
                    $indexed[$annotationType] = $annotation;
                }
            }
        }

        return $indexed;
    }
484864
protected function annotationToArray($annotation)
    {
        $options = array();
        foreach ((array) $annotation as $key => $value) {
            if ($value !== null) {
                $options[$key] = $value;
            }
        }

        return $options;
    }
346633
public function registerClasses(array $classDefinitions)
    {
        foreach ($classDefinitions as $className => $formatDefinitions) {
            $this->registerClass($className, $formatDefinitions);
        }
    }
856785
public function buildDefinition($definition)
    {
        if (is_callable($definition)) {
            return $definition;
        }

        if (is_array($definition) && isset($definition['component'])) {
            return new Listener(
                $definition['component'],
                $definition['method'] ?: null,
                $definition['arguments'] ? (array) $definition['arguments'] : []
            );
        }

        throw new AppException('Invalid listener format, must be callable or array with component key');
    }
192646
private function getDictionaryBuilder(DictionaryDefinition $definition): DictionaryBuilderInterface
    {
        if (!$this->dictionaryBuilders->has($typeName = $definition->getType())) {
            $typeName = 'default';
        }

        return $this->dictionaryBuilders->get($typeName);
    }