From ae51f93f70fa1d017becda734bb5dbe99098f026 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 17 Jan 2026 10:12:25 +0100 Subject: [PATCH] Fix documentation for getOperators() --- doc/advanced.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/advanced.rst b/doc/advanced.rst index 47683c44d..5650d0952 100644 --- a/doc/advanced.rst +++ b/doc/advanced.rst @@ -674,11 +674,11 @@ An extension is a class that implements the following interface:: public function getFunctions(); /** - * Returns a list of operators to add to the existing list. + * Returns a list of expression parsers to add to the existing list. * - * @return array First array of unary operators, second array of binary operators + * @return \Twig\ExpressionParser\ExpressionParserInterface[] */ - public function getOperators(); + public function getExpressionParsers(); } To keep your extension class clean and lean, inherit from the built-in @@ -793,8 +793,15 @@ responsible for parsing the tag and compiling it to PHP. Operators ~~~~~~~~~ -The ``getOperators()`` method lets you add new operators. To implement a new -one, have a look at the default operators provided by +.. versionadded:: 3.21 + + The ``getExpressionParsers()`` method was added in Twig 3.21 to replace the + deprecated ``getOperators()`` method. See the :doc:`deprecated + ` page for details on how to upgrade from ``getOperators()`` to + ``getExpressionParsers()``. + +The ``getExpressionParsers()`` method lets you add new operators. To implement +a new one, have a look at the default operators provided by ``Twig\Extension\CoreExtension``. Tests