Skip to content

Commit a14c39d

Browse files
committed
[#3191] Many tweaks to expression language component thanks to @wouterj, @xabbuh and @cordoval. Thanks guys!
1 parent e9a81bf commit a14c39d

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

components/expression_language/introduction.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ The ExpressionLanguage Component
1010
(mostly, but not limited to, Booleans).
1111

1212
.. versionadded:: 2.4
13-
The ExpressionLanguage component was added in Symfony 2.4.
13+
The ExpressionLanguage component was introduced in Symfony 2.4.
1414

1515
Installation
1616
------------
1717

1818
You can install the component in 2 different ways:
1919

20-
* :doc:`Install it via Composer </components/using_components>` (``symfony/expression-language`` on `Packagist`_).
21-
* Use the official Git repository (https://github.com/symfony/expression-language);
20+
* :doc:`Install it via Composer </components/using_components>` (``symfony/expression-language`` on `Packagist`_);
21+
* Use the official Git repository (https://github.com/symfony/expression-language).
2222

2323
How can the Expression Engine Help Me?
2424
--------------------------------------
2525

2626
The purpose of the component is to allow users to use expressions inside
27-
configuration for more complex logic. In the Symfony2 Framework, for example,
28-
expressions can be used in security, for validation rules, and in route matching.
27+
configuration for more complex logic. For some examples, the Symfony2 Framework
28+
uses expressions in security, for validation rules and in route matching.
2929

3030
Besides using the component in the framework itself, the ExpressionLanguage
3131
component is a perfect candidate for the foundation of a *business rule engine*.
@@ -52,15 +52,15 @@ Usage
5252

5353
The ExpressionLanguage component can compile and evaluate expressions.
5454
Expressions are one-liners that often return a Boolean, which can be used
55-
by the code executing the expression in an ``if`` statements. A simple example
55+
by the code executing the expression in an ``if`` statement. A simple example
5656
of an expression is ``1 + 2``. You can also use more complicated expressions,
5757
such as ``someArray[3].someMethod('bar')``.
5858

5959
The component provides 2 ways to work with expressions:
6060

61+
* **evaluation**: the expression is evaluated without being compiled to PHP;
6162
* **compile**: the expression is compiled to PHP, so it can be cached and
62-
evaluated;
63-
* **evaluation**: the expression is evaluated without being compiled to PHP.
63+
evaluated.
6464

6565
The main class of the component is
6666
:class:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage`::

components/expression_language/syntax.rst

+9-5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ to JavaScript::
4949
)
5050
);
5151

52+
This will print ``Honeycrisp``;
53+
5254
Calling Methods
5355
~~~~~~~~~~~~~~~
5456

@@ -77,7 +79,7 @@ JavaScript::
7779
)
7880
);
7981

80-
This will print "Hi Hi Hi!";
82+
This will print ``Hi Hi Hi!``.
8183

8284
.. _component-expression-arrays:
8385

@@ -178,7 +180,7 @@ Examples::
178180
)
179181
);
180182

181-
These would both return ``false``.
183+
Both variables would be set to ``false``.
182184

183185
Logical Operators
184186
~~~~~~~~~~~~~~~~~
@@ -198,7 +200,7 @@ For example::
198200
)
199201
);
200202

201-
This would return ``true``.
203+
This ``$ret`` variable will be set to ``true``.
202204

203205
String Operators
204206
~~~~~~~~~~~~~~~~
@@ -207,7 +209,7 @@ String Operators
207209

208210
For example::
209211

210-
$ret4 = $language->evaluate(
212+
echo $language->evaluate(
211213
'firstName~" "~lastName',
212214
array(
213215
'firstName' => 'Arthur',
@@ -233,13 +235,15 @@ For example::
233235
$user = new User();
234236
$user->group = 'human_resources';
235237

236-
$ret5 = $language->evaluate(
238+
$inGroup = $language->evaluate(
237239
'user.group in ["human_resources", "marketing"]',
238240
array(
239241
'user' => $user
240242
)
241243
);
242244

245+
The ``$inGroup`` would evaluate to ``true``.
246+
243247
Numeric Operators
244248
~~~~~~~~~~~~~~~~~
245249

0 commit comments

Comments
 (0)