本文整理汇总了PHP中Composer\Package\Version\VersionParser::normalizeBranch方法的典型用法代码示例。如果您正苦于以下问题:PHP VersionParser::normalizeBranch方法的具体用法?PHP VersionParser::normalizeBranch怎么用?PHP VersionParser::normalizeBranch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Package\Version\VersionParser
的用法示例。
在下文中一共展示了VersionParser::normalizeBranch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateBranch
/**
* Validates the branch.
*
* @param string $branch
* @param VersionParser|null $parser
*
* @return false|string
*/
public static function validateBranch($branch, VersionParser $parser = null)
{
if (null === $parser) {
$parser = new VersionParser();
}
$normalize = $parser->normalizeBranch($branch);
if (false !== strpos($normalize, '.9999999-dev')) {
return false;
}
return $normalize;
}
示例2: guessSvnVersion
private function guessSvnVersion(array $packageConfig, $path)
{
SvnUtil::cleanEnv();
// try to fetch current version from svn
if (0 === $this->process->execute('svn info --xml', $output, $path)) {
$trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
$branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
$tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
$urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
if (preg_match($urlPattern, $output, $matches)) {
if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
// we are in a branches path
$version = $this->versionParser->normalizeBranch($matches[3]);
if ('9999999-dev' === $version) {
$version = 'dev-' . $matches[3];
}
return $version;
}
return $this->versionParser->normalize(trim($matches[1]));
}
}
}
示例3: testNormalizeBranch
/**
* @dataProvider successfulNormalizedBranches
*/
public function testNormalizeBranch($input, $expected)
{
$parser = new VersionParser();
$this->assertSame((string) $expected, (string) $parser->normalizeBranch($input));
}
示例4: getVersionAlias
/**
* @return string
*/
public function getVersionAlias()
{
$extra = $this->getExtra();
if (isset($extra['branch-alias'][$this->getVersion()])) {
$parser = new VersionParser();
$version = $parser->normalizeBranch(str_replace('-dev', '', $extra['branch-alias'][$this->getVersion()]));
return preg_replace('{(\\.9{7})+}', '.x', $version);
}
return '';
}