diff --git a/components/expression_language.rst b/components/expression_language.rst index bf7b62f6f81..8a475e1f062 100644 --- a/components/expression_language.rst +++ b/components/expression_language.rst @@ -96,6 +96,26 @@ can chain multiple coalescing operators. The null-coalescing operator was introduced in Symfony 6.2. +Parsing and Linting Expressions +............................... + +The ExpressionLanguage component provides a way to parse and lint expressions. +The :method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::parse` +method returns a :class:`Symfony\\Component\\ExpressionLanguage\\ParsedExpression` +instance that can be used to inspect and manipulate the expression. The +:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionLanguage::lint`, on the +other hand, returns a boolean indicating if the expression is valid or not:: + + use Symfony\Component\ExpressionLanguage\ExpressionLanguage; + + $expressionLanguage = new ExpressionLanguage(); + + var_dump($expressionLanguage->parse('1 + 2')); + // displays the AST nodes of the expression which can be + // inspected and manipulated + + var_dump($expressionLanguage->lint('1 + 2')); // displays true + Passing in Variables --------------------