@param TypeDoc $docObject

@return array

@throws \ReflectionException
967195
public function normalize(TypeDoc $docObject) : array
    {
        $docArray = [];

        $docArray = $this->appendIfNotNull($docArray, 'description', $docObject->getDescription());

        return $docArray
            + ['type' => $this->normalizeSchemaType($docObject)]
            + ['nullable' => $docObject->isNullable()]
            + ['required' => $docObject->isRequired()]
            + $this->appendMisc($docObject)
            + $this->appendDocEnum($docObject)
            + $this->appendMinMax($docObject)
            + $this->appendCollectionDoc($docObject)
        ;
    }
267223
protected function getSiblingDocList(CollectionDoc $docObject) : array
    {
        $docArray = [];
        foreach ($docObject->getSiblingList() as $siblingDocObject) {
            $siblingDocArray = $this->normalize($siblingDocObject);
            // Use name if :
            // - parent is object
            // - parent is array and name is an integer
            if ($docObject instanceof ObjectDoc
                || (
                    $docObject instanceof ArrayDoc
                    && is_int($siblingDocObject->getName())
                )
            ) {
                $docArray[$siblingDocObject->getName()] = $siblingDocArray;
            } else {
                $docArray[] = $siblingDocArray;
            }
        }

        return $docArray;
    }
1032288
protected function getFixableMethodAnnotations(File $phpCsFile, int $docBlockStartIndex, int $docBlockEndIndex): array
    {
        $tokens = $phpCsFile->getTokens();

        $path = $this->findBasePath($phpCsFile->getFilename());
        if (!$path) {
            // We cannot fix it then for now
            return [];
        }

        $annotations = [];
        for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
            if ($tokens[$i]['code'] !== T_DOC_COMMENT_TAG || $tokens[$i]['content'] !== '@method') {
                continue;
            }

            // T_DOC_COMMENT_STRING invalid, another sniff should check on this
            if (strpos($tokens[$i + 2]['content'], ' ') === false) {
                continue;
            }

            [$class, $method] = explode(' ', $tokens[$i + 2]['content'], 2);

            $ignoredMethods = [
                'getFactory()',
                'getConfig()',
                'getSharedConfig()',
                'getApplication()',
            ];
            if (in_array($method, $ignoredMethods, true)) {
                continue;
            }

            if (substr($class, -9) === 'Interface' || substr($class, 0, 5) === '\\Orm\\') {
                continue;
            }
            if (!preg_match('/^[A-Z]/', $class)) {
                continue;
            }
            if ($this->isAbstract($class)) {
                continue;
            }

            $interface = $class . 'Interface';
            $interfacePathElement = str_replace('\\', DIRECTORY_SEPARATOR, $interface);
            $interfacePath = $path . $interfacePathElement . '.php';

            if (!file_exists($interfacePath)) {
                $phpCsFile->addError(
                    sprintf('Interface missing for %s annotation of %s', $method, $class),
                    $i,
                    'Annotation.Interface.Missing'
                );
                continue;
            }

            $annotation = [
                'index' => $i,
                'method' => $method,
                'class' => $class,
                'interface' => $interface,
            ];

            $annotations[] = $annotation;
        }

        return $annotations;
    }
909440
public function deserialize($serializedObject, $objectClass)
    {
        $result = json_decode($serializedObject, true);

        $article = $this->serializer->deserialize(
            $result['object'],
            $this->articleDocumentClass,
            'json',
            DeserializationContext::create()
                ->setSerializeNull(true)
                ->setGroups(['preview'])
        );

        foreach ($article->getChildren() as $child) {
            $child->setParent($article);
        }

        if (1 === $result['pageNumber']) {
            return $article;
        }

        $children = array_values($article->getChildren());

        $object = $children[$result['pageNumber'] - 2];

        return $object;
    }
1044796
public static function document($doc)
    {
        $type = 1;
        $valid = self::cpf($doc);
        if ($valid == false) {
            $type = 2;
            $valid = self::cnpj($doc);
        }
        if ($valid == false) {
            return false;
        }
        return ['type' => $type, 'valid' => $valid];
    }
628712
protected function getDocBlockExtraParameterRefTags($docBlock)
	{
		$results = [];
		$apiExtraParameterRefTags = $docBlock->getTagsByName('OpenApiExtraParameterRef');

		foreach ($apiExtraParameterRefTags as $apiExtraParameterRefTag) {
			$apiExtraParameterRef = trim(str_replace('@OpenApiExtraParameterRef', '', $apiExtraParameterRefTag->render()));
			$results[] = $apiExtraParameterRef;
		}

		return $results;
	}
289820
protected function getServerErrorsExtraSchemaList(ServerDoc $doc) : array
    {
        $list = [];
        foreach ($doc->getGlobalErrorList() as $errorDoc) {
            $key = $this->definitionRefResolver->getErrorDefinitionId(
                $errorDoc,
                DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
            );
            $list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
        }

        foreach ($doc->getServerErrorList() as $errorDoc) {
            $key = $this->definitionRefResolver->getErrorDefinitionId(
                $errorDoc,
                DefinitionRefResolver::SERVER_ERROR_DEFINITION_TYPE
            );
            $list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
        }

        return $list;
    }
992203
public function normalize(MethodDoc $doc) : array
    {
        $docDescription = $docTags = $paramsSchema = $responseSchema = [];

        if (null !== $doc->getDescription()) {
            $docDescription['description'] = $doc->getDescription();
        }
        if (count($doc->getTagList())) {
            $docTags['tags'] = $doc->getTagList();
        }
        if (null !== $doc->getParamsDoc()) {
            $paramsSchema = [
                'params' => $this->typeDocNormalizer->normalize($doc->getParamsDoc())
            ];
        }
        // Create custom result schema only if provided
        if (null !== $doc->getResultDoc()) {
            $responseSchema['result'] = $this->typeDocNormalizer->normalize($doc->getResultDoc());
        }


        return [
            'identifier' => $doc->getIdentifier(),
            'name' =>$doc->getMethodName(),
        ]
            + $docDescription
            + $docTags
            + $paramsSchema
            + $responseSchema
            + $this->appendErrorsSchema($doc)
        ;
    }
727262
public static function parseDocTypeObject($type)
    {
        if ($type instanceof \phpDocumentor\Reflection\Types\Object_) {
            $tmpObject = (string) $type->getFqsen();
            if ($tmpObject) {
                return $tmpObject;
            }

            return 'object';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Compound) {
            $types = [];
            foreach ($type as $subType) {
                $types[] = self::parseDocTypeObject($subType);
            }

            return $types;
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Array_) {
            $valueTypeTmp = $type->getValueType() . '';
            if ($valueTypeTmp !== 'mixed') {
                return $valueTypeTmp . '[]';
            }

            return 'array';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Null_) {
            return 'null';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Mixed_) {
            return 'mixed';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Scalar) {
            return 'string|int|float|bool';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Boolean) {
            return 'bool';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Callable_) {
            return 'callable';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Float_) {
            return 'float';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\String_) {
            return 'string';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Integer) {
            return 'int';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Void_) {
            return 'void';
        }

        if ($type instanceof \phpDocumentor\Reflection\Types\Resource_) {
            return 'resource';
        }

        return $type . '';
    }
1113649
public function extract( $object )
    {
        $result = array();
        $type   = $object->paragraph->type;

        $result['paragraph-' . $type] = $this->getParagraphMapper()
                                             ->extract( $object->paragraph );

        $propertyHydrator = $this->getHydrateSimpleProperties();

        foreach ( $object->rules as $key => $rule )
        {
            $result['customize-' . $key] = $propertyHydrator->extract( $rule )
                                                              [ 'properties' ];
        }

        return $result;
    }
955335
public static function fetchAllAnnotationsFromDocblock($docblock)
    {
        $annotations = [];
        if (!preg_match_all(sprintf(self::$regex, '(\w+)'), $docblock, $matched)) {
            return $annotations;
        }
        foreach ($matched[1] as $k => $annotation) {
            if (!isset($annotations[$annotation])) {
                $annotations[$annotation] = [];
            }
            $annotations[$annotation][] = $matched[2][$k];
        };
        return $annotations;
    }
585826
protected function getDocForObject($docBlock, array $objects = []): array
    {
        $objectName = $docBlock->getObjectName();

        if (!isset($objects[$objectName])) {
            $object = new SmdSimpleObject();
            $object->name = $objectName;
            $objects[$objectName] = $object;
        } else {
            $object = $objects[$objectName];
        }

        $object->parameters = $this->getExtendedParameters($docBlock, $object->parameters);

        return $objects;
    }
262375
public function normalize(MethodDoc $method) : array
    {
        $docTags = [];

        if (count($method->getTagList())) {
            $docTags['tags'] = $method->getTagList();
        }

        return [
                'summary' => sprintf('"%s" json-rpc method', $method->getMethodName()),
            ]
            + $this->getDescriptionDoc($method)
            + $docTags
            + [
                'operationId' => $method->getIdentifier(),
                'consumes' => ['application/json'],
                'produces' => ['application/json'],
                'parameters' => [
                    [
                        'in' => 'body',
                        'name' => 'JsonRpc request',
                        'required' => true,
                        'schema' => $this->requestDocTransformer->normalize($method)
                    ]
                ],
                'responses' => [
                    '200' => [
                        'description' => 'JSON-RPC response',
                        'schema' => $this->responseDocNormalizer->normalize($method),
                    ]
                ]
            ]
        ;
    }
679374
private function computeDoc(Documentation $object, array $classes): array
    {
        $doc = ['@context' => $this->getContext(), '@id' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT]), '@type' => 'hydra:ApiDocumentation'];

        if ('' !== $object->getTitle()) {
            $doc['hydra:title'] = $object->getTitle();
        }

        if ('' !== $object->getDescription()) {
            $doc['hydra:description'] = $object->getDescription();
        }

        $doc['hydra:entrypoint'] = $this->urlGenerator->generate('api_entrypoint');
        $doc['hydra:supportedClass'] = $classes;

        return $doc;
    }
902794
public function getByEntity($entityClass, $id, $locale, $object = null)
    {
        $metadata = $this->structureMetadataFactory->getStructureMetadata('page', $object->getStructureType());

        return [
            '_controller' => $metadata->getController(),
            'view' => $metadata->getView(),
            'object' => $object,
            'structure' => $this->documentToStructure($object),
        ];
    }
1049475
public function parse($docblock)
    {
        // parse @key value
        preg_match_all('#@([a-zA-Z]+)(.*)(\*/|\n)#', $docblock, $out, PREG_SET_ORDER);

        // compile data
        $annotations = [];
        foreach($out as $row) {
            $key = trim($row[1]);
            $annotations[$key] = $this->resolveValue($row[2]);
        }

        return $annotations;
    }
1189016
private function extractDocTags(array $arguments, ReflectionFunctionAbstract $function): array
    {
        if (!$function->getDocComment()) {
            return $arguments;
        }

        $context = (new Types\ContextFactory())->createFromReflector($function);
        $docBlock = DocBlockFactory::createInstance()->create($function, $context);

        /** @var Param $paramTag */
        foreach ($docBlock->getTagsByName('param') as $paramTag) {
            $name = $paramTag->getVariableName();
            if (!isset($arguments[$name])) {
                continue;
            }
            $arg = $arguments[$name];

            $type = $paramTag->getType();
            if ($type !== null) {
                if ($type instanceof Types\Array_) {
                    $type = $type->getValueType();
                    $arg->optional = true;
                    $arg->default = $arg->default ?? [];
                }

                if ($type instanceof Types\Object_ && $type->getFqsen()) {
                    $arg->key = ltrim((string)$type->getFqsen(), '\\');
                }
            }

            $paramDescription = (string)$paramTag->getDescription();

            if (preg_match(static::INJECT_TAG_REGEX, $paramDescription, $matches)) {
                $arg->key = $matches[1];
            }

            if (preg_match(static::OPTIONAL_TAG_REGEX, $paramDescription)) {
                $arg->optional = true;
            }
        }

        return $arguments;
    }