Skip to content

Commit aaf347e

Browse files
authored
Update Expression_language: lint function
The lint function doesn't return anything but exception. Second arguments with Flags example is ommitted.
1 parent 37be281 commit aaf347e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

components/expression_language.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ other hand, returns a boolean indicating if the expression is valid or not::
103103
// displays the AST nodes of the expression which can be
104104
// inspected and manipulated
105105

106-
var_dump($expressionLanguage->lint('1 + 2', [])); // displays true
106+
$expressionLanguage->lint('1 + a', []);
107+
// Throw SyntaxError Exception
108+
// "Variable "a" is not valid around position 5 for expression `1 + a`."
107109

108110
The behavior of these methods can be configured with some flags defined in the
109111
:class:`Symfony\\Component\\ExpressionLanguage\\Parser` class:
@@ -120,8 +122,8 @@ This is how you can use these flags::
120122

121123
$expressionLanguage = new ExpressionLanguage();
122124

123-
// this returns true because the unknown variables and functions are ignored
124-
var_dump($expressionLanguage->lint('unknown_var + unknown_function()', Parser::IGNORE_UNKNOWN_VARIABLES | Parser::IGNORE_UNKNOWN_FUNCTIONS));
125+
// this returns null because the unknown variables and functions are ignored, but don't throw `SyntaxError` exception
126+
var_dump($expressionLanguage->lint('unknown_var + unknown_function()', [], Parser::IGNORE_UNKNOWN_VARIABLES | Parser::IGNORE_UNKNOWN_FUNCTIONS));
125127

126128
.. versionadded:: 7.1
127129

0 commit comments

Comments
 (0)