diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index fcd35b16a..517e44e51 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -15,6 +15,7 @@ namespace Composer\Package\Loader; use Composer\Package\Version\VersionParser; use Composer\Repository\RepositoryManager; use Composer\Util\ProcessExecutor; +use Composer\Package\AliasPackage; /** * ArrayLoader built for the sole purpose of loading the root package @@ -48,13 +49,6 @@ class RootPackageLoader extends ArrayLoader foreach ($this->process->splitLines($output) as $branch) { if ($branch && preg_match('{^(?:\* ) *(?:[^/ ]+?/)?(\S+) *[a-f0-9]+ .*$}', $branch, $match)) { $version = 'dev-'.$match[1]; - if (isset($config['extra']['branch-alias'][$version]) - && substr($config['extra']['branch-alias'][$version], -4) === '-dev' - ) { - $targetBranch = $config['extra']['branch-alias'][$version]; - $normalized = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4)); - $version = preg_replace('{(\.9{7})+}', '.x', $normalized); - } } } } @@ -97,6 +91,16 @@ class RootPackageLoader extends ArrayLoader $package->setRepositories($config['repositories']); } + if (isset($config['extra']['branch-alias'][$version]) + && substr($config['extra']['branch-alias'][$version], -4) === '-dev' + ) { + $targetBranch = $config['extra']['branch-alias'][$version]; + $normalized = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4)); + $version = preg_replace('{(\.9{7})+}', '.x', $normalized); + + return new AliasPackage($package, $normalized, $version); + } + return $package; } }