function MatchesBinary::__construct
Overrides AbstractBinary::__construct
File
-
vendor/
twig/ twig/ src/ Node/ Expression/ Binary/ MatchesBinary.php, line 21
Class
Namespace
Twig\Node\Expression\BinaryCode
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);
}