Skip to content

Commit 1b4eab4

Browse files
committed
feature #7517 [ExpressionLanguage] Document ExpressionFunction::fromPhp (maidmaid, javiereguiluz)
This PR was merged into the master branch. Discussion ---------- [ExpressionLanguage] Document ExpressionFunction::fromPhp cf symfony/symfony#21122 Commits ------- 415c4ec Update extending.rst 478400a Minor reword 059155f Add versionadded 6c9e09d Fix typo c70ea7f Fix typo 6d9af37 Add fromPhp tip
2 parents 89cba1e + 415c4ec commit 1b4eab4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/expression_language/extending.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ register.
9090
}
9191
}
9292
93+
.. tip::
94+
95+
To create an expression function from a PHP function with the
96+
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunction::fromPhp` static method::
97+
98+
ExpressionFunction::fromPhp('strtoupper');
99+
100+
Namespaced functions are supported, but they require a second argument to
101+
define the name of the expression::
102+
103+
ExpressionFunction::fromPhp('My\strtoupper', 'my_strtoupper');
104+
105+
.. versionadded:: 3.3
106+
The ``ExpressionFunction::fromPhp()`` method was introduced in Symfony 3.3.
107+
93108
You can register providers using
94109
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::registerProvider`
95110
or by using the second argument of the constructor::

0 commit comments

Comments
 (0)