@param  string $doc

@return \ArrayIterator
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);
    }
208643
public function detectNamespacesFromDocument( $doc )
	{
		$namespaces	= self::getNamespacesFromDocument( $element );
		$this->namespaces	= array_merge( $this->namespaces, $namespaces );
		return count( $namespaces );
	}
531923
public function formatReturn($doc = [])
    {
        $json = '{<br>';
        $data = $this->config['return_format'];
        $returns = isset($doc['return']) ? $doc['return'] : [];
        foreach ($data as $name=>$value) {
            if($name != 'data' || (empty($returns) && $name == 'data')){
                $json .= '&nbsp;&nbsp;"'.$name.'":'.$value.',<br>';
            }
        }
        if( !empty($returns) ) {
            $json .= '&nbsp;&nbsp;"data":{<br/>';
            foreach ($returns as $val)
            {
                list($name, $value) =  explode(":", trim($val));
                if(strpos($value, '@') != false){
                    $json .= $this->string2jsonArray($doc, $val, '&nbsp;&nbsp;&nbsp;&nbsp;');
                }else{
                    $json .= '&nbsp;&nbsp;&nbsp;&nbsp;' . $this->string2json(trim($name), $value);
                }
            }
            $json .= '&nbsp;&nbsp;}<br/>';
        }
        $json .= '}';
        return $json;
    }
854897
public function initialize(array &$docs)
    {
        $doc_keys = range(0,count($docs)-1);
        $topic_keys = range(0,$this->ntopics-1);

        // initialize the arrays
        $this->words_in_doc = array_fill_keys(
            $doc_keys,
            0
        );
        $this->words_in_topic = array_fill_keys(
            $topic_keys,
            0
        );
        $this->count_docs_topics = array_fill_keys(
            $doc_keys,
            array_fill_keys(
                $topic_keys,
                0
            )
        );
        $this->count_topics_words = array_fill_keys(
            $topic_keys,
            array()
        );
        $this->word_doc_assigned_topic = array_fill_keys(
            $doc_keys,
            array()
        );
        $this->voc = array();

        foreach ($docs as $i=>$doc) {
            $this->words_in_doc[$i] = count($doc);
            foreach ($doc as $idx=>$w) {
                // choose a topic randomly to assign this word to
                $topic = (int) ($this->mt->generate()*$this->ntopics);

                //$this->words_in_doc[$i]++;
                $this->words_in_topic[$topic]++;
                $this->count_docs_topics[$i][$topic]++;

                if (!isset($this->count_topics_words[$topic][$w]))
                    $this->count_topics_words[$topic][$w]=0;
                $this->count_topics_words[$topic][$w]++;

                $this->word_doc_assigned_topic[$i][$idx] = $topic;

                $this->voc[$w] = 1;
            }
        }
        $this->voccnt = count($this->voc);
        $this->voc = array_keys($this->voc);
    }
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;
    }
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)
        ;
    }
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];
    }
1251130
public function toDOM(\DOMDocument $doc): \DOMNode
    {
        $paragraph = $doc->createElement('p');

        $this->customAttributesToDOM($paragraph);
        $this->containerToDOM($doc, $paragraph);

        return $paragraph;
    }
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);
    }
750595
public function getIterator()
    {
        return new \ArrayIterator(array(
            'cod' => $this->getCod(),
            'cod_amount' => $this->getCodAmount(),
            'exw' => $this->getExw(),
            'rod' => $this->getRod(),
            'pod' => $this->getPod(),
            'exc' => $this->getExc(),
            'ident' => $this->getIdent(),
            'daw' => $this->getDaw(),
            'ps' => $this->getPs(),
            'pr' => $this->getPr(),
            's10' => $this->getS10(),
            's12' => $this->getS12(),
            'sat' => $this->getSat(),
            'ow' => $this->getOw(),
            'srs' => $this->getSrs()
        ));
    }
890653
public function normalize(ServerDoc $doc) : array
    {
        // Info
        $rawInfo = $tagsDoc = $errorsDoc = [];
        if (null !== $doc->getName()) {
            $rawInfo['info']['name'] = $doc->getName();
        }
        if (null !== $doc->getVersion()) {
            $rawInfo['info']['version'] = $doc->getVersion();
        }

        // Tags
        $tagDocList = array_map([$this->tagDocNormalizer, 'normalize'], $doc->getTagList());
        if (count($tagDocList)) {
            $tagsDoc['tags'] = $tagDocList;
        }

        // Errors
        $serverErrorList = array_map([$this->errorDocNormalizer, 'normalize'], $doc->getServerErrorList());
        $globalErrorList = array_map([$this->errorDocNormalizer, 'normalize'], $doc->getGlobalErrorList());
        $errorList = array_merge($serverErrorList, $globalErrorList);
        if (count($errorList)) {
            $errorsDoc['errors'] = $errorList;
        }

        return $rawInfo
            + $tagsDoc
            + ['methods' => array_map([$this->methodDocNormalizer, 'normalize'], $doc->getMethodList())]
            + $errorsDoc;
    }
231080
public function normalize(ServerDoc $doc) : array
    {
        return array_merge(
            $this->getMethodsExternalSchemaList($doc),
            $this->getMethodErrorsExternalSchemaList($doc),
            $this->getServerErrorsExtraSchemaList($doc)
        );
    }
834899
protected function get_current_other_users($doc) {
        global $USER;

        $users = array();
        if (($USER->id == $doc->get('owneruserid')) || (get_class($this) === 'message_sent')) {
            $users['currentuserid'] = $doc->get('owneruserid');
            $users['otheruserid'] = $doc->get('userid');
        } else {
            $users['currentuserid'] = $doc->get('userid');
            $users['otheruserid'] = $doc->get('owneruserid');
        }

        return $users;
    }
390101
public function toXML(DOMDocument $doc, $nodeName = "")
    {
        $node = $doc->createElement('array');

        foreach ($this->value as $value) {
            $node->appendChild($value->toXML($doc));
        }
        return $node;
    }
23131
public static function formatDocument($document)
    {
       $document = self::keepOnlyNumbers($document);
       switch (strlen($document)) {
            case 14:
                return ['number' => $document, 'type' => 'cnpj'];
                break;
            case 11:
                return ['number' => $document, 'type' => 'cpf'];
                break;
            default:
                throw new \Exception('Invalid document');
                break;
        }
    }
831214
public function getLocale($document)
    {
        if ($document instanceof LocaleBehavior) {
            return $document->getLocale();
        }

        if ($this->documentRegistry->hasDocument($document)) {
            return $this->documentRegistry->getLocaleForDocument($document);
        }

        return;
    }
490417
function doc_builder(doc) {
				if(is.array(doc)) {
					return ARRAY(doc).map(_doc_builder).valueOf();
				}
				return _doc_builder(doc);
			}