/**
* Merge two collections of package links and collect duplicates for
* subsequent processing.
*
* @param string $type 'require' or 'require-dev'
* @param array $origin Primary collection
* @param array $merge Additional collection
* @param PluginState $state
* @return array Merged collection
*/
protected function mergeOrDefer($type, array $origin, array $merge, $state)
{
$dups = array();
foreach ($merge as $name => $link) {
if (!isset($origin[$name]) || $state->replaceDuplicateLinks()) {
$this->logger->info("Merging <comment>{$name}</comment>");
$origin[$name] = $link;
} else {
// Defer to solver.
$this->logger->info("Deferring duplicate <comment>{$name}</comment>");
$dups[] = $link;
}
}
$state->addDuplicateLinks($type, $dups);
return $origin;
}