protected function validateAttributeType(TokenStream $stream, $type, array $allowed): void
    {
        $valid = false;

        foreach ($allowed as $aType) {
            if ($stream->test(\constant(Token::class.'::'.$aType.'_TYPE'))) {
                $valid = true;

                break;
            }
        }

        if (!$valid) {
            $message = 'The attribute %s "%s" must be an %s';

            throw new SyntaxError(sprintf($message, $type, $stream->getCurrent()->getValue(), implode(', ', $allowed)), $stream->getCurrent()->getLine(), $stream->getSourceContext());
        }
    }
protected function validateAttributeType(TokenStream $stream, $type, array $allowed): void
    {
        $valid = false;

        foreach ($allowed as $aType) {
            if ($stream->test(\constant(Token::class.'::'.$aType.'_TYPE'))) {
                $valid = true;

                break;
            }
        }

        if (!$valid) {
            $message = 'The attribute %s "%s" must be an %s';

            throw new SyntaxError(sprintf($message, $type, $stream->getCurrent()->getValue(), implode(', ', $allowed)), $stream->getCurrent()->getLine(), $stream->getSourceContext());
        }
    }
protected function validateAttributeType ( TokenStream $ stream , $ type , array $ allowed ) : void { $ valid = false ; foreach ( $ allowed as $ aType ) { if ( $ stream -> test ( \ constant ( Token :: class . '::' . $ aType . '_TYPE' ) ) ) { $ valid = true ; break ; } } if ( ! $ valid ) { $ message = 'The attribute %s "%s" must be an %s' ; throw new SyntaxError ( sprintf ( $ message , $ type , $ stream -> getCurrent ( ) -> getValue ( ) , implode ( ', ' , $ allowed ) ) , $ stream -> getCurrent ( ) -> getLine ( ) , $ stream -> getSourceContext ( ) ) ; } }
Validate the current attribute type.

@param TokenStream $stream
@param string      $type
@param string[]    $allowed

@throws SyntaxError When the attribute type is not allowed
Validate the current attribute type .