@@ -127,9 +127,16 @@ Working with Functions
127127----------------------
128128
129129You can also use registered functions in the expression by using the same
130- syntax as PHP and JavaScript. The ExpressionLanguage component comes with one
131- function by default: ``constant() ``, which will return the value of the PHP
132- constant::
130+ syntax as PHP and JavaScript. The ExpressionLanguage component comes with the
131+ following functions by default:
132+
133+ * ``constant() ``
134+ * ``enum() ``
135+
136+ ``constant() `` function
137+ ~~~~~~~~~~~~~~~~~~~~~~~
138+
139+ This function will return the value of a PHP constant::
133140
134141 define('DB_USER', 'root');
135142
@@ -139,6 +146,43 @@ constant::
139146
140147This will print out ``root ``.
141148
149+ This also works with class constants::
150+
151+ namespace App\SomeNamespace;
152+
153+ class Foo
154+ {
155+ public const API_ENDPOINT = '/api';
156+ }
157+
158+ var_dump($expressionLanguage->evaluate(
159+ 'constant("App\\\SomeNamespace\\\Foo::API_ENDPOINT")'
160+ ));
161+
162+ This will print out ``/api ``.
163+
164+ ``enum() `` function
165+ ~~~~~~~~~~~~~~~~~~~
166+
167+ This function will return the case of an enumeration::
168+
169+ namespace App\SomeNamespace;
170+
171+ enum Foo
172+ {
173+ case Bar;
174+ }
175+
176+ var_dump(App\Enum\Foo::Bar === $expressionLanguage->evaluate(
177+ 'enum("App\\\SomeNamespace\\\Foo::Bar")'
178+ ));
179+
180+ This will print out ``true ``.
181+
182+ .. versionadded :: 6.3
183+
184+ The ``enum() `` function was introduced in Symfony 6.3.
185+
142186.. tip ::
143187
144188 To read how to register your own functions to use in an expression, see
0 commit comments