1
0
Fork 0

Fix one more case of unsetting a key in an object

pull/11963/head
Jordi Boggiano 2024-04-29 11:19:52 +02:00
parent 877f1b150f
commit 80631d2fc8
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 8 additions and 0 deletions

View File

@ -430,6 +430,9 @@ class JsonManipulator
if ($subName !== null) {
$curVal = json_decode($matches['content'], true);
unset($curVal[$name][$subName]);
if ($curVal[$name] === []) {
$curVal[$name] = new \ArrayObject();
}
$childrenClean = $this->format($curVal, 0, true);
}

View File

@ -82,6 +82,11 @@ class ConfigCommandTest extends TestCase
['setting-key' => 'preferred-install.foo/*', '--unset' => true],
['config' => ['preferred-install' => []]],
];
yield 'unset platform' => [
['config' => ['platform' => ['php' => '7.2.5'], 'platform-check' => false]],
['setting-key' => 'platform.php', '--unset' => true],
['config' => ['platform' => [], 'platform-check' => false]],
];
yield 'set extra with merge' => [
[],
['setting-key' => 'extra.patches.foo/bar', 'setting-value' => ['{"123":"value"}'], '--json' => true, '--merge' => true],