Parse foreach control structure.
@return ForeachNode
480455
private function _foreach() {
    $node = new ForeachNode();
    $this->mustMatch(T_FOREACH, $node);
    $this->mustMatch('(', $node, 'openParen');
    $node->addChild($this->expr(), 'onEach');
    $this->mustMatch(T_AS, $node);
    $value = $this->foreachVariable();
    if ($this->currentType === T_DOUBLE_ARROW) {
      $node->addChild($value, 'key');
      $this->mustMatch(T_DOUBLE_ARROW, $node);
      $node->addChild($this->foreachVariable(), 'value');
    }
    else {
      $node->addChild($value, 'value');
    }
    $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE);
    if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) {
      $node->addChild($this->innerStatementListNode(T_ENDFOREACH), 'body');
      $this->mustMatch(T_ENDFOREACH, $node);
      $this->endStatement($node);
      return $node;
    }
    else {
      $node->addChild($this->statement(), 'body');
      return $node;
    }
  }
1079791
private function parseElementNodes($children, $parentName = null)
    {
        $result = [];

        foreach ($children as $child) {
            $prefix = $child->prefix ?: null;
            $oname  = $this->normalizeKey($child->nodeName);
            $name   = $this->prefixKey($oname, $prefix);

            if (isset($result[$name])) {
                $this->parseSetResultNodes($child, $name, $result);
                continue;
            }

            $this->parseUnsetResultNodes($child, $name, $oname, $parentName, $result, $prefix);
        }

        return $result;
    }
838587
public function parse()
    {
        if (!is_array($this->paramList)) {
            return [];
        }

        $parsedParams = [];
        foreach ($this->paramList as $p) {
            $param = new ParsedParameter();
            $param->name = $p->name;
            $param->type = $this->getType($p->name, $this->paramAnnotations);
            $param->matchPattern = $this->getParamMatchType($param->type);
            try {
                $param->default = $p->getDefaultValue();
                if (is_bool($param->default)) {
                    $param->default = ($param->default===false) ? '0' : '1';
                }
                $param->required = false;
            } catch (\Exception $e) {
                $param->default = null;
                $param->required = true;
            }

            $parsedParams[] = $param;
        }

        return $parsedParams;
    }
194
public function getControl()
	{
		$control = parent::getControl();
		$control->type = $this->htmlType;
		$control->addClass($this->htmlType);

		list($min, $max) = $this->extractRangeRule($this->getRules());
		if ($min instanceof DateTimeInterface) {
			$control->min = $min->format($this->htmlFormat);
		}
		if ($max instanceof DateTimeInterface) {
			$control->max = $max->format($this->htmlFormat);
		}
		$value = $this->getValue();
		if ($value instanceof DateTimeInterface) {
			$control->value = $value->format($this->htmlFormat);
		}

		return $control;
	}
15834
public function getValuesParsedAttribute()
    {
        if ($this->attributes['data'] == '')
            return null;

        $data = unserialize($this->attributes['data']);

        if (!isset($data['values']))
            return null;
        else {
            $values = preg_split("/\\r\\n|\\r|\\n/", $data['values']);
            $ret = [];

            foreach ($values as $item) {
                if (strpos($item, '=>')) {
                    $item = str_replace(' => ', '=>', $item);
                    list($key, $value) = explode('=>', $item);

                    $ret[$key] = $value;
                } else {
                    $ret[$item] = $item;
                }
            }

            return $ret;
        }
    }
171546
private function parse()
    {
        if (!self::$placeholders) {
            self::loadConfig();
        }
        $this->type = '';
        $this->modifiers = self::$lModifiers;
        $ph = $this->placeholder;
        if ($ph == '') {
            return true;
        }
        $comp = explode('-', $ph);
        if (count($comp) > 1) {
            $type = array_shift($comp);
            if (isset(self::$longs[$type])) {
                $this->type = self::$longs[$type];
            } elseif (isset(self::$longModifiers[$type])) {
                $this->modifiers[self::$longModifiers[$type]] = true;
            } else {
                return $this->error();
            }
            foreach ($comp as $c) {
                if (isset(self::$longModifiers[$c])) {
                    $this->modifiers[self::$longModifiers[$c]] = true;
                } else {
                    return $this->error();
                }
            }
            return true;
        }
        if (isset(self::$longs[$ph])) {
            $this->type = self::$longs[$ph];
            return true;
        }
        if (isset(self::$longModifiers[$ph])) {
            $this->modifiers[self::$longModifiers[$ph]] = true;
            return true;
        }
        $type = $ph[0];
        if (isset(self::$placeholders[$type])) {
            $this->type = $type;
        } elseif (isset(self::$lModifiers[$type])) {
            $this->modifiers[$type] = true;
        } else {
            return $this->error();
        }
        $len = strlen($ph);
        for ($i = 1; $i < $len; $i++) {
            $modifier = $ph[$i];
            if (isset(self::$lModifiers[$modifier])) {
                $this->modifiers[$modifier] = true;
            } else {
                return $this->error();
            }
        }
        return true;
    }
1320602
function nextNode() {
    if (empty($this->html)) {
      # we are done with parsing the html string
      return false;
    }
    static $skipWhitespace = true;
    if ($this->isStartTag && !$this->isEmptyTag) {
      array_push($this->openTags, $this->tagName);
      if (in_array($this->tagName, $this->preformattedTags)) {
        # dont truncate whitespaces for <code> or <pre> contents
        $this->keepWhitespace++;
      }
    }

    if ($this->html[0] == '<') {
      $token = substr($this->html, 0, 9);
      if (substr($token, 0, 2) == '<?') {
        # xml prolog or other pi's
        /** TODO **/
        #trigger_error('this might need some work', E_USER_NOTICE);
        $pos = strpos($this->html, '>');
        $this->setNode('pi', $pos + 1);
        return true;
      }
      if (substr($token, 0, 4) == '<!--') {
        # comment
        $pos = strpos($this->html, '-->');
        if ($pos === false) {
          # could not find a closing -->, use next gt instead
          # this is firefox' behaviour
          $pos = strpos($this->html, '>') + 1;
        } else {
          $pos += 3;
        }
        $this->setNode('comment', $pos);

        $skipWhitespace = true;
        return true;
      }
      if ($token == '<!DOCTYPE') {
        # doctype
        $this->setNode('doctype', strpos($this->html, '>')+1);

        $skipWhitespace = true;
        return true;
      }
      if ($token == '<![CDATA[') {
        # cdata, use text node

        # remove leading <![CDATA[
        $this->html = substr($this->html, 9);

        $this->setNode('text', strpos($this->html, ']]>')+3);

        # remove trailing ]]> and trim
        $this->node = substr($this->node, 0, -3);
        $this->handleWhitespaces();

        $skipWhitespace = true;
        return true;
      }
      if ($this->parseTag()) {
        # seems to be a tag
        # handle whitespaces
        if ($this->isBlockElement) {
          $skipWhitespace = true;
        } else {
          $skipWhitespace = false;
        }
        return true;
      }
    }
    if ($this->keepWhitespace) {
      $skipWhitespace = false;
    }
    # when we get here it seems to be a text node
    $pos = strpos($this->html, '<');
    if ($pos === false) {
      $pos = strlen($this->html);
    }
    $this->setNode('text', $pos);
    $this->handleWhitespaces();
    if ($skipWhitespace && $this->node == ' ') {
      return $this->nextNode();
    }
    $skipWhitespace = false;
    return true;
  }
858478
protected function parse(): void
    {
        // add the root node
        $this->root = new HtmlNode('root');
        $activeNode = $this->root;
        while ( ! is_null($activeNode)) {
            $str = $this->content->copyUntil('<');
            if ($str == '') {
                $info = $this->parseTag();
                if ( ! $info['status']) {
                    // we are done here
                    $activeNode = null;
                    continue;
                }

                // check if it was a closing tag
                if ($info['closing']) {
                    $foundOpeningTag  = true;
                    $originalNode     = $activeNode;
                    while ($activeNode->getTag()->name() != $info['tag']) {
                        $activeNode = $activeNode->getParent();
                        if (is_null($activeNode)) {
                            // we could not find opening tag
                            $activeNode = $originalNode;
                            $foundOpeningTag = false;
                            break;
                        }
                    }
                    if ($foundOpeningTag) {
                        $activeNode = $activeNode->getParent();
                    }
                    continue;
                }

                if ( ! isset($info['node'])) {
                    continue;
                }

                /** @var AbstractNode $node */
                $node = $info['node'];
                $activeNode->addChild($node);

                // check if node is self closing
                if ( ! $node->getTag()->isSelfClosing()) {
                    $activeNode = $node;
                }
            } else if ($this->options->whitespaceTextNode ||
                trim($str) != ''
            ) {
                // we found text we care about
                $textNode = new TextNode($str, $this->options->removeDoubleSpace);
                $activeNode->addChild($textNode);
            }
        }
    }
326904
protected function _parseTemplate()
	{
		$matches = array();

		if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\/>#iU', $this->_template, $matches))
		{
			$template_tags_first = array();
			$template_tags_last  = array();

			// Step through the jdocs in reverse order.
			for ($i = count($matches[0]) - 1; $i >= 0; $i--)
			{
				$type = $matches[1][$i];
				$attribs = empty($matches[2][$i]) ? array() : $this->parseAttributes($matches[2][$i]);
				$name = isset($attribs['name']) ? $attribs['name'] : null;

				// Separate buffers to be executed first and last
				if ($type == 'module' || $type == 'modules')
				{
					$template_tags_first[$matches[0][$i]] = array('type' => $type, 'name' => $name, 'attribs' => $attribs);
				}
				else
				{
					$template_tags_last[$matches[0][$i]]  = array('type' => $type, 'name' => $name, 'attribs' => $attribs);
				}
			}
			// Reverse the last array so the jdocs are in forward order.
			$template_tags_last = array_reverse($template_tags_last);

			$this->_template_tags = $template_tags_first + $template_tags_last;
		}

		return $this;
	}
121640
protected function getElementsArrayText()
    {
        $elements = array();
        foreach ($this->elements as $element) {
            $elementId            = $element->getItem()
                                            ->getId();
            $elements[$elementId] = $element->getControl()
                                            ->getId();
        }
        return Builder::getArray($elements, true);
    }
767482
public function parse(){
			$data = [];

			preg_match_all('#@(.*?)\n#s', $this->_comments, $annotations);

			foreach ($annotations[1] as $key => $annotation){
				if(preg_match('#([A-Za-z]+)\((.*)\)#is', $annotation)){
					preg_match_all('#([A-Za-z]+)\((.*)\)#is', $annotation, $annotationData);
					$annotationTitle = $annotationData[1][0];

					if(isset(Parser::$_annotations[$annotationTitle])) {
						$annotationContents = explode(", ", $annotationData[2][0]);
						$data[$key] = [];

						foreach ($annotationContents as $annotationContent) {
							preg_match_all('#(.+)="(.*)"#isU', trim($annotationContent), $annotationContentData);

							$data[$key]['type'] = $annotationTitle;
							$data[$key]['class'] = Parser::$_annotations[$annotationTitle];
							$data[$key]['properties'][$annotationContentData[1][0]] = $annotationContentData[2][0];
						}
					}
					else{
						throw new AnnotationNotExistingException('The annotation "' . $annotationTitle . '" does not exist');
					}
				}
			}

			return $data;
		}
874630
protected function parse()
	{
		if (($s = $this->copy_until_char('<'))==='')
		{
			return $this->read_tag();
		}

		// text
		$node = new Node($this);
		++$this->cursor;
		$node->_[self::HDOM_INFO_TEXT] = $s;
		$this->link_nodes($node, false);
		return true;
	}
392446
protected function parse()
    {
        $sectionName = static::GLOBAL_SECTION;
        $values = [];

        try {
            while ($line = fgets($this->handle)) {
                $this->linenumber++;
                $line = trim($line);
                if (empty($line) || substr($line, 0, 1) === ';') {
                    continue;
                }

                if ($this->isSectionHeader($line)) {
                    if ($sectionName === static::GLOBAL_SECTION) {
                        $this->config = $values;
                    } else {
                        $tokens = explode($this->delimiter, $sectionName);
                        $this->config = array_merge_recursive($this->config,
                                                              $this->subdivide($tokens, $values));

                        unset($tokens);
                    }

                    $sectionName = $this->getSectionHeader($line);
                    $values = [];
                    continue;
                }

                list($key, $value) = array_pad(preg_split(static::SPLIT_PATTERN, trim($line), 2), 2, '');

                if ($this->isArrayKey($key)) {
                    if (is_null($array_key = $this->parseArrayKey($key))) {
                        $key = trim(trim($key), '[]');

                        $values[$key][] = $this->parseValue($value);
                    } else {
                        $key = trim(substr($key, 0, strpos($key, '[')));
                        if (!isset($values[$key])) {
                            $values[$key] = [];
                        }

                        $values[$key][$array_key] = $this->parseValue($value);
                    }
                } else {
                    $values[trim($key)] = $this->parseValue($value);
                }
            }
        } catch (\Exception $ex) {
            throw new \RuntimeException("{$ex->getMessage()} Line: {$this->linenumber}.");
        } finally {
            $this->close();
        }

        if ($sectionName === static::GLOBAL_SECTION) {
            $this->config = $values;
        } else {
            $section = $this->subdivide(explode($this->delimiter, $sectionName), $values);
            $this->config = array_merge($this->config, $section);
        }
    }
39883
protected function parse(): array
    {
        $offset = 0;
        $name = $this->_parseName($offset);
        if ($offset < $this->_len) {
            $remains = substr($this->_dn, $offset);
            throw new \UnexpectedValueException(
                "Parser finished before the end of string" .
                     ", remaining: '$remains'.");
        }
        return $name;
    }
1203742
protected function parseLink():self
	{
		return $this->setMultinameAttribute('link',$this->sectionLedBy('@',true),function( string$link ){
			if( isset($this->config['target']) && ':'===$link{0} ){
				return 'javascript'.$link;
			}elseif( '//'===($firstTwoLetters=substr($link,0,2)) ){
				return 'http:'.$link;
			}elseif( '\\\\'===$firstTwoLetters ){
				return 'https://'.substr($link,2);
			}else{
				return $this->checkExpression($link);
			}
		});
	}
964521
public function parse() {
		$annotations = [];
		preg_match_all(self::ANNOTATION_PATTERN, $this->rawDocComment, $found);
		foreach ($found[1] as $key => $value) {
			$arg = null;
			if (!empty($found[2][$key])) {
				$arg = substr(trim($found[2][$key]), 1, -1);
			}
			$annotations[] = new Annotation($value, $this->parseValue($found[3][$key]), $arg);
		}
		return $annotations;
	}
1318919
protected function parseTree()
    {
        $string = $this->string;
        if (empty($string)) {
            return array();
        }
        $tree = array();
        $i = 0;
        $length = strlen($string);
        $isBackslash = false;
        $operand = '';
        while ($i <= $length) {
            $char = $string[$i];

            $isAND = ($char == self::AND_DELIMITER);
            $isOR = ($char == self::OR_DELIMITER);
            $isEnd = ($length == $i + 1);

            if ($isEnd) {
                if ($isBackslash && ($isAND || $isOR)) {
                    $operand = substr($operand, 0, -1);
                }
                $operand .= $char;
                $tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_END, self::INDEX_OPERAND => $operand);
                break;
            }

            if ($isAND && !$isBackslash) {
                $tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_AND, self::INDEX_OPERAND => $operand);
                $operand = '';
            } elseif ($isOR && !$isBackslash) {
                $tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_OR, self::INDEX_OPERAND => $operand);
                $operand = '';
            } else {
                if ($isBackslash && ($isAND || $isOR)) {
                    $operand = substr($operand, 0, -1);
                }
                $operand .= $char;
            }
            $isBackslash = ($char == "\\");
            $i++;
        }
        return $tree;
    }