8000 Fixed comments and splitted in intro and syntax · symfony/symfony-docs@8fe9fd6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8fe9fd6

Browse files
committed
Fixed comments and splitted in intro and syntax
1 parent 4ff9fae commit 8fe9fd6

File tree

4 files changed

+107
-93
lines changed

4 files changed

+107
-93
lines changed

components/expression_language/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Expression Language
55
:maxdepth: 2
66

77
introduction
8+
syntax

components/expression_language/introduction.rst

Lines changed: 7 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ The ExpressionLanguage Component
1010
(mostly, but not limited to, Booleans).
1111

1212
.. versionadded:: 2.4
13-
The ExpressionLanguage Component was new in Symfony 2.4.
13+
The ExpressionLanguage component was new in Symfony 2.4.
1414

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

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

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

2323
Usage
@@ -29,7 +29,7 @@ compare them to the expression in an ``if`` statement. A simple example of an
2929
expression is ``1 + 2``. You can also use more complicated expressions, such
3030
as ``someArray[3].someMethod('bar')``.
3131

32-
The component provide 2 ways to work with expressions:
32+
The component provides 2 ways to work with expressions:
3333

3434
* **compile**: the expression is compiled to PHP, so it can be cached and
3535
evaluated;
@@ -46,96 +46,10 @@ The main class of the component is
4646

4747
echo $language->compile('1 + 2'); // displays (1 + 2)
4848

49-
Supported Literals
50-
~~~~~~~~~~~~~~~~~~
49+
Expression Syntax
50+
-----------------
5151

52-
The component supports:
53-
54-
* **strings** - single and double quotes (e.g. ``'hello'``)
55-
* **numbers** - e.g. ``103``
56-
* **arrays** - using twig notation (e.g. ``[1, 2]``)
57-
* **hashes** - using twig notation (e.g. ``{ foo: 'bar' }``)
58-
* **booleans** - ``true`` and ``false``
59-
* **null** - ``null``
60-
61-
Supported Operators
62-
~~~~~~~~~~~~~~~~~~~
63-
64-
The component comes with a lot of operators:
65-
66-
Arithmetic Operators
67-
....................
68-
69-
* ``+`` (addition)
70-
* ``-`` (subtraction)
71-
* ``*`` (multiplication)
72-
* ``/`` (division)
73-
* ``%`` (modulus)
74-
* ``**`` (pow)
75-
76-
Assignment Operators
77-
....................
78-
79-
* ``=``
80-
81-
Bitwise Operators
82-
.................
83-
84-
* ``&`` (and)
85-
* ``|`` (or)
86-
* ``^`` (xor)
87-
88-
Comparison Operators
89-
....................
90-
91-
* ``==`` (equal)
92-
* ``===`` (identical)
93-
* ``!=`` (not equal)
94-
* ``!==`` (not identical)
95-
* ``<`` (less than)
96-
* ``>`` (greater than)
97-
* ``<=`` (less than or equal to)
98-
* ``>=`` (greater than or equal to)
99-
* ``=~`` (regex match)
100-
* ``!~`` (regex does not match)
101-
102-
.. sidebar:: Regex Operator
103-
104-
The Regex Operators (``=~`` and ``!~``) are coming from Perl. This
105-
operator matches if the regular expression on the right side of the
106-
operator matches the string on the left. For instance, 6D40
107-
``'foobar' =~ '/foo/'`` evaluates to true.
108-
``!~`` is the opposite and matches if the regular expression does *not*
109-
match the string.
110-
111-
Logical Operators
112-
.................
113-
114-
* ``not`` or ``!``
115-
* ``and`` or ``&&``
116-
* ``or`` or ``||``
117-
118-
String Operators
119-
................
120-
121-
* ``~`` (concatenation)
122-
123-
Array Operators
124-
...............
125-
126-
* ``in`` (contain)
127-
* ``not in`` (does not contain)
128-
129-
Numeric Operators
130-
.................
131-
132-
* ``..`` (range)
133-
134-
Ternary Operators
135-
.................
136-
137-
* ``foo ? 'yes' : 'no'``
138-
* ``foo ?: 'no'`` (equal to ``foo ? foo : 'no'``)
139-
* ``foo ? 'yes'`` (equal to ``foo ? 'yes' : ''``)
52+
See ":doc:`/components/expression_language/syntax`" to learn the syntax of the
53+
ExpressionLanguage component.
14054

14155
.. _Packagist: https://packagist.org/packages/symfony/expression-language
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
.. index::
2+
single: Syntax; ExpressionLanguage
3+
4+
The Expression Syntax
5+
=====================
6+
7+
The ExpressionLanguage component uses a specific syntax which is based on the
8+
expression syntax of Twig. In this document, you can find all supported
9+
syntaxes.
10+
11+
Supported Literals
12+
~~~~~~~~~~~~~~~~~~
13+
14+
The component supports:
15+
16+
* **strings** - single and double quotes (e.g. ``'hello'``)
17+
* **numbers** - e.g. ``103``
18+
* **arrays** - using twig notation (e.g. ``[1, 2]``)
19+
* **hashes** - using twig notation (e.g. ``{ foo: 'bar' }``)
20+
* **booleans** - ``true`` and ``false``
21+
* **null** - ``null``
22+
23+
Supported Operators
24+
~~~~~~~~~~~~~~~~~~~
25+
26+
The component comes with a lot of operators:
27+
28+
Arithmetic Operators
29+
....................
30+
31+
* ``+`` (addition)
32+
* ``-`` (subtraction)
33+
* ``*`` (multiplication)
34+
* ``/`` (division)
35+
* ``%`` (modulus)
36+
* ``**`` (pow)
37+
38+
Assignment Operators
39+
....................
40+
41+
* ``=``
42+
43+
Bitwise Operators
44+
.................
45+
46+
* ``&`` (and)
47+
* ``|`` (or)
48+
* ``^`` (xor)
49+
50+
Comparison Operators
51+
....................
52+
53+
* ``==`` (equal)
54+
* ``===`` (identical)
55+
* ``!=`` (not equal)
56+
* ``!==`` (not identical)
57+
* ``<`` (less than)
58+
* ``>`` (greater than)
59+
* ``<=`` (less than or equal to)
60+
* ``>=`` (greater than or equal to)
61+
* ``matches`` (regex match)
62+
63+
.. tip::
64+
65+
To test if a string does *not* match a regex, use the logical ``not``
66+
operator in combination with the ``matches`` operator::
67+
68+
$language->evaluate('not "foo" matches "/bar/"'); // returns true
69+
70+
Logical Operators
71+
.................
72+
73+
* ``not`` or ``!``
74+
* ``and`` or ``&&``
75+
* ``or`` or ``||``
76+
77+
String Operators
78+
................
79+
80+
* ``~`` (concatenation)
81+
82+
Array Operators
83+
...............
84+
85+
* ``in`` (contain)
86+
* ``not in`` (does not contain)
87+
88+
Numeric Operators
89+
.................
90+
91+
* ``..`` (range)
92+
93+
Ternary Operators
94+
.................
95+
96+
* ``foo ? 'yes' : 'no'``
97+
* ``foo ?: 'no'`` (equal to ``foo ? foo : 'no'``)
98+
* ``foo ? 'yes'`` (equal to ``foo ? 'yes' : ''``)

components/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* :doc:`/components/expression_language/index`
6161

6262
* :doc:`/components/expression_language/introduction`
63+
* :doc:`/components/expression_language/syntax`
6364

6465
* **Filesystem**
6566

0 commit comments

Comments
 (0)
0