File tree 2 files changed +21
-1
lines changed 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,26 @@ can chain multiple coalescing operators.
92
92
* ``foo[3] ?? 'no' ``
93
93
* ``foo.baz ?? foo['baz'] ?? 'no' ``
94
94
95
+ Parsing and Linting Expressions
96
+ ...............................
97
+
98
+ The ExpressionLanguage component provides a way to parse and lint expressions.
99
+ The :method: `Symfony\\ Component\\ ExpressionLanguage\\ ExpressionLanguage::parse `
100
+ method returns a :class: `Symfony\\ Component\\ ExpressionLanguage\\ ParsedExpression `
101
+ instance that can be used to inspect and manipulate the expression. The
102
+ :method: `Symfony\\ Component\\ ExpressionLanguage\\ ExpressionLanguage::lint `, on the
103
+ other hand, returns a boolean indicating if the expression is valid or not::
104
+
105
+ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
106
+
107
+ $expressionLanguage = new ExpressionLanguage();
108
+
109
+ var_dump($expressionLanguage->parse('1 + 2'));
110
+ // displays the AST nodes of the expression which can be
111
+ // inspected and manipulated
112
+
113
+ var_dump($expressionLanguage->lint('1 + 2')); // displays true
114
+
95
115
Passing in Variables
96
116
--------------------
97
117
Original file line number Diff line number Diff line change @@ -509,7 +509,7 @@ like this::
509
509
$cloner = new VarCloner();
510
510
$dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();
511
511
512
- $dumper->dump($cloner->cloneVar($var));
512
+ return $dumper->dump($cloner->cloneVar($var));
513
513
});
514
514
515
515
Cloners
You can’t perform that action at this time.
0 commit comments