Вход Регистрация
Файл: upload/core/vendor/twig/twig/src/Node/Expression/Binary/MatchesBinary.php
Строк: 56
<?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 TwigNodeExpressionBinary;

use 
TwigCompiler;
use 
TwigErrorSyntaxError;
use 
TwigNodeExpressionConstantExpression;
use 
TwigNodeExpressionReturnBoolInterface;
use 
TwigNodeNode;

class 
MatchesBinary extends AbstractBinary implements ReturnBoolInterface
{
    public function 
__construct(Node $leftNode $rightint $lineno)
    {
        if (
$right instanceof ConstantExpression) {
            
$regexp $right->getAttribute('value');
            
set_error_handler(static fn ($t$m) => throw new SyntaxError(sprintf('Regexp "%s" passed to "matches" is not valid: %s.'$regexpsubstr($m14)), $lineno));
            try {
                
preg_match($regexp'');
            } finally {
                
restore_error_handler();
            }
        }

        
parent::__construct($left$right$lineno);
    }

    public function 
compile(Compiler $compiler): void
    
{
        
$compiler
            
->raw('CoreExtension::matches(')
            ->
subcompile($this->getNode('right'))
            ->
raw(', ')
            ->
subcompile($this->getNode('left'))
            ->
raw(')')
        ;
    }

    public function 
operator(Compiler $compiler): Compiler
    
{
        return 
$compiler->raw('');
    }
}
Онлайн: 0
Реклама