Parse fenced code blocks.

@param array $line
@return array
438166
protected function blockFencedCode($line)
    {
        $regex = '/^([' . $line[ 'text' ][ 0 ] . ']{3,})[ ]*([\w-]+)?[ ]*$/';

        if (preg_match($regex, $line[ 'text' ], $matches)) {
            $element = [
                'name' => 'code',
                'text' => '',
            ];

            if (isset($matches[ 2 ])) {
                $class = $this->getConfig('fenced_code_lang_class', 'prettyprint lang-{LANG}');
                $class = str_replace('{LANG}', $matches[2], $class); //'prettyprint lang-' . $matches[ 2 ];

                $element[ 'attributes' ] = [ 'class' => $class ];
            }

            $block = [
                'char'    => $line[ 'text' ][ 0 ],
                'element' => [
                    'name'    => 'pre',
                    'handler' => 'element',
                    'text'    => $element,
                ],
            ];

            return $block;
        }
    }
1313503
private function parseCodeLine(string $line): Line
    {
        if (strlen($line) == 0) {
            return new Line(Line::EXISTED, '');
        }

        $firstChar = $line[0];
        $cleanLine = rtrim(substr($line, 1));

        return new Line(Line::$opsMap[$firstChar], $cleanLine);
    }
1047385
public function parseLine($line) {

        $data = explode(";", $line);
        $i    = -1;

        $model = new Card();
        $model->setTicketNumber($this->decodeString($data[++$i]));
        $model->setUserNumber(IntegerHelper::parseString($data[++$i]));
        $model->setArticleNumber(IntegerHelper::parseString($data[++$i]));
        $model->setValidFrom($this->decodeDate($data[++$i]));
        $model->setExpires($this->decodeDate($data[++$i]));
        $model->setBlocked(BooleanHelper::parseString($data[++$i]));
        $model->setBlockedDate($this->decodeDate($data[++$i]));
        $model->setProductionState(IntegerHelper::parseString($data[++$i]));
        $model->setReasonProduction(IntegerHelper::parseString($data[++$i]));
        $model->setProductionCounter(IntegerHelper::parseString($data[++$i]));
        $model->setNeutral(BooleanHelper::parseString($data[++$i]));
        $model->setRetainTicketEntry(BooleanHelper::parseString($data[++$i]));
        $model->setEntryBarrierClosed(BooleanHelper::parseString($data[++$i]));
        $model->setExitBarrierClosed(BooleanHelper::parseString($data[++$i]));
        $model->setRetainTicketExit(BooleanHelper::parseString($data[++$i]));
        $model->setDisplayText(BooleanHelper::parseString($data[++$i]));
        $model->setDisplayText1($this->decodeString($data[++$i]));
        $model->setDisplayText2($this->decodeString($data[++$i]));
        $model->setPersonnalNo(IntegerHelper::parseString($data[++$i]));
        $model->setResidualValue(IntegerHelper::parseString($data[++$i]));
        $model->setSerialNumberKeyCardSwatch($this->decodeString($data[++$i]));
        $model->setCurrencyResidualValue($this->decodeString($data[++$i]));
        $model->setTicketType(IntegerHelper::parseString($data[++$i]));
        $model->setTicketSubType($this->decodeString($data[++$i]));
        $model->setSerialNo($this->decodeString($data[++$i]));
        $model->setSuspendPeriodFrom($this->decodeDate($data[++$i]));
        $model->setSuspendPeriodUntil($this->decodeDate($data[++$i]));
        $model->setUseValidCarParks(BooleanHelper::parseString($data[++$i]));
        $model->setProductionFacilityNumber(IntegerHelper::parseString($data[++$i]));

        return $model;
    }
1239355
public function parseLine($line) {

        $data = explode(";", $line);
        $i    = -1;

        $model = new User();
        $model->setUserNumber(IntegerHelper::parseString($data[++$i]));
        $model->setCustomerNumber(IntegerHelper::parseString($data[++$i]));
        $model->setTitle($this->decodeString($data[++$i]));
        $model->setSurname($this->decodeString($data[++$i]));
        $model->setFirstname($this->decodeString($data[++$i]));
        $model->setDateBirth($this->decodeDate($data[++$i]));
        $model->setParkingSpace($this->decodeString($data[++$i]));
        $model->setRemarks($this->decodeString($data[++$i]));
        $model->setDatetimeLastModification($this->decodeDateTime($data[++$i]));
        $model->setDeletedRecord(BooleanHelper::parseString($data[++$i]));
        $model->setIdentificationNumber($this->decodeString($data[++$i]));
        $model->setCheckLicensePlate(BooleanHelper::parseString($data[++$i]));
        $model->setPassageLicensePlatePermitted(BooleanHelper::parseString($data[++$i]));
        $model->setExcessTimesCreditCard(BooleanHelper::parseString($data[++$i]));
        $model->setCreditCardNumber($this->decodeString($data[++$i]));
        $model->setExpiryDate($this->decodeDate($data[++$i]));
        $model->setRemarks2($this->decodeString($data[++$i]));
        $model->setRemarks3($this->decodeString($data[++$i]));
        $model->setDivision($this->decodeString($data[++$i]));
        $model->setEmail($this->decodeString($data[++$i]));
        $model->setGroupCounting(BooleanHelper::parseString($data[++$i]));
        $model->setETicketTypeP(IntegerHelper::parseString($data[++$i]));
        $model->setETicketEmailTelephone($this->decodeString($data[++$i]));
        $model->setETicketAuthentication(IntegerHelper::parseString($data[++$i]));
        $model->setETicketServiceTyp(IntegerHelper::parseString($data[++$i]));
        $model->setETicketServiceArt(IntegerHelper::parseString($data[++$i]));

        return $model;
    }
1286418
public function parse($lines)
    {
        $data = [];
        foreach ($lines as $line) {
            if ($line === '' || $line[0] === '#') {
                continue;
            }

            if ($pos = strpos($line, ' # ')) {
                $line = substr($line, 0, $pos);
            }
            $line = trim($line);
            if (strpos($line, 'export ') === 0) {
                $parts = explode('=', ltrim(substr($line, 7)), 2);
            } else {
                $parts = explode('=', $line, 2);
            }

            if (count($parts) !== 2) {
                throw new InvalidValueException(['invalid line: :line, has no = character', 'line' => $line]);
            }
            $name = $parts[0];
            $value = $parts[1];

            if ($value === '') {
                null;
            } elseif ($value === 'true') {
                $value = true;
            } elseif ($value === 'false') {
                $value = false;
            } elseif ($value === 'null') {
                $value = null;
            } else {
                $fc = $value[0];
                if (($fc === '"' || $fc === "'") && $value[strlen($value) - 1] === $fc) {
                    $value = substr($value, 1, -1);
                    $value = strtr($value, ["\\$fc" => $fc]);
                }
                $value = strtr($value, ['\n' => PHP_EOL]);

                if (strpos($value, '${') !== false) {
                    preg_match_all('#\$\{([\w\.]+)\}#', $value, $matches, PREG_PATTERN_ORDER);
                    foreach ((array)$matches[1] as $match) {
                        $ref_name = $match;
                        if (!isset($data[$ref_name])) {
                            throw new InvalidValueException('`:ref` ref variable is not exists: :value', ['ref' => $ref_name, 'value' => $value]);
                        }
                        $value = strtr($value, ['${' . $ref_name . '}' => $data[$ref_name]]);
                    }
                } elseif (strpos($value, '$') !== false) {
                    preg_match_all('#\$([A-Z_\d]+)#', $value, $matches, PREG_PATTERN_ORDER);
                    foreach ((array)$matches[1] as $match) {
                        $ref_name = $match;
                        if (!isset($data[$ref_name])) {
                            throw new InvalidValueException(['`:ref` ref variable is not exists: :value', 'ref' => $ref_name, 'value' => $value]);
                        }
                        $value = strtr($value, ['$' . $ref_name => $data[$ref_name]]);
                    }
                }
            }

            $data[$name] = $value;
        }

        return $data;
    }
954594
protected function blockQuote($Line)
    {
        if (!$this->config('markup.quote.keepSigns'))
        {
            return parent::blockQuote($Line);
        }

        if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches))
        {
            $matches = str_replace(">", "&gt;", $matches[1]);
            $Block = array(
                'element' => array(
                    'name' => 'blockquote',
                    'handler' => 'lines',
                    'text' => [ "&gt;{$matches}" ],
                ),
            );

            return $Block;
        }
    }
540807
private function parse($line)
    {
        $uriParser = new UriParser($line);
        $line = $uriParser->encode();
        if ($uriParser->validateIP() ||
            !$uriParser->validateHost() ||
            (
                parse_url($line, PHP_URL_SCHEME) !== null &&
                !$uriParser->validateScheme()
            )
        ) {
            return false;
        }
        $parts = $this->getParts($line);
        return $parts['scheme'] . $parts['host'] . $parts['port'];
    }
725548
protected function blockQuoteContinue($Line, array $Block)
    {
        if (!$this->config('markup.quote.keepSigns'))
        {
            return parent::blockQuote($Line);
        }

        if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches))
        {
            if (isset($Block['interrupted']))
            {
                $Block['element']['text'] []= '';

                unset($Block['interrupted']);
            }

            $matches = str_replace(">", "&gt;", $matches[1]);
            $Block['element']['text'][] = "&gt;{$matches}";

            return $Block;
        }
    }
56281
function getFromDefine($line)
    {
        $line = "<?php $line"; // Trick the parser that we are in PHP file, instead of analyzing a single line

        $state = 0;
        $key = $value = '';

        $tokens = token_get_all($line);
        $token = reset($tokens);

        while ($token) {
            if (is_array($token)) {
                if ($token[0] == T_WHITESPACE || $token[0] == T_COMMENT || $token[0] == T_DOC_COMMENT) {
                    // do nothing
                } else {
                    if ($token[0] == T_STRING && strtolower($token[1]) == 'define') {
                        $state = 1;
                    } else {
                        if ($state == 2 && $this->isConstantToken($token[0])) {
                            $key = $token[1];
                            $state = 3;
                        } else {
                            if ($state == 4 && $this->isConstantToken($token[0])) {
                                $value = $token[1];
                                $state = 5;
                            }
                        }
                    }
                }
            } else {
                $symbol = trim($token);
                if ($symbol == '(' && $state == 1) {
                    $state = 2;
                } else {
                    if ($symbol == ',' && $state == 3) {
                        $state = 4;
                    } else {
                        if ($symbol == ')' && $state == 5) {
                            $state = 0;

                            yield [$this->stripQuotes($key), $this->getNativeValueFromDefinition($value)];
                        }
                    }
                }
            }
            $token = next($tokens);
        }
    }
852887
private function parseLine( $line, $info ) 
	{
		$handled = false;
		if (preg_match('/^\s*(@[a-z]+)\s(.*)$/i', $line, $matches)) 
		{
			$this->currentTag = substr($matches[1], 1);
			$line = trim( substr($line, strlen($this->currentTag)+2 ) );
			switch( $this->currentTag ) 
			{
				case 'param' :
					if ( preg_match('/^\s*([[:alpha:]|]+)\s([[:alnum:]$_]+)(.*)$/i', $line, $matches) ) 
					{
						if ( !isset($info['arguments']) ) {
							$info['arguments'] = array();
						}
						if ( !isset($info['arguments'][$matches[2]]) ) {
							$info['arguments'][$matches[2]] = array('description' => '');
						}
						$info['arguments'][$matches[2]]['type'] = $matches[1];
						$info['arguments'][$matches[2]]['description'] .= $this->parseDescription($matches[3]);
					}
					$handled = true;
				break;
				case 'return' :
					if ( preg_match('/^\s*([[:alpha:]|]+)\s(.*)$/i', $line, $matches) ) 
					{
						if ( !isset($info['return']) ) {
							$info['return'] = array( 'description' => '' );
						}
						$info['return']['type'] = $matches[1];
						$info['return']['description'] .= $this->parseDescription($matches[2]);
					}
					$handled = true;
				break;
			}
		}
		if (!$handled) {
			switch( $this->currentTag) {
				case 'param' :
				case 'return' :
					if ( !isset( $info[$this->currentTag] ) ) {
						$info[$this->currentTag] = array();
					}
					$info[$this->currentTag]['description'] .= $this->parseDescription($line);
				break;
				default:
					if ( !isset( $info[$this->currentTag] ) ) {
						$info[$this->currentTag] = '';
					}
					$info[$this->currentTag] .= $this->parseDescription($line);
				break;
			}
		}
		return $info;
	}
4751
protected static function parseLine( $line )
	{
		$pos	= strpos( $line, ":" );
		$name	= substr( $line, 0, $pos );
		$value	= substr( $line, $pos+1 );

		$params	= array();
		if( substr_count( $name, ";" ) )
		{
			$pos	= strpos( $name, ";" );
			$params	= substr( $name, $pos+1 );
			$name	= substr( $name, 0, $pos );
			$params	= explode( ",", utf8_decode( $params ) );
		}

		$parsed	= array(
			"name"	=> trim( $name ),
			"param"	=> $params,
			"value"	=> utf8_decode( $value ),
		);
		return $parsed;
	}
1235708
public function parseLocalPushRefs($lines)
    {
        $branches = [];
        $delimiter = ' pushes to ';
        foreach ($lines as $line) {
            $line = trim($line);
            $line = preg_replace('/\s+/', ' ', $line);
            $parts = explode($delimiter, $line);
            if (count($parts) > 1) {
                $value = explode(' ', $parts[1], 2);
                $branches[$parts[0]] = ['pushes_to' => $value[0], 'local_state' => $value[1]];
            }
        }

        return $branches;
    }
570447
protected function parseHtmlLine( Line$line ):self
	{
		return $this->openNode(new StringNode($this,$line))->appendLine($line->slice(1));
	}
638354
protected function parseMessages($lines) {
    $messages = array();

    $message = array();
    foreach ($lines as $line) {
      if (empty($line) & !empty($message)) {
        $messages[] = $message;
        $message = array();
        continue;
      }
      $message[] = $line;
    }

    return $messages;
  }
132544
protected function parseTag($line)
    {
        $tagAndValue = preg_split('/\\s/', $line, 2);
        $tag = substr($tagAndValue[0], 1);
        if (count($tagAndValue) > 1) {
            $this->tags[$tag][] = trim($tagAndValue[1]);
        } else {
            $this->tags[$tag] = [];
        }
    }
202826
public function parseBody( $line )
    {
        $line = rtrim( $line, "\r\n" );
        if ( $this->text === null )
        {
            $this->text = $line;
        }
        else
        {
            $this->text .= "\n" . $line;
        }
    }
663648
private function parseLine($line)
    {
        if ($line == '') {
            return;
        }

        $slices = NodeObject::getLineSlices($line);
        if ($this->isBlob()) {
            $this->pathChildren[] = $this->blob->getName();
        } else {
            if ($this->isRoot()) {
                // if is root check for first children
                $pattern = '/(\w+)\/(.*)/';
                $replacement = '$1';
            } else {
                // filter by the children of the path
                $actualPath = $this->subject->getFullPath();
                if (!preg_match(sprintf('/^%s\/(\w*)/', preg_quote($actualPath, '/')), $slices['fullPath'])) {
                    return;
                }
                $pattern = sprintf('/^%s\/(\w*)/', preg_quote($actualPath, '/'));
                $replacement = '$1';
            }

            $name = preg_replace($pattern, $replacement, $slices['fullPath']);
            if (strpos($name, '/') !== false) {
                return;
            }

            if (!in_array($name, $this->pathChildren)) {
                $path = rtrim(rtrim($slices['fullPath'], $name), '/');
                $treeObject = new TreeObject(
                    $this->repository,
                    $slices['permissions'],
                    $slices['type'],
                    $slices['sha'],
                    $slices['size'],
                    $name,
                    $path
                );
                $this->children[] = $treeObject;
                $this->pathChildren[] = $name;
            }
        }
    }