@param TypeDoc $doc

@return array|mixed

@throws \ReflectionException
432685
public function normalize(TypeDoc $doc) : array
    {
        $siblingsDoc = $paramDocRequired = [];

        $siblingsDoc = $this->appendArrayDoc($doc, $siblingsDoc);
        list (
            $siblingsDoc,
            $paramDocRequired
            ) = $this->appendObjectDoc($doc, $siblingsDoc, $paramDocRequired);

        $format = ($doc instanceof StringDoc ? $doc->getFormat() : null);

        return $this->appendIfValueNotNull('description', $doc->getDescription())
            + ['type' => $this->schemaTypeNormalizer->normalize($doc)]
            + $this->appendIfValueNotNull('format', $format)
            + ['nullable' => $doc->isNullable()]
            + $paramDocRequired
            + $this->appendIfValueNotNull('default', $doc->getDefault())
            + $this->appendIfValueNotNull('example', $doc->getExample())
            + $this->appendIfValueHaveSiblings('enum', array_values($doc->getAllowedValueList()))
            + $this->getMinMaxDoc($doc)
            + $siblingsDoc
        ;
    }
1222802
private function getQueryForDocument(object $document) : array
    {
        $id = $this->uow->getDocumentIdentifier($document);
        $id = $this->class->getDatabaseIdentifierValue($id);

        $shardKeyQueryPart = $this->getShardKeyQuery($document);
        return array_merge(['_id' => $id], $shardKeyQueryPart);
    }
879669
public function setDocoptDefinition($doc) {
        if ($this->frozen)    throw new RuntimeException('Configuration of "'.get_class($this).'" is frozen');
        if (!is_string($doc)) throw new IllegalTypeException('Illegal type of parameter $doc: '.gettype($doc));

        $parser = new DocoptParser();
        $this->docoptResult = $parser->parse($doc);

        $this->docoptDefinition = $doc;
        return $this;
    }
607479
protected function docToArray(RpbSearchDoc $doc)
    {
        if ( ! $doc->hasFields()) {
            return [];
        }

        $values = [];

        foreach ($doc->fields as $pair) {
            $values[$pair->key][] = $pair->value;
        }

        return $values;
    }
157587
protected function getDocFromTypeConstraintOrPayloadDocIfExist(array $constraintList) : ?TypeDoc
    {
        $doc = null;
        // Check if a Type constraint exist or if a constraint have a type documentation
        foreach ($constraintList as $constraint) {
            $doc = $this->createDocFromConstraint($constraint);

            if (null !== $doc) {
                break;
            }
        }

        return $doc;
    }
550096
private function normalizeType(string $type) : ?TypeDoc
    {
        if (array_key_exists($type, self::MANAGED_TYPE_CLASS_LIST)) {
            $class = self::MANAGED_TYPE_CLASS_LIST[$type];

            return new $class();
        }

        return null;
    }
264271
private function guestCollectionType(Assert\Collection $constraint) : TypeDoc
    {
        // If only integer => array, else object
        $integerKeyList = array_filter(array_keys($constraint->fields), 'is_int');
        if (count($constraint->fields) === count($integerKeyList)) {
            return new ArrayDoc();
        }

        return new ObjectDoc();
    }
324173
protected function getTypesCollection()
    {
        if (null === $this->types) {
            $this->types = new Collection(
                array($this->type),
                $this->docblock ? $this->docblock->getContext() : null
            );
        }
        return $this->types;
    }
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),
                    ]
                ]
            ]
        ;
    }
645667
public function typeDesc()
    {
        // Cast SimpleXMLObject to string
        $type = (string)$this->type;
        return array_key_exists($type, self::$types) ? self::$types[$type] : '';
    }
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];
    }
837343
protected function appendDocEnum(TypeDoc $docObject) : array
    {
        $docArray = [];
        foreach ($docObject->getAllowedValueList() as $value) {
            $docArray['allowedValues'][] = $value;
        }

        return $docArray;
    }
1301869
public function getDocComment($prefix = "\t\t")
    {
        $serializer = new DocBlockSerializer(1, $prefix);

        if ($this->phpdoc) {
            if ($this->config->get('ide-helper.include_class_docblocks')) {
                // if a class doesn't expose any DocBlock tags
                // we can perform reflection on the class and
                // add in the original class DocBlock
                if (count($this->phpdoc->getTags()) === 0) {
                    $class = new ReflectionClass($this->root);
                    $this->phpdoc = new DocBlock($class->getDocComment());
                }
            }

            $this->removeDuplicateMethodsFromPhpDoc();
            return $serializer->getDocComment($this->phpdoc);
        }

        return '';
    }
17318
protected function appendArrayDoc(TypeDoc $doc, array $siblingsDoc) : array
    {
        // CollectionDoc should be managed as ArrayDoc
        if (!$doc instanceof ArrayDoc && get_class($doc) !== CollectionDoc::class) {
            return $siblingsDoc;
        }
        /** @var $doc ArrayDoc|CollectionDoc */
        // add mandatory "items" field
        if ($doc instanceof ArrayDoc && null !== $doc->getItemValidation()) {
            $siblingsDoc['items'] = $this->normalize($doc->getItemValidation());
        } else {
            $siblingsDoc['items']['type'] = $this->guessItemsType($doc->getSiblingList());
        }

        return $siblingsDoc;
    }
358053
protected static function parseDefaults($doc) {
        $defaults = [];
        foreach (static::parseSection('options:', $doc) as $section) {
            # FIXME corner case "bla: options: --foo"
            list (, $section) = explode(':', $section, 2);
            $splitTmp = array_slice(preg_split("/\n[ \t]*(-\S+?)/", "\n".$section, null, PREG_SPLIT_DELIM_CAPTURE), 1);
            $split = [];
            for ($size=sizeof($splitTmp), $i=0; $i < $size; $i+=2) {
                $split[] = $splitTmp[$i].(isset($splitTmp[$i+1]) ? $splitTmp[$i+1] : '');
            }
            $options = [];
            foreach ($split as $value) {
                if ($value[0] == '-') {
                    $options[] = Option::parse($value);
                }
            }
            $defaults = array_merge($defaults, $options);
        }
        return new \ArrayIterator($defaults);
    }
113587
public function parse($docPath)
    {
        if ( ! is_dir($docPath)) {
            throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $docPath));
        }

        $sorter = function(\SplFileInfo $a, \SplFileInfo $b) {
            $aIsDir = $a->isDir();
            $bIsDir = $b->isDir();

            if ($aIsDir !== $bIsDir) {
                return $aIsDir ? -1 : 1;
            }

            return -1 * strcmp($a->getRealPath(), $b->getRealPath());
        };

        $this->classes = $this->functions = $this->constants = $this->aliasedFunctions = array();
        foreach (Finder::create()->in($docPath)->name('*.xml')->sort($sorter) as $file) {
            assert($file instanceof \SplFileInfo);
            $this->file = $file;

            $content = file_get_contents($file->getRealPath());
            $content = preg_replace('#<refsect1 role="(?:examples|notes|seealso)">.*?</refsect1>#s', '', $content);
            $content = preg_replace(self::$undefinedEntities, '', $content);
            $content = preg_replace(array_keys(self::$entitySubstitutes), array_values(self::$entitySubstitutes), $content);

            if ('' === trim($content)) {
                continue;
            }

            $doc = simplexml_load_string($content);
            $doc->registerXPathNamespace('search', 'http://docbook.org/ns/docbook');
            if (isset($doc->refnamediv)) {
                // Ignore methods, we will parse them as part of the class.
                if (false !== strpos((string) $doc->refnamediv->refname, '::')) {
                    $this->parseMethod($doc);

                    continue;
                }

                $this->parseFunction($doc);

                continue;
            }

            $this->tryParsingClass($doc);
            $this->tryParsingConstant($doc);
        }

        if ( ! empty($this->aliasedFunctions)) {
            foreach ($this->functions as $function) {
                $aliasedNames = array_keys($this->aliasedFunctions, $function->getName(), true);

                if (empty($aliasedNames)) {
                    continue;
                }

                foreach ($aliasedNames as $name) {
                    $newFunction = clone $function;
                    $newFunction->setName($name);
                    $newFunction->setAttribute('alias_of', $function->getName());
                    $this->functions[] = $newFunction;
                }
            }
        }

        foreach ($this->classes as $class) {
            $this->typeRefiner->refineClass($class);
        }

        $rs = array('classes' => $this->classes, 'functions' => $this->functions, 'constants' => $this->constants);
        $this->classes = $this->functions = $this->constants = $this->aliasedFunctions = null;

        return $rs;
    }
598401
public function getDocumentActualData($document)
    {
        $class = $this->dm->getClassMetadata(get_class($document));
        $actualData = array();
        foreach ($class->reflFields as $name => $refProp) {
            $mapping = $class->fieldMappings[$name];
            // skip not saved fields
            if (isset($mapping['notSaved']) && $mapping['notSaved'] === true) {
                continue;
            }
            $value = $refProp->getValue($document);
            if (isset($mapping['file']) && ! $value instanceof GridFSFile) {
                $value = new GridFSFile($value);
                $class->reflFields[$name]->setValue($document, $value);
                $actualData[$name] = $value;
            } elseif ((isset($mapping['association']) && $mapping['type'] === 'many')
                && $value !== null && ! ($value instanceof PersistentCollection)) {
                // If $actualData[$name] is not a Collection then use an ArrayCollection.
                if ( ! $value instanceof Collection) {
                    $value = new ArrayCollection($value);
                }

                // Inject PersistentCollection
                $coll = new PersistentCollection($value, $this->dm, $this);
                $coll->setOwner($document, $mapping);
                $coll->setDirty( ! $value->isEmpty());
                $class->reflFields[$name]->setValue($document, $coll);
                $actualData[$name] = $coll;
            } else {
                $actualData[$name] = $value;
            }
        }
        return $actualData;
    }