Skip to content

Commit 9213854

Browse files
committed
feature #19501 [ExpressionLanguage] Add min and max php functions (alamirault)
This PR was merged into the 7.1 branch. Discussion ---------- [ExpressionLanguage] Add `min` and `max` php functions Fix #19479 Commits ------- 7edd5d1 [ExpressionLanguage] Add min and max php functions
2 parents ce23225 + 7edd5d1 commit 9213854

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

reference/formats/expression_language.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ following functions by default:
120120

121121
* ``constant()``
122122
* ``enum()``
123+
* ``min()``
124+
* ``max()``
123125

124126
``constant()`` function
125127
~~~~~~~~~~~~~~~~~~~~~~~
@@ -167,6 +169,32 @@ This function will return the case of an enumeration::
167169

168170
This will print out ``true``.
169171

172+
``min()`` function
173+
~~~~~~~~~~~~~~~~~~
174+
175+
This function will return the lowest value::
176+
177+
var_dump($expressionLanguage->evaluate(
178+
'min(1, 2, 3)'
179+
));
180+
181+
This will print out ``1``.
182+
183+
``max()`` function
184+
~~~~~~~~~~~~~~~~~~
185+
186+
This function will return the highest value::
187+
188+
var_dump($expressionLanguage->evaluate(
189+
'max(1, 2, 3)'
190+
));
191+
192+
This will print out ``3``.
193+
194+
.. versionadded:: 7.1
195+
196+
The ``min()`` and ``max()`` functions were introduced in Symfony 7.1.
197+
170198
.. tip::
171199

172200
To read how to register your own functions to use in an expression, see

0 commit comments

Comments
 (0)