Skip to content

Commit 8cfbeb0

Browse files
committed
feature #19528 [ExpressionLanguage] Mention parsing and linting (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- [ExpressionLanguage] Mention parsing and linting Required for #19521 Commits ------- 42b5153 [ExpressionLanguage] Mention parsing and linting
2 parents 4f6ea6f + 42b5153 commit 8cfbeb0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

components/expression_language.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ can chain multiple coalescing operators.
9696

9797
The null-coalescing operator was introduced in Symfony 6.2.
9898

99+
Parsing and Linting Expressions
100+
...............................
101+
102+
The ExpressionLanguage component provides a way to parse and lint expressions.
103+
The :method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::parse`
104+
method returns a :class:`Symfony\\Component\\ExpressionLanguage\\ParsedExpression`
105+
instance that can be used to inspect and manipulate the expression. The
106+
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::lint`, on the
107+
other hand, returns a boolean indicating if the expression is valid or not::
108+
109+
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
110+
111+
$expressionLanguage = new ExpressionLanguage();
112+
113+
var_dump($expressionLanguage->parse('1 + 2'));
114+
// displays the AST nodes of the expression which can be
115+
// inspected and manipulated
116+
117+
var_dump($expressionLanguage->lint('1 + 2')); // displays true
118+
99119
Passing in Variables
100120
--------------------
101121

0 commit comments

Comments
 (0)