composer#11852 fix: ability to remove autoload* keys (#11967)
parent
2fe3244ddb
commit
4d7476ca30
|
@ -162,7 +162,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
public function removeProperty(string $name): void
|
||||
{
|
||||
$this->manipulateJson('removeProperty', static function (&$config, $key): void {
|
||||
if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
|
||||
if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0 || stripos($key, 'autoload.') === 0 || stripos($key, 'autoload-dev.') === 0) {
|
||||
$bits = explode('.', $key);
|
||||
$last = array_pop($bits);
|
||||
$arr = &$config[reset($bits)];
|
||||
|
|
|
@ -214,6 +214,14 @@ class JsonManipulator
|
|||
return $this->removeSubNode('scripts', substr($name, 8));
|
||||
}
|
||||
|
||||
if (strpos($name, 'autoload.') === 0) {
|
||||
return $this->removeSubNode('autoload', substr($name, 9));
|
||||
}
|
||||
|
||||
if (strpos($name, 'autoload-dev.') === 0) {
|
||||
return $this->removeSubNode('autoload-dev', substr($name, 13));
|
||||
}
|
||||
|
||||
return $this->removeMainKey($name);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,16 @@ class ConfigCommandTest extends TestCase
|
|||
['setting-key' => 'extra.patches.foo/bar', 'setting-value' => ['{"123":"value"}'], '--json' => true, '--merge' => true],
|
||||
['extra' => ['patches' => ['foo/bar' => [123 => 'value']]]],
|
||||
];
|
||||
yield 'unset autoload' => [
|
||||
['autoload' => ['psr-4' => ['test'], 'classmap' => ['test']]],
|
||||
['setting-key' => 'autoload.psr-4', '--unset' => true],
|
||||
['autoload' => ['classmap' => ['test']]],
|
||||
];
|
||||
yield 'unset autoload-dev' => [
|
||||
['autoload-dev' => ['psr-4' => ['test'], 'classmap' => ['test']]],
|
||||
['setting-key' => 'autoload-dev.psr-4', '--unset' => true],
|
||||
['autoload-dev' => ['classmap' => ['test']]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue