Вход Регистрация
Файл: upload/core/vendor/twig/twig/src/ExpressionParser/Prefix/UnaryOperatorExpressionParser.php
Строк: 108
<?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 TwigExpressionParserPrefix;

use 
TwigExpressionParserAbstractExpressionParser;
use 
TwigExpressionParserExpressionParserDescriptionInterface;
use 
TwigExpressionParserPrecedenceChange;
use 
TwigExpressionParserPrefixExpressionParserInterface;
use 
TwigNodeExpressionAbstractExpression;
use 
TwigNodeExpressionUnaryAbstractUnary;
use 
TwigParser;
use 
TwigToken;

/**
 * @internal
 */
final class UnaryOperatorExpressionParser extends AbstractExpressionParser implements PrefixExpressionParserInterfaceExpressionParserDescriptionInterface
{
    public function 
__construct(
        
/** @var class-string<AbstractUnary> */
        
private string $nodeClass,
        private 
string $name,
        private 
int $precedence,
        private ?
PrecedenceChange $precedenceChange null,
        private ?
string $description null,
        private array 
$aliases = [],
        private ?
int $operandPrecedence null,
    ) {
    }

    
/**
     * @return AbstractUnary
     */
    
public function parse(Parser $parserToken $token): AbstractExpression
    
{
        return new (
$this->nodeClass)($parser->parseExpression($this->operandPrecedence ?? $this->precedence), $token->getLine());
    }

    public function 
getName(): string
    
{
        return 
$this->name;
    }

    public function 
getDescription(): string
    
{
        return 
$this->description ?? '';
    }

    public function 
getPrecedence(): int
    
{
        return 
$this->precedence;
    }

    public function 
getPrecedenceChange(): ?PrecedenceChange
    
{
        return 
$this->precedenceChange;
    }

    public function 
getAliases(): array
    {
        return 
$this->aliases;
    }
}
Онлайн: 1
Реклама