Вход Регистрация
Файл: upload/core/vendor/twig/twig/src/ExpressionParser/Infix/ArrowExpressionParser.php
Строк: 87
<?php

/*
 * This file is part of Twig.
 *
 * (c) Fabien Potencier
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace TwigExpressionParserInfix;

use 
TwigExpressionParserAbstractExpressionParser;
use 
TwigExpressionParserExpressionParserDescriptionInterface;
use 
TwigExpressionParserInfixAssociativity;
use 
TwigExpressionParserInfixExpressionParserInterface;
use 
TwigNodeExpressionAbstractExpression;
use 
TwigNodeExpressionArrowFunctionExpression;
use 
TwigParser;
use 
TwigToken;

/**
 * @internal
 */
final class ArrowExpressionParser extends AbstractExpressionParser implements InfixExpressionParserInterfaceExpressionParserDescriptionInterface
{
    public function 
parse(Parser $parserAbstractExpression $exprToken $token): AbstractExpression
    
{
        
// As the expression of the arrow function is independent from the current precedence, we want a precedence of 0
        
return new ArrowFunctionExpression($parser->parseExpression(), $expr$token->getLine());
    }

    public function 
getName(): string
    
{
        return 
'=>';
    }

    public function 
getDescription(): string
    
{
        return 
'Arrow function (x => expr)';
    }

    public function 
getPrecedence(): int
    
{
        return 
250;
    }

    public function 
getAssociativity(): InfixAssociativity
    
{
        return 
InfixAssociativity::Left;
    }
}
Онлайн: 1
Реклама