You are here

protected function ExtraPackage::mergeOrDefer in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php \Wikimedia\Composer\Merge\ExtraPackage::mergeOrDefer()

Merge two collections of package links and collect duplicates for subsequent processing.

Parameters

string $type 'require' or 'require-dev':

array $origin Primary collection:

array $merge Additional collection:

PluginState $state:

Return value

array Merged collection

1 call to ExtraPackage::mergeOrDefer()
ExtraPackage::mergeRequires in vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php
Merge require or require-dev into a RootPackageInterface

File

vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php, line 250

Class

ExtraPackage
Processing for a composer.json file that will be merged into a RootPackageInterface

Namespace

Wikimedia\Composer\Merge

Code

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;
}