function JsonConfigSource::addProperty
@inheritDoc
Overrides ConfigSourceInterface::addProperty
File
-
vendor/
composer/ composer/ src/ Composer/ Config/ JsonConfigSource.php, line 139
Class
- JsonConfigSource
- JSON Configuration Source
Namespace
Composer\ConfigCode
public function addProperty(string $name, $value) : void {
$this->manipulateJson('addProperty', static function (&$config, $key, $val) : void {
if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
$bits = explode('.', $key);
$last = array_pop($bits);
$arr =& $config[reset($bits)];
foreach ($bits as $bit) {
if (!isset($arr[$bit])) {
$arr[$bit] = [];
}
$arr =& $arr[$bit];
}
$arr[$last] = $val;
}
else {
$config[$key] = $val;
}
}, $name, $value);
}