bug #35537 [Config][XmlReferenceDumper] Prevent potential \TypeError (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[Config][XmlReferenceDumper] Prevent potential \TypeError

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | https://github.com/symfony/symfony/issues/34841
| License       | MIT
| Doc PR        | -

`$key` can be null and `setName()` is now typed with `string`. Fallbacking on an empty string restores the behavior (and output) of < 5.0.

However, that shows that's a case we don't handle (yet) properly. But that's another task 😃

Commits
-------

e8ba15ed27 [Config][XmlReferenceDumper] Prevent potential \TypeError
This commit is contained in:
Nicolas Grekas 2020-02-03 18:14:20 +01:00
commit c29989d69e

View File

@ -91,7 +91,7 @@ class XmlReferenceDumper
}
if ($prototype instanceof PrototypedArrayNode) {
$prototype->setName($key);
$prototype->setName($key ?? '');
$children = [$key => $prototype];
} elseif ($prototype instanceof ArrayNode) {
$children = $prototype->getChildren();