Skip to content

Commit 18630b7

Browse files
committed
minor #20353 [ExpressionLanguage] Update Expression_language: lint function (kl3sk)
This PR was merged into the 7.1 branch. Discussion ---------- [ExpressionLanguage] Update Expression_language: lint function The lint function doesn't return anything but exception. Second arguments with Flags example is ommitted. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `7.x` for features of unreleased versions). --> Commits ------- a8841ee Update Expression_language: lint function
2 parents 3ee3f40 + a8841ee commit 18630b7

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)