Parse a class statement.
@param bool $is_abstract TRUE if the class is abstract
@return Node
@throws ParserException
978503
private function classStatement($is_abstract) {
    if ($this->currentType === T_FUNCTION) {
      $modifiers = new ModifiersNode();
      $doc_comment = new PartialCommentNode();
      $this->matchDocComment($doc_comment);
      return $this->classMethod($doc_comment, $modifiers);
    }
    elseif ($this->currentType === T_VAR) {
      $doc_comment = new PartialCommentNode();
      $this->matchDocComment($doc_comment);
      $modifiers = new ModifiersNode();
      $this->mustMatch(T_VAR, $modifiers, 'visibility');
      return $this->classMemberList($doc_comment, $modifiers);
    }
    elseif ($this->currentType === T_CONST) {
      return $this->_const();
    }
    elseif ($this->currentType === T_USE) {
      return $this->traitUse();
    }
    // Match modifiers
    $doc_comment = new PartialCommentNode();
    $this->matchDocComment($doc_comment);
    $modifiers = new ModifiersNode();
    while ($this->iterator->hasNext()) {
      switch ($this->currentType) {
        case T_PUBLIC:
        case T_PROTECTED:
        case T_PRIVATE:
          if ($modifiers->getVisibility()) {
            throw new ParserException(
              $this->filename,
              $this->iterator->getLineNumber(),
              $this->iterator->getColumnNumber(),
              "can only have one visibility modifier on class member/method."
            );
          }
          $this->mustMatch($this->currentType, $modifiers, 'visibility');
          break;
        case T_STATIC:
          if ($modifiers->getStatic()) {
            throw new ParserException(
              $this->filename,
              $this->iterator->getLineNumber(),
              $this->iterator->getColumnNumber(),
              "duplicate modifier");
          }
          $this->mustMatch(T_STATIC, $modifiers, 'static');
          break;
        case T_FINAL:
          if ($modifiers->getFinal()) {
            throw new ParserException(
              $this->filename,
              $this->iterator->getLineNumber(),
              $this->iterator->getColumnNumber(),
              "duplicate modifier");
          }
          if ($modifiers->getAbstract()) {
            throw new ParserException(
              $this->filename,
              $this->iterator->getLineNumber(),
              $this->iterator->getColumnNumber(),
              "can not use final modifier on abstract method");
          }
          $this->mustMatch(T_FINAL, $modifiers, 'final');
          break;
        case T_ABSTRACT:
          if ($modifiers->getAbstract()) {
            throw new ParserException(
              $this->filename,
              $this->iterator->getLineNumber(),
              $this->iterator->getColumnNumber(),
              "duplicate modifier");
          }
          if ($modifiers->getFinal()) {
            throw new ParserException(
              $this->filename,
              $this->iterator->getLineNumber(),
              $this->iterator->getColumnNumber(),
              "can not use abstract modifier on final method");
          }
          if (!$is_abstract) {
            throw new ParserException(
              $this->filename,
              $this->iterator->getLineNumber(),
              $this->iterator->getColumnNumber(),
              "can not use abstract modifier in non-abstract class");
          }
          $this->mustMatch(T_ABSTRACT, $modifiers, 'abstract');
          break;
        case T_FUNCTION:
          return $this->classMethod($doc_comment, $modifiers);
        case T_VARIABLE:
          return $this->classMemberList($doc_comment, $modifiers);
        default:
          throw new ParserException(
            $this->filename,
            $this->iterator->getLineNumber(),
            $this->iterator->getColumnNumber(),
            "invalid class statement");
      }
    }
    throw new ParserException(
      $this->filename,
      $this->iterator->getLineNumber(),
      $this->iterator->getColumnNumber(),
      "invalid class statement");
  }
949345
protected function parseExamples()
    {
        $token = $this->expectTokenType('Examples');

        $keyword = $token['keyword'];

        return new ExampleTableNode($this->parseTableRows(), $keyword);
    }
916305
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = new self();

        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *
         *      0 ---------------- [ tbl_name ] -----------------> 1
         *      1 ---------------- [ lock_type ] ----------------> 2
         *      2 -------------------- [ , ] --------------------> break
         *
         * @var int
         */
        $state = 0;

        $prevToken = null;

        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // End of statement.
            if ($token->type === Token::TYPE_DELIMITER
                || ($token->type === Token::TYPE_OPERATOR
                && $token->value === ',')
            ) {
                break;
            }

            if ($state === 0) {
                $ret->table = Expression::parse($parser, $list, ['parseField' => 'table']);
                $state = 1;
            } elseif ($state === 1) {
                // parse lock type
                $ret->type = self::parseLockType($parser, $list);
                $state = 2;
            }
            $prevToken = $token;
        }

        // 2 is the only valid end state
        if ($state !== 2) {
            $parser->error('Unexpected end of LOCK expression.', $prevToken);
        }

        --$list->idx;

        return $ret;
    }
360049
private function _processClassStatement() {
		$isAfterScopeResolutionOperator = $this->tokenizer->checkPreviousToken(T_DOUBLE_COLON);
		if ($isAfterScopeResolutionOperator) {
			return;
		}

		// Check PHPDoc presence
		$this->_checkDocExists(T_CLASS);

		$this->_ncssTotalClasses ++;
		$this->_ncssFileClasses ++;

		// Test if there is more than one class per file
		if ($this->_isActive('oneClassPerFile') && $this->_ncssFileClasses > 1) {
			$msg = $this->_getMessage('ONE_CLASS_PER_FILE', $this->_currentFilename);
			$this->_writeError('oneClassPerFile', $msg);
		}

		// Reset the default values
		$this->_inFunction = false;
		$this->_nbFunctionParameters = 0;
		$this->_functionParameters = array();
		$this->_inFunctionStatement = false;
		$this->_functionReturns = false;
		$this->_functionThrows = false;
		$this->_inControlStatement = false;
		$this->_currentStatement = false;
		$this->_inClassStatement = true;

		// skip until T_STRING representing the class name
		while (!$this->tokenizer->checkCurrentToken(T_STRING)) {
			$this->tokenizer->getNextToken();
		}

		$token = $this->tokenizer->getCurrentToken();
		$classname = $token->text;
		$this->_currentClassname = $classname;

		// Test that the class name matches the file name
		$this->_checkTypeNameFileNameMatch($classname);

		// Check class naming
		$this->_checkClassNaming($classname);

		$this->_checkWhiteSpaceAfter($classname);
	}
604202
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = new self();

        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *
         *      0 -------------------[ data type ]--------------------> 1
         *
         *      1 ----------------[ size and options ]----------------> 2
         *
         * @var int
         */
        $state = 0;

        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // Skipping whitespaces and comments.
            if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
                continue;
            }

            if ($state === 0) {
                $ret->name = strtoupper((string) $token->value);
                if (($token->type !== Token::TYPE_KEYWORD) || (! ($token->flags & Token::FLAG_KEYWORD_DATA_TYPE))) {
                    $parser->error('Unrecognized data type.', $token);
                }
                $state = 1;
            } elseif ($state === 1) {
                if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
                    $parameters = ArrayObj::parse($parser, $list);
                    ++$list->idx;
                    $ret->parameters = (($ret->name === 'ENUM') || ($ret->name === 'SET')) ?
                        $parameters->raw : $parameters->values;
                }
                $ret->options = OptionsArray::parse($parser, $list, static::$DATA_TYPE_OPTIONS);
                ++$list->idx;
                break;
            }
        }

        if (empty($ret->name)) {
            return null;
        }

        --$list->idx;

        return $ret;
    }
168669
public function hasClass($class_name)
    {
        foreach ($this->nodes as $node) {
            if ($node instanceof \DOMElement && $node_class_attr = $node->getAttribute('class')) {
                $node_classes = explode(' ', $node_class_attr);
                if (\in_array($class_name, $node_classes, true)) {
                    return true;
                }
            }
        }

        return false;
    }
847638
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = [];

        $expr = new self();

        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *
         *      0 -----------------------[ ( ]------------------------> 1
         *
         *      1 --------------------[ CONSTRAINT ]------------------> 1
         *      1 -----------------------[ key ]----------------------> 2
         *      1 -------------[ constraint / column name ]-----------> 2
         *
         *      2 --------------------[ data type ]-------------------> 3
         *
         *      3 ---------------------[ options ]--------------------> 4
         *
         *      4 --------------------[ REFERENCES ]------------------> 4
         *
         *      5 ------------------------[ , ]-----------------------> 1
         *      5 ------------------------[ ) ]-----------------------> 6 (-1)
         *
         * @var int
         */
        $state = 0;

        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // End of statement.
            if ($token->type === Token::TYPE_DELIMITER) {
                break;
            }

            // Skipping whitespaces and comments.
            if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
                continue;
            }

            if ($state === 0) {
                if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
                    $state = 1;
                } else {
                    $parser->error(
                        'An opening bracket was expected.',
                        $token
                    );

                    break;
                }
            } elseif ($state === 1) {
                if ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'CONSTRAINT') {
                    $expr->isConstraint = true;
                } elseif (($token->type === Token::TYPE_KEYWORD) && ($token->flags & Token::FLAG_KEYWORD_KEY)) {
                    $expr->key = Key::parse($parser, $list);
                    $state = 4;
                } elseif ($token->type === Token::TYPE_SYMBOL || $token->type === Token::TYPE_NONE) {
                    $expr->name = $token->value;
                    if (! $expr->isConstraint) {
                        $state = 2;
                    }
                } elseif ($token->type === Token::TYPE_KEYWORD) {
                    if ($token->flags & Token::FLAG_KEYWORD_RESERVED) {
                        // Reserved keywords can't be used
                        // as field names without backquotes
                        $parser->error(
                            'A symbol name was expected! '
                            . 'A reserved keyword can not be used '
                            . 'as a column name without backquotes.',
                            $token
                        );

                        return $ret;
                    }

                    // Non-reserved keywords are allowed without backquotes
                    $expr->name = $token->value;
                    $state = 2;
                } else {
                    $parser->error(
                        'A symbol name was expected!',
                        $token
                    );

                    return $ret;
                }
            } elseif ($state === 2) {
                $expr->type = DataType::parse($parser, $list);
                $state = 3;
            } elseif ($state === 3) {
                $expr->options = OptionsArray::parse($parser, $list, static::$FIELD_OPTIONS);
                $state = 4;
            } elseif ($state === 4) {
                if ($token->type === Token::TYPE_KEYWORD && $token->keyword === 'REFERENCES') {
                    ++$list->idx; // Skipping keyword 'REFERENCES'.
                    $expr->references = Reference::parse($parser, $list);
                } else {
                    --$list->idx;
                }
                $state = 5;
            } elseif ($state === 5) {
                if (! empty($expr->type) || ! empty($expr->key)) {
                    $ret[] = $expr;
                }
                $expr = new self();
                if ($token->value === ',') {
                    $state = 1;
                } elseif ($token->value === ')') {
                    $state = 6;
                    ++$list->idx;
                    break;
                } else {
                    $parser->error(
                        'A comma or a closing bracket was expected.',
                        $token
                    );
                    $state = 0;
                    break;
                }
            }
        }

        // Last iteration was not saved.
        if (! empty($expr->type) || ! empty($expr->key)) {
            $ret[] = $expr;
        }

        if (($state !== 0) && ($state !== 6)) {
            $parser->error(
                'A closing bracket was expected.',
                $list->tokens[$list->idx - 1]
            );
        }

        --$list->idx;

        return $ret;
    }
1318689
final public function parse()
    {
        $wsdl = $this->generator->getWsdl();
        if ($wsdl instanceof Wsdl) {
            $content = $wsdl->getContent();
            if ($content instanceof WsdlDocument) {
                if ($this->isWsdlParsed($wsdl) === false) {
                    $this->setWsdlAsParsed($wsdl)->setTags($content->getElementsByName($this->parsingTag()))->parseWsdl($wsdl);
                }
                foreach ($content->getExternalSchemas() as $schema) {
                    if ($this->isSchemaParsed($wsdl, $schema) === false) {
                        $this->setSchemaAsParsed($wsdl, $schema);
                        $schemaContent = $schema->getContent();
                        if ($schemaContent instanceof SchemaDocument) {
                            $this->setTags($schemaContent->getElementsByName($this->parsingTag()))->parseSchema($wsdl, $schema);
                        }
                    }
                }
            }
        }
    }
977807
public function parse() {
		/** @noinspection PhpParamsInspection */
		return $this -> execute(Util::cache(
			$this -> file,
			$this -> raw,
			'viper',
			function($data): NodeCollection {
				$tokens = $this -> tokenize($data);
				return $this -> formLogicalTree($tokens);
			}
		), $this -> data);
	}
1154965
public function parse(AbstractStream $stream)
    {
        if (!($this->dataSet instanceof DataSet)) {
            $this->dataSet = new DataSet;
        }

        $this->rewind();
        do {
            $field = $this->current();
            $field->setDataSet($this->getDataSet());
            if ($field instanceof Conditional) {
                $field = $field->resolveField();
            }
            if ($field instanceof self) {
                $this->dataSet->push($this->key());
                $field->parse($stream);
                $this->dataSet->pop();
            } else {
                $this->dataSet->setValue($this->key(), $field->parse($stream));
            }
            $this->next();
        } while ($this->valid());

        if (isset($this->assert)) {
            $this->validate($this->dataSet->getValueByCurrentPath());
        }

        return $this->dataSet->getData();
    }
665090
public function parse(){
		if($this->hasCircularReferences($this))
			throw new RuntimeException('Circular reference found in the query tree, cannot parse the query.');

		$this->connection->connect();

		$parser = $this->connection->getParser();
		$instance = new $parser($this);
		return $instance->parse();
	}
64252
public function parse(
        string $xml,
        string $className = null,
        int $options = null,
        string $ns = null,
        bool $isPrefix = null
    ): \SimpleXMLElement {
        list($content, $error) = $this->softParse($xml, $className, $options, $ns, $isPrefix);
        if ($error !== null) {
            throw $error;
        }
        return $content;
    }
270509
private function parseClass(Parser $parser, Stream $stream, $parentTemplate)
    {
        $oldClassNode = $parser->getCurrentClassNode();
        $fileNode     = $parser->getCurrentFileNode();

        /** @var $classNode ClassNode */
        $classNode = $fileNode->addClass(
            $fileNode->getNextEmbeddedTemplateName()
        );
        $classNode->setParentTemplate($parentTemplate);
        $parser->setCurrentClassNode($classNode);

        $classNode->addChild(
            $parser->parseBlock($stream, 'endembed'),
            ClassNode::MAIN_TEMPLATE_BLOCK
        );
        $stream->expect(Token::TAG_END);
        $parser->setCurrentClassNode($oldClassNode);

        return $classNode->getClassName();
    }
792968
protected function parse()
    {
        $data = $this->_source->getData();

        $prefilters = $this->getPreFilterInstances();
        foreach($prefilters as $prefilter) {
            $data = $prefilter->filter($data);
        }

        $realpath = $this->_source->getRealPath();
        $parser = new PHPTAL_Dom_SaxXmlParser($this->_encoding);

        $builder = new PHPTAL_Dom_PHPTALDocumentBuilder();
        $tree = $parser->parseString($builder, $data, $realpath)->getResult();

        foreach($prefilters as $prefilter) {
            if ($prefilter instanceof PHPTAL_PreFilter) {
                if ($prefilter->filterDOM($tree) !== NULL) {
                    throw new PHPTAL_ConfigurationException("Don't return value from filterDOM()");
                }
            }
        }

        $state = new PHPTAL_Php_State($this);

        $codewriter = new PHPTAL_Php_CodeWriter($state);
        $codewriter->doTemplateFile($this->getFunctionName(), $tree);

        return $codewriter->getResult();
    }
1077319
public static function parse(Parser $parser, TokensList $list, array $options = [])
    {
        $ret = new self();

        /**
         * Last parsed column.
         *
         * @var array
         */
        $lastColumn = [];

        /**
         * The state of the parser.
         *
         * Below are the states of the parser.
         *
         *      0 ----------------------[ type ]-----------------------> 1
         *
         *      1 ----------------------[ name ]-----------------------> 1
         *      1 ---------------------[ columns ]---------------------> 2
         *
         *      2 ---------------------[ options ]---------------------> 3
         *
         * @var int
         */
        $state = 0;

        for (; $list->idx < $list->count; ++$list->idx) {
            /**
             * Token parsed at this moment.
             *
             * @var Token
             */
            $token = $list->tokens[$list->idx];

            // End of statement.
            if ($token->type === Token::TYPE_DELIMITER) {
                break;
            }

            // Skipping whitespaces and comments.
            if (($token->type === Token::TYPE_WHITESPACE) || ($token->type === Token::TYPE_COMMENT)) {
                continue;
            }

            if ($state === 0) {
                $ret->type = $token->value;
                $state = 1;
            } elseif ($state === 1) {
                if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
                    $state = 2;
                } else {
                    $ret->name = $token->value;
                }
            } elseif ($state === 2) {
                if ($token->type === Token::TYPE_OPERATOR) {
                    if ($token->value === '(') {
                        $state = 3;
                    } elseif (($token->value === ',') || ($token->value === ')')) {
                        $state = ($token->value === ',') ? 2 : 4;
                        if (! empty($lastColumn)) {
                            $ret->columns[] = $lastColumn;
                            $lastColumn = [];
                        }
                    }
                } else {
                    $lastColumn['name'] = $token->value;
                }
            } elseif ($state === 3) {
                if (($token->type === Token::TYPE_OPERATOR) && ($token->value === ')')) {
                    $state = 2;
                } else {
                    $lastColumn['length'] = $token->value;
                }
            } elseif ($state === 4) {
                $ret->options = OptionsArray::parse($parser, $list, static::$KEY_OPTIONS);
                ++$list->idx;
                break;
            }
        }

        --$list->idx;

        return $ret;
    }
1328241
public function parse(): bool
    {
        if ($this->valid === true) {
            /**
             * Before processing through the deltas, generate new deltas by splliting
             * on all new lines, will make it much simpler to work out which
             * delta belong to headings, lists etc.
             */
            $this->quill_json = $this->splitInsertsByNewline($this->quill_json['ops']);

            foreach ($this->quill_json as $quill) {

                if ($quill['insert'] !== null) {
                    if (
                        array_key_exists('attributes', $quill) === true &&
                        is_array($quill['attributes']) === true
                    ) {
                        if (count($quill['attributes']) === 1) {
                            foreach ($quill['attributes'] as $attribute => $value) {
                                switch ($attribute) {
                                    case Options::ATTRIBUTE_BOLD:
                                        $this->attributeBold($quill);
                                        break;

                                    case Options::ATTRIBUTE_COLOR:
                                        $this->attributeColor($quill);
                                        break;

                                    case Options::ATTRIBUTE_HEADER:
                                        $this->attributeHeader($quill);
                                        break;

                                    case Options::ATTRIBUTE_ITALIC:
                                        $this->attributeItalic($quill);
                                        break;

                                    case Options::ATTRIBUTE_LINK:
                                        $this->attributeLink($quill);
                                        break;

                                    case Options::ATTRIBUTE_LIST:
                                        $this->attributeList($quill);
                                        break;

                                    case Options::ATTRIBUTE_SCRIPT:
                                        $this->attributeScript($quill);
                                        break;

                                    case Options::ATTRIBUTE_STRIKE:
                                        $this->attributeStrike($quill);
                                        break;

                                    case Options::ATTRIBUTE_UNDERLINE:
                                        $this->attributeUnderline($quill);
                                        break;

                                    default:
                                        $this->insert($quill);
                                        break;
                                }
                            }
                        } else {
                            $this->compoundInsert($quill);
                        }
                    } else {
                        if (is_string($quill['insert']) === true) {
                            $this->insert($quill);
                        } else {
                            if (is_array($quill['insert']) === true) {
                                if (array_key_exists('image', $quill['insert']) === true) {
                                    $this->image($quill);
                                } else if (array_key_exists('video', $quill['insert']) === true) {
                                    $this->video($quill);
                                }
                            }
                        }
                    }
                }
            }
            return true;
        } else {
            return false;
        }
    }
1059533
private function parseUseStatement()
    {
        $class = '';
        $alias = '';
        $statements = array();
        $explicitAlias = false;
        while (($token = $this->next())) {
            $isNameToken = $token[0] === T_STRING || $token[0] === T_NS_SEPARATOR;
            if (!$explicitAlias && $isNameToken) {
                $class .= $token[1];
                $alias = $token[1];
            } else if ($explicitAlias && $isNameToken) {
                $alias .= $token[1];
            } else if ($token[0] === T_AS) {
                $explicitAlias = true;
                $alias = '';
            } else if ($token === ',') {
                $statements[$alias] = $class;
                $class = '';
                $alias = '';
                $explicitAlias = false;
            } else if ($token === ';') {
                $statements[$alias] = $class;
                break;
            } else {
                break;
            }
        }

        return $statements;
    }