Fix documentation for getOperators()

This commit is contained in:
Fabien Potencier
2026-01-17 10:12:25 +01:00
parent 0b1ef6cda0
commit ae51f93f70
+12 -5
View File
@@ -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<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
<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