Skip to content

Commit c89677d

Browse files
mjauvinreedy
authored andcommitted
add merge-replace config to control merging of composer replace section
1 parent 176a396 commit c89677d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/ExtraPackage.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ public function mergeInto(RootPackageInterface $root, PluginState $state)
171171
$this->mergeRequires('require', $root, $state);
172172

173173
$this->mergePackageLinks('conflict', $root);
174-
$this->mergePackageLinks('replace', $root);
174+
175+
if ($state->shouldMergeReplace()) {
176+
$this->mergePackageLinks('replace', $root);
177+
}
178+
175179
$this->mergePackageLinks('provide', $root);
176180

177181
$this->mergeSuggests($root);

src/PluginState.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ class PluginState
9898
*/
9999
protected $mergeExtraDeep = false;
100100

101+
/**
102+
* Whether to merge the replace section.
103+
*
104+
* @var bool $mergeReplace
105+
*/
106+
protected $mergeReplace = true;
107+
101108
/**
102109
* Whether to merge the scripts section.
103110
*
@@ -160,6 +167,7 @@ public function loadSettings()
160167
'merge-dev' => true,
161168
'merge-extra' => false,
162169
'merge-extra-deep' => false,
170+
'merge-replace' => true,
163171
'merge-scripts' => false,
164172
],
165173
$extra['merge-plugin'] ?? []
@@ -175,6 +183,7 @@ public function loadSettings()
175183
$this->mergeDev = (bool)$config['merge-dev'];
176184
$this->mergeExtra = (bool)$config['merge-extra'];
177185
$this->mergeExtraDeep = (bool)$config['merge-extra-deep'];
186+
$this->mergeReplace = (bool)$config['merge-replace'];
178187
$this->mergeScripts = (bool)$config['merge-scripts'];
179188
}
180189

@@ -386,6 +395,18 @@ public function shouldMergeExtraDeep()
386395
return $this->mergeExtraDeep;
387396
}
388397

398+
/**
399+
* Should the replace section be merged?
400+
*
401+
* By default, the replace section is merged.
402+
*
403+
* @return bool
404+
*/
405+
public function shouldMergeReplace()
406+
{
407+
return $this->mergeReplace;
408+
}
409+
389410
/**
390411
* Should the scripts section be merged?
391412
*

0 commit comments

Comments
 (0)