本文整理汇总了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();
}