From 7edd5d171de559b4fa471a961c3a8b5e6143978c Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Sun, 4 Feb 2024 20:45:39 +0100 Subject: [PATCH] [ExpressionLanguage] Add min and max php functions --- reference/formats/expression_language.rst | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/reference/formats/expression_language.rst b/reference/formats/expression_language.rst index 6c9b1bffe42..9a3e78ef485 100644 --- a/reference/formats/expression_language.rst +++ b/reference/formats/expression_language.rst @@ -120,6 +120,8 @@ following functions by default: * ``constant()`` * ``enum()`` +* ``min()`` +* ``max()`` ``constant()`` function ~~~~~~~~~~~~~~~~~~~~~~~ @@ -167,6 +169,32 @@ This function will return the case of an enumeration:: This will print out ``true``. +``min()`` function +~~~~~~~~~~~~~~~~~~ + +This function will return the lowest value:: + + var_dump($expressionLanguage->evaluate( + 'min(1, 2, 3)' + )); + +This will print out ``1``. + +``max()`` function +~~~~~~~~~~~~~~~~~~ + +This function will return the highest value:: + + var_dump($expressionLanguage->evaluate( + 'max(1, 2, 3)' + )); + +This will print out ``3``. + +.. versionadded:: 7.1 + + The ``min()`` and ``max()`` functions were introduced in Symfony 7.1. + .. tip:: To read how to register your own functions to use in an expression, see