diff --git a/components/expression_language/extending.rst b/components/expression_language/extending.rst index eeb9963c6c6..20a6aa9e188 100644 --- a/components/expression_language/extending.rst +++ b/components/expression_language/extending.rst @@ -90,6 +90,21 @@ register. } } +.. tip:: + + To create an expression function from a PHP function with the + :method:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunction::fromPhp` static method:: + + ExpressionFunction::fromPhp('strtoupper'); + + Namespaced functions are supported, but they require a second argument to + define the name of the expression:: + + ExpressionFunction::fromPhp('My\strtoupper', 'my_strtoupper'); + + .. versionadded:: 3.3 + The ``ExpressionFunction::fromPhp()`` method was introduced in Symfony 3.3. + You can register providers using :method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::registerProvider` or by using the second argument of the constructor::