Skip to content

Commit d88bfcc

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: fix merge [VarDumper] Test intl formatter broken since dumper does not replace the nnbsp character by standard space [WebProfilerBundle] Fix intercept external redirects [Webhook] Added missing XML attribute in config XSD [String] Skip a test when an issue is detected in PCRE2 [ExpressionLanguage] Fix null coalescing propagation [Mailer] Stop using the (local) AWS shared configuration in the PHPUnit tests. detect colors on not windows fix xterm detection refactor: hyper check Missing translations for Slovak (sk) #51954 Remove redundant PHPdoc line properly handle SYMFONY_DOTENV_VARS being the empty string Avoid incompatibility with symfony/console 7 bug #45057 [Messenger] Avoid reconnecting active Redis connections. [HttpKernel] Catch `TypeError` if the wrong type is used in `BackedEnumValueResolver` [Serializer] fix regression where nullable int cannot be serialized do not overwrite an application's default serialization context
2 parents 46520d8 + 7d63ccd commit d88bfcc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Node/NullCoalesceNode.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function compile(Compiler $compiler): void
3939
public function evaluate(array $functions, array $values): mixed
4040
{
4141
if ($this->nodes['expr1'] instanceof GetAttrNode) {
42-
$this->nodes['expr1']->attributes['is_null_coalesce'] = true;
42+
$this->addNullCoalesceAttributeToGetAttrNodes($this->nodes['expr1']);
4343
}
4444

4545
return $this->nodes['expr1']->evaluate($functions, $values) ?? $this->nodes['expr2']->evaluate($functions, $values);
@@ -49,4 +49,17 @@ public function toArray(): array
4949
{
5050
return ['(', $this->nodes['expr1'], ') ?? (', $this->nodes['expr2'], ')'];
5151
}
52+
53+
private function addNullCoalesceAttributeToGetAttrNodes(Node $node): void
54+
{
55+
if (!$node instanceof GetAttrNode) {
56+
return;
57+
}
58+
59+
$node->attributes['is_null_coalesce'] = true;
60+
61+
foreach ($node->nodes as $node) {
62+
$this->addNullCoalesceAttributeToGetAttrNodes($node);
63+
}
64+
}
5265
}

Tests/ExpressionLanguageTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ public function bar()
424424
yield ['foo["bar"]["baz"] ?? "default"', ['bar' => null]];
425425
yield ['foo["bar"].baz ?? "default"', ['bar' => null]];
426426
yield ['foo.bar().baz ?? "default"', $foo];
427+
yield ['foo.bar.baz.bam ?? "default"', (object) ['bar' => null]];
428+
yield ['foo?.bar?.baz?.qux ?? "default"', (object) ['bar' => null]];
429+
yield ['foo[123][456][789] ?? "default"', [123 => []]];
427430
}
428431

429432
/**

0 commit comments

Comments
 (0)