function Package::getUrls
@phpstan-param list<array{url: non-empty-string, preferred: bool}>|null $mirrors
Parameters
mixed[]|null $mirrors:
Return value
list<non-empty-string>
2 calls to Package::getUrls()
- Package::getDistUrls in vendor/
composer/ composer/ src/ Composer/ Package/ Package.php - @inheritDoc
- Package::getSourceUrls in vendor/
composer/ composer/ src/ Composer/ Package/ Package.php - @inheritDoc
File
-
vendor/
composer/ composer/ src/ Composer/ Package/ Package.php, line 685
Class
- Package
- Core package definitions that are needed to resolve dependencies and install packages
Namespace
Composer\PackageCode
protected function getUrls(?string $url, ?array $mirrors, ?string $ref, ?string $type, string $urlType) : array {
if (!$url) {
return [];
}
if ($urlType === 'dist' && false !== strpos($url, '%')) {
$url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion);
}
$urls = [
$url,
];
if ($mirrors) {
foreach ($mirrors as $mirror) {
if ($urlType === 'dist') {
$mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion);
}
elseif ($urlType === 'source' && $type === 'git') {
$mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
}
elseif ($urlType === 'source' && $type === 'hg') {
$mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
}
else {
continue;
}
if (!\in_array($mirrorUrl, $urls)) {
$func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
$func($urls, $mirrorUrl);
}
}
}
return $urls;
}