Parse a token with a value and type, and consume it depending on type.

@param int    $type  The token type (an integer from the Lexer class constant).
@param string $value The token value.

@throws AnnotationParseException If the token type is invalid.
771746
private function parse(int $type, string $value): void
    {
        switch ($type) {
            case AnnotationLexer::T_ANNOTATION:
                $this->tokenConsumer->consumeAnnotationToken($value);
                break;
            case AnnotationLexer::T_O_PARENTHESIS:
                $this->tokenConsumer->consumeOpeningParenthesisToken();
                $this->tokenConsumer->addTokenToContent($value);
                break;
            case AnnotationLexer::T_C_PARENTHESIS:
                $this->tokenConsumer->addTokenToContent($value);
                $this->tokenConsumer->consumeClosingParenthesisToken();
                break;
            case AnnotationLexer::T_SINGLE_QUOTE:
            case AnnotationLexer::T_DOUBLE_QUOTE:
                $this->tokenConsumer->addTokenToContent($value);
                $this->tokenConsumer->consumeQuoteToken($type);
                break;
            case AnnotationLexer::T_ASTERISK:
                if ($this->tokenConsumer->hasOpenedString()) {
                    // We are in a string, save this token value.
                    $this->tokenConsumer->addTokenToContent($value);
                }
                break;
            case AnnotationLexer::T_LINE_BREAK:
                $this->tokenConsumer->addTokenToContent($value);
                $this->tokenConsumer->increaseLine();
                break;
            case AnnotationLexer::T_BACKSLASH:
            case AnnotationLexer::T_WHITESPACE:
            case AnnotationLexer::T_OTHER:
                $this->tokenConsumer->addTokenToContent($value);
                break;
            default:
                throw new AnnotationParseException(sprintf('A token of value "%s" has an invalid type', $value));
        }
        $this->tokenConsumer->afterConsume($type);
    }
332712
protected function createAnnotation($type, $value)
    {
        if (!isset($this->annotationTypes[$type])) {
            throw new OutOfBoundsException($this->translate(
                'Invalid annotation type "{type}".',
                ['type' => $type]
            ));
        }

        return $this->getPrototype(
                $this->annotationTypes[$type],
                ['umi\form\annotation\IAnnotation']
            )
            ->createInstance([$value]);
    }
1178565
protected function parseIsEnabled(string $value): Token
    {
        $value === '1' ? $this->setEnabled() : $this->setDisabled();

        return $this;
    }
457139
public function expect($type, $value = null)
    {
        if (!$this->match($type, $value)) {
            $msg = "Unexpected token {$this->current()->type} '{$this->current()->value}', expected {$type}";
            throw new \UnexpectedValueException($msg);
        }
        $current = $this->current();
        $this->next();
        return $current;
    }
724781
public function expectNext(int $type, $value = null) : bool
    {
        if (!$this->acceptNext($type, $value)) {
	        $this->syntaxError('Expected '.Token::getStringRepresentation($type, $value).' got '.$this->getNextToken());
        }

        return true;
    }
598741
protected function checkType($value)
    {
        if (is_string($value) !== true) {
            $msg = "The Identifier Datatype only accepts to store identifier values.";
            throw new InvalidArgumentException($msg);
        } elseif ($value === '') {
            $msg = "The Identifier Datatype do not accept empty strings as valid identifiers.";
            throw new InvalidArgumentException($msg);
        }
    }
92288
protected function parseParameterType($value): int
    {

        if ($value === null) {
            return PDO::PARAM_NULL;
        }

        if (\is_int($value) === true || \is_bool($value) === true) {
            return PDO::PARAM_INT;
        }

        return PDO::PARAM_STR;
    }
1058163
protected function getValue(Token $token, $value = null)
    {
        $value = $value ?: $token->match['value'];
        $type  = $token->match['type'];

        switch (true) {
            case $type === 'int':
                return (int) $value;
            case $type === 'char' &&
                 preg_match('(^(?P<value>-?\\d+)%2F100$)', $value, $match):
                return $match['value'] / 100;
            case $type === 'char':
                return (string) urldecode($value);
            default:
                throw new \RuntimeException(
                    "Unknown value type $type in line {$token->line} at position {$token->position}."
                );
        }
    }
692221
private function ConsumeToken2( $token, $value )
	{
		if ( in_array( $token, array( Token::DIV, Token::IDIV, Token::MOD ) ) && preg_match( "/\p{N}/", $this->Peek(0) ) )
		{
			throw XPath2Exception::withErrorCodeAndParam( "XPST0003", Resources::XPST0003, "The operator must be followed by space" );
		}
		$curr = new CurrentToken();
		$curr->token = $token;
		$curr->value = $value;
		$curr->anchor = $this->m_anchor;
		$curr->length = $this->m_length;
		array_push( $this->m_token, $curr );
	}
440339
public function setType($value)
    {
        $this->_validateNotNull('Type', $value);
        $this->_validateString('Type', $value);

        if ($this->data['type'] === $value) {
            return;
        }

        $this->data['type'] = $value;

        $this->_setModified('type');
    }
1142207
protected function setValue($value)
    {
        if (! is_bool($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be a boolean", static::prototype());
        }

        $this->value = $value;
    }
72415
protected function checkValue(): void
    {
        if (!ctype_digit($this->value) && !is_numeric($this->value) && !empty($this->value)) {
            throw new InvalidArgumentException('NumericParser: Value must be of type numeric');
        }
    }
650405
public function parse($value, $annotation = null)
    {
        if (false === ($value = filter_var($value, FILTER_VALIDATE_INT))) {
            throw new ParserException("Raw value must be integer. Invalid value '{$value}' given.");
        }

        return $value;
    }
309192
private function checkType($type, $value)
    {        
        switch($type)
        {
            case 'bool':
            case 'boolean':
                $codeException = (!is_bool($value)) ? 1 : 0;
                break;
            case 'int':
            case 'integer':
                $codeException = (!is_int($value)) ? 1 : 0;
                break;
            case 'string':
                $codeException = (!is_string($value)) ? 1 : 0;
                break;
            case 'not_resource':
                $codeException = (is_resource($value)) ? 2 : 0;
                break;
            default :
                $codeException = 3;
                break;
        }
        
        return $codeException;
    }
846813
function parseValue($value) {
        try {
            return \Plasma\Types\TypeExtensionsManager::getManager()->decodeType($this->type, $value)->getValue();
        } catch (\Plasma\Exception $e) {
            /* Continue regardless of error */
        }
        
        return $value;
    }
159756
public function setConfirmationType($value)
    {
        if ($value === null || $value === '') {
            $this->_confirmationTypes = null;
        } elseif (TypeCast::canCastToEnumString($value)) {
            if (!ConfirmationType::valueExists((string)$value)) {
                throw new \InvalidArgumentException('Invalid confirmation_type value: "' . $value . '"');
            }
            $this->_confirmationTypes = $value;
        } else {
            throw new \InvalidArgumentException('Invalid confirmation_type value type: "' . gettype($value) . '"');
        }
    }
59965
public function setValue($value, $type = null)
    {
        $this->value = $value;
        $this->type  = $type ?: ParameterTypeInferer::inferType($value);
    }