mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 21:37:29 +00:00
Deprecate passing non AbstractExpression nodes to MatchesBinary
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# 3.24.0 (2026-XX-XX)
|
# 3.24.0 (2026-XX-XX)
|
||||||
|
|
||||||
|
* Deprecate passing a non-`AbstractExpression` node to `ParserTwig\Node\Expression\Binary\MatchesBinary` constructor
|
||||||
* Deprecate passing a non-`AbstractExpression` node to `Parser::setParent()`
|
* Deprecate passing a non-`AbstractExpression` node to `Parser::setParent()`
|
||||||
* Add support for renaming variables in object destructuring (`{name: userName} = user`)
|
* Add support for renaming variables in object destructuring (`{name: userName} = user`)
|
||||||
* Add `html_attr_relaxed` escaping strategy that preserves :, @, [, and ] for front-end framework attribute names
|
* Add `html_attr_relaxed` escaping strategy that preserves :, @, [, and ] for front-end framework attribute names
|
||||||
|
|||||||
@@ -242,6 +242,11 @@ Parser
|
|||||||
deprecated as of Twig 3.24; the method will require an ``AbstractExpression``
|
deprecated as of Twig 3.24; the method will require an ``AbstractExpression``
|
||||||
instance in Twig 4.0.
|
instance in Twig 4.0.
|
||||||
|
|
||||||
|
* Passing non-``AbstractExpression`` nodes to
|
||||||
|
``Twig\Node\Expression\Binary\MatchesBinary`` constructor is deprecated as of
|
||||||
|
Twig 3.24; the constructor will require an ``AbstractExpression`` instance in Twig
|
||||||
|
4.0.
|
||||||
|
|
||||||
* The ``Twig\Parser::getExpressionParser()`` method is deprecated as of Twig
|
* The ``Twig\Parser::getExpressionParser()`` method is deprecated as of Twig
|
||||||
3.21, use ``Twig\Parser::parseExpression()`` instead.
|
3.21, use ``Twig\Parser::parseExpression()`` instead.
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace Twig\Node\Expression\Binary;
|
|||||||
|
|
||||||
use Twig\Compiler;
|
use Twig\Compiler;
|
||||||
use Twig\Error\SyntaxError;
|
use Twig\Error\SyntaxError;
|
||||||
|
use Twig\Node\Expression\AbstractExpression;
|
||||||
use Twig\Node\Expression\ConstantExpression;
|
use Twig\Node\Expression\ConstantExpression;
|
||||||
use Twig\Node\Expression\ReturnBoolInterface;
|
use Twig\Node\Expression\ReturnBoolInterface;
|
||||||
use Twig\Node\Node;
|
use Twig\Node\Node;
|
||||||
@@ -21,6 +22,13 @@ class MatchesBinary extends AbstractBinary implements ReturnBoolInterface
|
|||||||
{
|
{
|
||||||
public function __construct(Node $left, Node $right, int $lineno)
|
public function __construct(Node $left, Node $right, int $lineno)
|
||||||
{
|
{
|
||||||
|
if (!$left instanceof AbstractExpression) {
|
||||||
|
trigger_deprecation('twig/twig', '3.24', 'Passing a "%s" instance to "%s()" first argument is deprecated, pass an "AbstractExpression" instance instead.', $left::class, __METHOD__);
|
||||||
|
}
|
||||||
|
if (!$right instanceof AbstractExpression) {
|
||||||
|
trigger_deprecation('twig/twig', '3.24', 'Passing a "%s" instance to "%s()" second argument is deprecated, pass an "AbstractExpression" instance instead.', $right::class, __METHOD__);
|
||||||
|
}
|
||||||
|
|
||||||
if ($right instanceof ConstantExpression) {
|
if ($right instanceof ConstantExpression) {
|
||||||
$regexp = $right->getAttribute('value');
|
$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));
|
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));
|
||||||
|
|||||||
Reference in New Issue
Block a user