Used in inlines to check for more inlines or quoted strings
@access private
@return array
482124
private function _inlineEscape($inline) {
		// There's gotta be a cleaner way to do this...
		// While pure sequences seem to be nesting just fine,
		// pure mappings and mappings with sequences inside can't go very
		// deep.  This needs to be fixed.

		$saved_strings = array();

		// Check for strings
		$regex = '/(?:(")|(?:\'))((?(1)[^"]+|[^\']+))(?(1)"|\')/';
		if (preg_match_all($regex,$inline,$strings)) {
			$saved_strings = $strings[0];
			$inline  = preg_replace($regex,'YAMLString',$inline);
		}
		unset($regex);

		// Check for sequences
		if (preg_match_all('/\[(.+)\]/U',$inline,$seqs)) {
			$inline = preg_replace('/\[(.+)\]/U','YAMLSeq',$inline);
			$seqs   = $seqs[0];
		}

		// Check for mappings
		if (preg_match_all('/{(.+)}/U',$inline,$maps)) {
			$inline = preg_replace('/{(.+)}/U','YAMLMap',$inline);
			$maps   = $maps[0];
		}

		$explode = explode(', ',$inline);


		// Re-add the sequences
		if (!empty($seqs)) {
			$i = 0;
			foreach ($explode as $key => $value) {
				if (strpos($value,'YAMLSeq') !== FALSE) {
					$explode[$key] = str_replace('YAMLSeq',$seqs[$i],$value);
					++$i;
				}
			}
		}

		// Re-add the mappings
		if (!empty($maps)) {
			$i = 0;
			foreach ($explode as $key => $value) {
				if (strpos($value,'YAMLMap') !== FALSE) {
					$explode[$key] = str_replace('YAMLMap',$maps[$i],$value);
					++$i;
				}
			}
		}


		// Re-add the strings
		if (!empty($saved_strings)) {
			$i = 0;
			foreach ($explode as $key => $value) {
				while (strpos($value,'YAMLString') !== FALSE) {
					$explode[$key] = preg_replace('/YAMLString/',$saved_strings[$i],$value, 1);
					++$i;
					$value = $explode[$key];
				}
			}
		}

		return $explode;
	}
238958
protected function _parseFunction() {
        $this->_content = preg_replace('`' . $this->_openTag . $this->_name . preg_quote($this->markup['function'][0]) . $this->_spaceR . preg_quote($this->markup['function'][1]) . $this->_space . '=' . $this->_space . '"' . $this->_space . '(.+)' . $this->_space . '"' . $this->_space . '/' . $this->_closeTag . '`isU', '<?php $1 ?>', $this->_content);
    }
407709
public function getStdOutAsArray() : array
    {
        if (null === $this->buffer) {
            $this->buffer = $this->textToBuffer();
        }
        return $this->buffer;
    }
675583
private function extractPlaceholders(): void
  {
    $unknown = [];

    preg_match_all('(@[A-Za-z0-9\_\.]+(\%type)?@)', $this->routineSourceCode, $matches);
    if (!empty($matches[0]))
    {
      foreach ($matches[0] as $placeholder)
      {
        if (isset($this->replacePairs[strtoupper($placeholder)]))
        {
          $this->replace[$placeholder] = $this->replacePairs[strtoupper($placeholder)];
        }
        else
        {
          $unknown[] = $placeholder;
        }
      }
    }

    $this->logUnknownPlaceholders($unknown);
  }
36419
protected function _parseVarFunc() {
        $this->_content = preg_replace('`' . preg_quote($this->markup['vars'][0]) . $this->_space . $this->_openTag . 'gc:function(.+)' . $this->_closeTag . $this->_space . preg_quote($this->markup['vars'][1]) . '`isU', '<?php echo ' . $this->_openTag . 'gc:function$1' . $this->_closeTag . '; ?>', $this->_content);
    }
486869
public function parseLines()
    {
        $text = [];

        while (($line = $this->nextLine()) !== false) {
            $line = rtrim($line);

            // Skip empty lines
            if ($line == "") {
                $text[] = null;
                continue;
            }

            // Look at start of line to detect valid blocktypes
            $blockTypes = [];
            $marker = $line[0];
            if (isset($this->blockTypes[$marker])) {
                foreach ($this->blockTypes[$marker] as $blockType) {
                    $blockTypes[] = $blockType;
                }
            }

            // Check if line is matching a detected blocktype
            foreach ($blockTypes as $blockType) {
                if ($this->{"block".$blockType}($line)) {
                    continue;
                }
            }
        }

        $text = implode("\n", $this->lines);

        return [
            "text" => $text,
            "frontmatter" => $this->frontmatter,
        ];
    }
391423
function orig() {
    	$lines = array();

    	foreach ($this->edits as $edit) {
    		if ($edit->orig)
    			array_splice($lines, sizeof($lines), 0, $edit->orig);
    	}
    	return $lines;
    }
577649
public function getQuotedString() {
    $str = (string) $this;
    
    if (mb_strpos($str, ' ') !== FALSE) {
      return escapeshellarg($str);
    }
    
    return $str;
  }
120803
protected function generateTraitUsesLines()
    {
        $code = array();
        foreach ($this->traitUses as $use) {
            $use->setIndentationString($this->getIndentationString());
            $use->setIndentationLevel($this->getIndentationLevel() + 1);
            $code[] = $use->generate();
            $code[] = null;
        }

        return $code;
    }
1102097
function scan($str) {
		$inline=['img','a','text','auto','code'];
		foreach ($inline as $func)
			$str=$this->{'_'.$func}($str);
		return $str;
	}
922158
protected function parseTag(): array
    {
        $return = [
            'status'  => false,
            'closing' => false,
            'node'    => null,
        ];
        if ($this->content->char() != '<') {
            // we are not at the beginning of a tag
            return $return;
        }

        // check if this is a closing tag
        if ($this->content->fastForward(1)->char() == '/') {
            // end tag
            $tag = $this->content->fastForward(1)
                                 ->copyByToken('slash', true);
            // move to end of tag
            $this->content->copyUntil('>');
            $this->content->fastForward(1);

            // check if this closing tag counts
            $tag = strtolower($tag);
            if (in_array($tag, $this->selfClosing)) {
                $return['status'] = true;

                return $return;
            } else {
                $return['status']  = true;
                $return['closing'] = true;
                $return['tag']     = strtolower($tag);
            }

            return $return;
        }

        $tag  = strtolower($this->content->copyByToken('slash', true));
        $node = new HtmlNode($tag);

        // attributes
        while ($this->content->char() != '>' &&
            $this->content->char() != '/') {
            $space = $this->content->skipByToken('blank', true);
            if (empty($space)) {
                $this->content->fastForward(1);
                continue;
            }

            $name = $this->content->copyByToken('equal', true);
            if ($name == '/') {
                break;
            }

            if (empty($name)) {
				$this->content->skipByToken('blank');
				continue;
            }

            $this->content->skipByToken('blank');
            if ($this->content->char() == '=') {
                $attr = [];
                $this->content->fastForward(1)
                              ->skipByToken('blank');
                switch ($this->content->char()) {
                    case '"':
                        $attr['doubleQuote'] = true;
                        $this->content->fastForward(1);
                        $string = $this->content->copyUntil('"', true, true);
                        do {
                            $moreString = $this->content->copyUntilUnless('"', '=>');
                            $string .= $moreString;
                        } while ( ! empty($moreString));
                        $attr['value'] = $string;
                        $this->content->fastForward(1);
                        $node->getTag()->$name = $attr;
                        break;
                    case "'":
                        $attr['doubleQuote'] = false;
                        $this->content->fastForward(1);
                        $string = $this->content->copyUntil("'", true, true);
                        do {
                            $moreString = $this->content->copyUntilUnless("'", '=>');
                            $string .= $moreString;
                        } while ( ! empty($moreString));
                        $attr['value'] = $string;
                        $this->content->fastForward(1);
                        $node->getTag()->$name = $attr;
                        break;
                    default:
                        $attr['doubleQuote']   = true;
                        $attr['value']         = $this->content->copyByToken('attr', true);
                        $node->getTag()->$name = $attr;
                        break;
                }
            } else {
                // no value attribute
                if ($this->options->strict) {
                    // can't have this in strict html
                    $character = $this->content->getPosition();
                    throw new StrictException("Tag '$tag' has an attribute '$name' with out a value! (character #$character)");
                }
                $node->getTag()->$name = [
                    'value'       => null,
                    'doubleQuote' => true,
                ];
                if ($this->content->char() != '>') {
                    $this->content->rewind(1);
                }
            }
        }

        $this->content->skipByToken('blank');
        if ($this->content->char() == '/') {
            // self closing tag
            $node->getTag()->selfClosing();
            $this->content->fastForward(1);
        } elseif (in_array($tag, $this->selfClosing)) {

            // Should be a self closing tag, check if we are strict
            if ($this->options->strict) {
                $character = $this->content->getPosition();
                throw new StrictException("Tag '$tag' is not self closing! (character #$character)");
            }

            // We force self closing on this tag.
            $node->getTag()->selfClosing();

            // Should this tag use a trailing slash?
            if(in_array($tag, $this->noSlash))
            {
                $node->getTag()->noTrailingSlash();
            }

        }

        $this->content->fastForward(1);

        $return['status'] = true;
        $return['node']   = $node;

        return $return;
    }
1178027
public function check()
    {
        $this->missing = [];
        $from          = $this->getDefaultLocale();
        $locales       = $this->getLocales();
        $ignored       = $this->getIgnoredTranslations();
        $fromTrans     = $this->getTranslations($from, $ignored);

        foreach ($locales as $to) {
            $toTrans = $this->getTranslations($to, $ignored);

            $this->diffMissing($toTrans, $fromTrans, $from);
            $this->diffMissing($fromTrans, $toTrans, $to);
        }

        return $this->missing;
    }
216967
protected function parseStatementNumber()
    {
        $results = [];
        if (preg_match('/:28C?:(.*)/', $this->getCurrentStatementData(), $results)
            && !empty($results[1])
        ) {
            return trim($results[1]);
        }

        return '';
    }
663047
public function getTagFiltersExpanded()
    {
        $tagFilters = $this->getTagFilters();
        if ($tagFilters === null) {
            $result = null;
        } else {
            $result = [];
            $m = null;
            foreach ($tagFilters as $tagFilter) {
                if (preg_match('/^\s*([<>=]+)\s*(\d+(?:\.\d+)?)\s*$/', $tagFilter, $m)) {
                    switch ($m[1]) {
                        case '<=':
                        case '<':
                        case '=':
                        case '>=':
                        case '>':
                            $result[] = ['operator' => $m[1], 'version' => $m[2]];
                            break;
                    }
                }
            }
        }

        return $result;
    }
313903
private function makeConstantStatements(): array
  {
    $width1    = 0;
    $width2    = 0;
    $constants = [];

    foreach ($this->constants as $constant => $value)
    {
      $width1 = max(mb_strlen($constant), $width1);
      $width2 = max(mb_strlen((string)$value), $width2);
    }

    $line_format = sprintf('  const %%-%ds = %%%dd;', $width1, $width2);
    foreach ($this->constants as $constant => $value)
    {
      $constants[] = sprintf($line_format, $constant, $value);
    }

    return $constants;
  }
167661
protected function getUseClauseVariables()
    {
        $begin = strpos($code = $this->getCode(), '(', $this->getUseIndex()) + 1;

        return explode(',', substr($code, $begin, strpos($code, ')', $begin) - $begin));
    }
411097
function &_getInlineTags($text)
    {
        $return = NULL;
        $tagStrings = preg_split('/{(@.+)}/sU', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        if ($tagStrings) {
            $inlineTags = NULL;
            $phpdoctor =& $this->_root->phpdoctor();
            foreach ($tagStrings as $tag) {
                if (substr($tag, 0, 1) == '@') {
                    $pos = strpos($tag, ' ');
                    if ($pos !== FALSE) {
                        $name = trim(substr($tag, 0, $pos));
                        $text = trim(substr($tag, $pos + 1));
                    } else {
                        $name = $tag;
                        $text = NULL;
                    }
                } else {
                    $name = '@text';
                    $text = $tag;
                }
                $data = NULL;
                $inlineTag =& $phpdoctor->createTag($name, $text, $data, $this->_root);
                $inlineTag->setParent($this->_parent);
                $inlineTags[] = $inlineTag;
            }
            $return =& $inlineTags;
        }

        return $return;
    }