Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MatchesBinary.php

function MatchesBinary::__construct

Overrides AbstractBinary::__construct

File

vendor/twig/twig/src/Node/Expression/Binary/MatchesBinary.php, line 21

Class

MatchesBinary

Namespace

Twig\Node\Expression\Binary

Code

public function __construct(Node $left, Node $right, int $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.', $regexp, substr($m, 14)), $lineno));
        try {
            preg_match($regexp, '');
        } finally {
            restore_error_handler();
        }
    }
    parent::__construct($left, $right, $lineno);
}
RSS feed
Powered by Drupal