You are here

protected function ExtraPackage::replaceSelfVersionDependencies 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::replaceSelfVersionDependencies()

Update Links with a 'self.version' constraint with the root package's version.

Parameters

string $type Link type:

array $links:

RootPackageInterface $root:

Return value

array

2 calls to ExtraPackage::replaceSelfVersionDependencies()
ExtraPackage::mergePackageLinks in vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php
Merge package links of the given type into a RootPackageInterface
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 430

Class

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

Namespace

Wikimedia\Composer\Merge

Code

protected function replaceSelfVersionDependencies($type, array $links, RootPackageInterface $root) {
  $linkType = BasePackage::$supportedLinkTypes[$type];
  $version = $root
    ->getVersion();
  $prettyVersion = $root
    ->getPrettyVersion();
  $vp = new VersionParser();
  return array_map(function ($link) use ($linkType, $version, $prettyVersion, $vp) {
    if ('self.version' === $link
      ->getPrettyConstraint()) {
      return new Link($link
        ->getSource(), $link
        ->getTarget(), $vp
        ->parseConstraints($version), $linkType['description'], $prettyVersion);
    }
    return $link;
  }, $links);
}