本文整理匯總了PHP中Composer\Package\Loader\ArrayLoader::getBranchAlias方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayLoader::getBranchAlias方法的具體用法?PHP ArrayLoader::getBranchAlias怎麽用?PHP ArrayLoader::getBranchAlias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Package\Loader\ArrayLoader
的用法示例。
在下文中一共展示了ArrayLoader::getBranchAlias方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: findRecommendedRequireVersion
/**
* Given a concrete version, this returns a ~ constraint (when possible)
* that should be used, for example, in composer.json.
*
* For example:
* * 1.2.1 -> ~1.2
* * 1.2 -> ~1.2
* * v3.2.1 -> ~3.2
* * 2.0-beta.1 -> ~2.0@beta
* * dev-master -> ~2.1@dev (dev version with alias)
* * dev-master -> dev-master (dev versions are untouched)
*
* @param PackageInterface $package
* @return string
*/
public function findRecommendedRequireVersion(PackageInterface $package)
{
$version = $package->getVersion();
if (!$package->isDev()) {
return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
}
$loader = new ArrayLoader($this->getParser());
$dumper = new ArrayDumper();
$extra = $loader->getBranchAlias($dumper->dump($package));
if ($extra) {
$extra = preg_replace('{^(\\d+\\.\\d+\\.\\d+)(\\.9999999)-dev$}', '$1.0', $extra, -1, $count);
if ($count) {
$extra = str_replace('.9999999', '.0', $extra);
return $this->transformVersion($extra, $extra, 'dev');
}
}
return $package->getPrettyVersion();
}