-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Symfony version(s) affected
7.0
Description
According to docs, we can use null-coalescing operator to provide fallback to potentially empty or even nonexistent variables. However I can't make it work, even in a simple file with nothing but Expression Language.
How to reproduce
$lang = new ExpressionLanguage();
$data = [
'exists' => true,
];
$expression1 = 'notexists ?? "nope,"';
$expression2 = '(notexists ?? "nope,")';
$expression3 = '(notexists ?? false) ? "yes" : "no"';
foreach ([$expression1, $expression2, $expression3] as $exp) {
try {
var_dump($lang->evaluate($exp, $data));
} catch (\Throwable $th) {
echo('!');
}
}
// expected: nope,nope,no
// actual: !!!(In the reproduction I have suppressed the throws, but every evaluate fails with Fatal error: Uncaught Symfony\Component\ExpressionLanguage\SyntaxError: Variable "notexists" is not valid around position …
Possible Solution
No response
Additional Context
No response