Skip to content

Commit a8841ee

Browse files
kl3skjaviereguiluz
authored andcommitted
Update Expression_language: lint function
The lint function doesn't return anything but exception. Second arguments with Flags example is ommitted. Update expression_language.rst Removing `var_dump`, this make no sens here. Update expression_language.rst Sync with last commits Update expression_language.rst Change comment explication for "IGNORE_*" flags
1 parent 3ee3f40 commit a8841ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/expression_language.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ if the expression is not valid::
106106

107107
$expressionLanguage->lint('1 + 2', []); // doesn't throw anything
108108

109+
$expressionLanguage->lint('1 + a', []);
110+
// Throw SyntaxError Exception
111+
// "Variable "a" is not valid around position 5 for expression `1 + a`."
112+
109113
The behavior of these methods can be configured with some flags defined in the
110114
:class:`Symfony\\Component\\ExpressionLanguage\\Parser` class:
111115

@@ -121,8 +125,8 @@ This is how you can use these flags::
121125

122126
$expressionLanguage = new ExpressionLanguage();
123127

124-
// this returns true because the unknown variables and functions are ignored
125-
var_dump($expressionLanguage->lint('unknown_var + unknown_function()', Parser::IGNORE_UNKNOWN_VARIABLES | Parser::IGNORE_UNKNOWN_FUNCTIONS));
128+
// Does not throw a SyntaxError because the unknown variables and functions are ignored
129+
$expressionLanguage->lint('unknown_var + unknown_function()', [], Parser::IGNORE_UNKNOWN_VARIABLES | Parser::IGNORE_UNKNOWN_FUNCTIONS);
126130

127131
.. versionadded:: 7.1
128132

0 commit comments

Comments
 (0)