Fix one more case of unsetting a key in an object
parent
877f1b150f
commit
80631d2fc8
|
@ -430,6 +430,9 @@ class JsonManipulator
|
||||||
if ($subName !== null) {
|
if ($subName !== null) {
|
||||||
$curVal = json_decode($matches['content'], true);
|
$curVal = json_decode($matches['content'], true);
|
||||||
unset($curVal[$name][$subName]);
|
unset($curVal[$name][$subName]);
|
||||||
|
if ($curVal[$name] === []) {
|
||||||
|
$curVal[$name] = new \ArrayObject();
|
||||||
|
}
|
||||||
$childrenClean = $this->format($curVal, 0, true);
|
$childrenClean = $this->format($curVal, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,11 @@ class ConfigCommandTest extends TestCase
|
||||||
['setting-key' => 'preferred-install.foo/*', '--unset' => true],
|
['setting-key' => 'preferred-install.foo/*', '--unset' => true],
|
||||||
['config' => ['preferred-install' => []]],
|
['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' => [
|
yield 'set extra with merge' => [
|
||||||
[],
|
[],
|
||||||
['setting-key' => 'extra.patches.foo/bar', 'setting-value' => ['{"123":"value"}'], '--json' => true, '--merge' => true],
|
['setting-key' => 'extra.patches.foo/bar', 'setting-value' => ['{"123":"value"}'], '--json' => true, '--merge' => true],
|
||||||
|
|
Loading…
Reference in New Issue