Page MenuHomePhorge
Diviner libphutil Tech Docs ArcanistRepositoryURINormalizer

final class ArcanistRepositoryURINormalizer
libphutil Technical Documentation ()

Normalize repository URIs. For example, these URIs are generally equivalent and all point at the same repository:

ssh://user@host/repo
ssh://user@host/repo/
ssh://user@host:22/repo
user@host:/repo
ssh://user@host/repo.git

This class can be used to normalize URIs like this, in order to detect alternate spellings of the same repository URI. In particular, the getNormalizedPath() method will return:

repo

...for all of these URIs. Generally, usage looks like this:

$norm_a = new ArcanistRepositoryURINormalizer($type, $uri_a);
$norm_b = new ArcanistRepositoryURINormalizer($type, $uri_b);

if ($norm_a->getNormalizedPath() === $norm_b->getNormalizedPath()) {
  // URIs appear to point at the same repository.
} else {
  // URIs are very unlikely to be the same repository.
}

Because a repository can be hosted at arbitrarily many arbitrary URIs, there is no way to completely prevent false negatives by only examining URIs (that is, repositories with totally different URIs could really be the same). However, normalization is relatively aggressive and false negatives should be rare: if normalization says two URIs are different repositories, they probably are.

Tasks

Normalizing URIs

Other Methods

Methods

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

public function __construct($type, $uri)

This method is not documented.
Parameters
$type
$uri
Return
this//Implicit.//

public static function getAllURITypes()

This method is not documented.
Return
wild

public function setDomainMap($domain_map)

This method is not documented.
Parameters
array$domain_map
Return
wild

public function getPath()

This method is not documented.
Return
wild

public function getNormalizedURI()

This method is not documented.
Return
wild

public function getNormalizedPath()

This method is not documented.
Return
wild

public function getNormalizedDomain()

This method is not documented.
Return
wild