Add more types
parent
e52071a92c
commit
7abc8da7d3
|
@ -52,7 +52,7 @@ class DiagnoseCommand extends BaseCommand
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->setName('diagnose')
|
||||
|
|
|
@ -456,11 +456,10 @@ EOT
|
|||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param string $author
|
||||
* @return array{name: string, email: string|null}
|
||||
*/
|
||||
public function parseAuthorString(string $author)
|
||||
private function parseAuthorString(string $author)
|
||||
{
|
||||
if (Preg::isMatch('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+)(?:\s+<(?P<email>.+?)>)?$/u', $author, $match)) {
|
||||
$hasEmail = isset($match['email']) && '' !== $match['email'];
|
||||
|
@ -485,7 +484,7 @@ EOT
|
|||
*
|
||||
* @return array<int, array{name: string, email?: string}>
|
||||
*/
|
||||
protected function formatAuthors(string $author)
|
||||
protected function formatAuthors(string $author): array
|
||||
{
|
||||
$author = $this->parseAuthorString($author);
|
||||
if (null === $author['email']) {
|
||||
|
@ -504,7 +503,7 @@ EOT
|
|||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function namespaceFromPackageName(string $packageName)
|
||||
public function namespaceFromPackageName(string $packageName): ?string
|
||||
{
|
||||
if (!$packageName || strpos($packageName, '/') === false) {
|
||||
return null;
|
||||
|
@ -526,7 +525,7 @@ EOT
|
|||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function getGitConfig()
|
||||
protected function getGitConfig(): array
|
||||
{
|
||||
if (null !== $this->gitConfig) {
|
||||
return $this->gitConfig;
|
||||
|
@ -567,7 +566,7 @@ EOT
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasVendorIgnore(string $ignoreFile, string $vendor = 'vendor')
|
||||
protected function hasVendorIgnore(string $ignoreFile, string $vendor = 'vendor'): bool
|
||||
{
|
||||
if (!file_exists($ignoreFile)) {
|
||||
return false;
|
||||
|
@ -591,7 +590,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addVendorIgnore(string $ignoreFile, string $vendor = '/vendor/')
|
||||
protected function addVendorIgnore(string $ignoreFile, string $vendor = '/vendor/'): void
|
||||
{
|
||||
$contents = "";
|
||||
if (file_exists($ignoreFile)) {
|
||||
|
@ -610,7 +609,7 @@ EOT
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isValidEmail(string $email)
|
||||
protected function isValidEmail(string $email): bool
|
||||
{
|
||||
// assume it's valid if we can't validate it
|
||||
if (!function_exists('filter_var')) {
|
||||
|
|
|
@ -335,15 +335,6 @@ EOT
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @return void
|
||||
*/
|
||||
public function markSolverComplete()
|
||||
{
|
||||
$this->dependencyResolutionCompleted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $requirements
|
||||
* @param string $requireKey
|
||||
|
@ -358,7 +349,9 @@ EOT
|
|||
$composer = $this->requireComposer();
|
||||
|
||||
$this->dependencyResolutionCompleted = false;
|
||||
$composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, array($this, 'markSolverComplete'), 10000);
|
||||
$composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, function (): void {
|
||||
$this->dependencyResolutionCompleted = true;
|
||||
}, 10000);
|
||||
|
||||
if ($input->getOption('dry-run')) {
|
||||
$rootPackage = $composer->getPackage();
|
||||
|
@ -480,7 +473,7 @@ EOT
|
|||
* @param bool $hardExit
|
||||
* @return void
|
||||
*/
|
||||
public function revertComposerFile(bool $hardExit = true)
|
||||
public function revertComposerFile(bool $hardExit = true): void
|
||||
{
|
||||
$io = $this->getIO();
|
||||
|
||||
|
|
|
@ -602,7 +602,7 @@ EOT
|
|||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getRootRequires()
|
||||
protected function getRootRequires(): array
|
||||
{
|
||||
$rootPackage = $this->requireComposer()->getPackage();
|
||||
|
||||
|
@ -677,7 +677,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
|
||||
protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null): void
|
||||
{
|
||||
$io = $this->getIO();
|
||||
|
||||
|
@ -705,7 +705,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
|
||||
protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null): void
|
||||
{
|
||||
$io = $this->getIO();
|
||||
$io->write('<info>name</info> : ' . $package->getPrettyName());
|
||||
|
@ -773,7 +773,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
|
||||
protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo): void
|
||||
{
|
||||
$versions = array_keys($versions);
|
||||
$versions = Semver::rsort($versions);
|
||||
|
@ -802,7 +802,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function printLinks(CompletePackageInterface $package, string $linkType, string $title = null)
|
||||
protected function printLinks(CompletePackageInterface $package, string $linkType, string $title = null): void
|
||||
{
|
||||
$title = $title ?: $linkType;
|
||||
$io = $this->getIO();
|
||||
|
@ -820,7 +820,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function printLicenses(CompletePackageInterface $package)
|
||||
protected function printLicenses(CompletePackageInterface $package): void
|
||||
{
|
||||
$spdxLicenses = new SpdxLicenses();
|
||||
|
||||
|
@ -852,7 +852,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
|
||||
protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null): void
|
||||
{
|
||||
$json = array(
|
||||
'name' => $package->getPrettyName(),
|
||||
|
@ -1030,7 +1030,7 @@ EOT
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initStyles(OutputInterface $output)
|
||||
protected function initStyles(OutputInterface $output): void
|
||||
{
|
||||
$this->colors = array(
|
||||
'green',
|
||||
|
@ -1052,7 +1052,7 @@ EOT
|
|||
* @param array<int, array<string, string|mixed[]>> $arrayTree
|
||||
* @return void
|
||||
*/
|
||||
protected function displayPackageTree(array $arrayTree)
|
||||
protected function displayPackageTree(array $arrayTree): void
|
||||
{
|
||||
$io = $this->getIO();
|
||||
foreach ($arrayTree as $package) {
|
||||
|
@ -1101,7 +1101,7 @@ EOT
|
|||
PackageInterface $package,
|
||||
InstalledRepository $installedRepo,
|
||||
RepositoryInterface $remoteRepos
|
||||
) {
|
||||
): array {
|
||||
$requires = $package->getRequires();
|
||||
ksort($requires);
|
||||
$children = array();
|
||||
|
@ -1149,7 +1149,7 @@ EOT
|
|||
array $packagesInTree,
|
||||
string $previousTreeBar = '├',
|
||||
int $level = 1
|
||||
) {
|
||||
): void {
|
||||
$previousTreeBar = str_replace('├', '│', $previousTreeBar);
|
||||
if (is_array($package) && isset($package['requires'])) {
|
||||
$requires = $package['requires'];
|
||||
|
@ -1202,7 +1202,7 @@ EOT
|
|||
InstalledRepository $installedRepo,
|
||||
RepositoryInterface $remoteRepos,
|
||||
array $packagesInTree
|
||||
) {
|
||||
): array {
|
||||
$children = array();
|
||||
list($package) = $this->getPackage(
|
||||
$installedRepo,
|
||||
|
|
|
@ -29,7 +29,7 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addRepository(string $name, $config, bool $append = true);
|
||||
public function addRepository(string $name, $config, bool $append = true): void;
|
||||
|
||||
/**
|
||||
* Remove a repository
|
||||
|
@ -38,7 +38,7 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeRepository(string $name);
|
||||
public function removeRepository(string $name): void;
|
||||
|
||||
/**
|
||||
* Add a config setting
|
||||
|
@ -48,7 +48,7 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addConfigSetting(string $name, $value);
|
||||
public function addConfigSetting(string $name, $value): void;
|
||||
|
||||
/**
|
||||
* Remove a config setting
|
||||
|
@ -57,7 +57,7 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeConfigSetting(string $name);
|
||||
public function removeConfigSetting(string $name): void;
|
||||
|
||||
/**
|
||||
* Add a property
|
||||
|
@ -67,7 +67,7 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addProperty(string $name, $value);
|
||||
public function addProperty(string $name, $value): void;
|
||||
|
||||
/**
|
||||
* Remove a property
|
||||
|
@ -76,7 +76,7 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeProperty(string $name);
|
||||
public function removeProperty(string $name): void;
|
||||
|
||||
/**
|
||||
* Add a package link
|
||||
|
@ -87,7 +87,7 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addLink(string $type, string $name, string $value);
|
||||
public function addLink(string $type, string $name, string $value): void;
|
||||
|
||||
/**
|
||||
* Remove a package link
|
||||
|
@ -97,12 +97,12 @@ interface ConfigSourceInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeLink(string $type, string $name);
|
||||
public function removeLink(string $type, string $name): void;
|
||||
|
||||
/**
|
||||
* Gives a user-friendly name to this source (file path or so)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
public function getName(): string;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->file->getPath();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addRepository($name, $config, $append = true)
|
||||
public function addRepository(string $name, $config, bool $append = true): void
|
||||
{
|
||||
$this->manipulateJson('addRepository', function (&$config, $repo, $repoConfig) use ($append): void {
|
||||
// if converting from an array format to hashmap format, and there is a {"packagist.org":false} repo, we have
|
||||
|
@ -89,7 +89,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeRepository($name)
|
||||
public function removeRepository(string $name): void
|
||||
{
|
||||
$this->manipulateJson('removeRepository', function (&$config, $repo): void {
|
||||
unset($config['repositories'][$repo]);
|
||||
|
@ -99,7 +99,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addConfigSetting($name, $value)
|
||||
public function addConfigSetting(string $name, $value): void
|
||||
{
|
||||
$authConfig = $this->authConfig;
|
||||
$this->manipulateJson('addConfigSetting', function (&$config, $key, $val) use ($authConfig): void {
|
||||
|
@ -119,7 +119,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeConfigSetting($name)
|
||||
public function removeConfigSetting(string $name): void
|
||||
{
|
||||
$authConfig = $this->authConfig;
|
||||
$this->manipulateJson('removeConfigSetting', function (&$config, $key) use ($authConfig): void {
|
||||
|
@ -139,7 +139,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addProperty($name, $value)
|
||||
public function addProperty(string $name, $value): void
|
||||
{
|
||||
$this->manipulateJson('addProperty', function (&$config, $key, $val): void {
|
||||
if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
|
||||
|
@ -162,7 +162,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeProperty($name)
|
||||
public function removeProperty(string $name): void
|
||||
{
|
||||
$this->manipulateJson('removeProperty', function (&$config, $key): void {
|
||||
if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
|
||||
|
@ -185,7 +185,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function addLink($type, $name, $value)
|
||||
public function addLink(string $type, string $name, string $value): void
|
||||
{
|
||||
$this->manipulateJson('addLink', function (&$config, $type, $name, $value): void {
|
||||
$config[$type][$name] = $value;
|
||||
|
@ -195,7 +195,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeLink($type, $name)
|
||||
public function removeLink(string $type, string $name): void
|
||||
{
|
||||
$this->manipulateJson('removeSubNode', function (&$config, $type, $name): void {
|
||||
unset($config[$type][$name]);
|
||||
|
|
|
@ -423,9 +423,9 @@ class Application extends BaseApplication
|
|||
* @param bool|null $disableScripts
|
||||
* @throws JsonValidationException
|
||||
* @throws \InvalidArgumentException
|
||||
* @return ?\Composer\Composer If $required is true then the return value is guaranteed
|
||||
* @return ?Composer If $required is true then the return value is guaranteed
|
||||
*/
|
||||
public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null)
|
||||
public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null): ?Composer
|
||||
{
|
||||
if (null === $disablePlugins) {
|
||||
$disablePlugins = $this->disablePluginsByDefault;
|
||||
|
@ -460,7 +460,7 @@ class Application extends BaseApplication
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetComposer()
|
||||
public function resetComposer(): void
|
||||
{
|
||||
$this->composer = null;
|
||||
if (method_exists($this->getIO(), 'resetAuthentications')) {
|
||||
|
@ -471,7 +471,7 @@ class Application extends BaseApplication
|
|||
/**
|
||||
* @return IOInterface
|
||||
*/
|
||||
public function getIO()
|
||||
public function getIO(): IOInterface
|
||||
{
|
||||
return $this->io;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class InstallOperation extends SolverOperation implements OperationInterface
|
|||
*
|
||||
* @return PackageInterface
|
||||
*/
|
||||
public function getPackage()
|
||||
public function getPackage(): PackageInterface
|
||||
{
|
||||
return $this->package;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class InstallOperation extends SolverOperation implements OperationInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function show($lock)
|
||||
public function show($lock): string
|
||||
{
|
||||
return self::format($this->package, $lock);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class InstallOperation extends SolverOperation implements OperationInterface
|
|||
* @param bool $lock
|
||||
* @return string
|
||||
*/
|
||||
public static function format(PackageInterface $package, bool $lock = false)
|
||||
public static function format(PackageInterface $package, bool $lock = false): string
|
||||
{
|
||||
return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class SolverOperation implements OperationInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOperationType()
|
||||
public function getOperationType(): string
|
||||
{
|
||||
return static::TYPE;
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
protected $cleanupExecuted = array();
|
||||
|
||||
/**
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
unset($this->cleanupExecuted[$package->getName()]);
|
||||
|
||||
|
@ -43,9 +43,9 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
}
|
||||
|
||||
/**
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
$this->cleanupExecuted[$package->getName()] = true;
|
||||
|
||||
|
@ -62,7 +62,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
* @throws \RuntimeException
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function install(PackageInterface $package, string $path, bool $output = true)
|
||||
public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
|
||||
{
|
||||
if ($output) {
|
||||
$this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
|
||||
|
@ -113,10 +113,6 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
throw $e;
|
||||
}
|
||||
|
||||
if (!$promise instanceof PromiseInterface) {
|
||||
$promise = \React\Promise\resolve();
|
||||
}
|
||||
|
||||
return $promise->then(function () use ($package, $filesystem, $fileName, $temporaryDir, $path): \React\Promise\PromiseInterface {
|
||||
$filesystem->unlink($fileName);
|
||||
|
||||
|
@ -215,7 +211,7 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getInstallOperationAppendix(PackageInterface $package, string $path)
|
||||
protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
|
||||
{
|
||||
return ': Extracting archive';
|
||||
}
|
||||
|
@ -227,7 +223,6 @@ abstract class ArchiveDownloader extends FileDownloader
|
|||
* @param string $path Directory
|
||||
*
|
||||
* @throws \UnexpectedValueException If can not extract downloaded file to path
|
||||
* @return PromiseInterface|null
|
||||
*/
|
||||
abstract protected function extract(PackageInterface $package, string $file, string $path);
|
||||
abstract protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface;
|
||||
}
|
||||
|
|
|
@ -28,5 +28,5 @@ interface ChangeReportInterface
|
|||
* @param string $path package directory
|
||||
* @return string|null changes or null
|
||||
*/
|
||||
public function getLocalChanges(PackageInterface $package, string $path);
|
||||
public function getLocalChanges(PackageInterface $package, string $path): ?string;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class DownloadManager
|
|||
* @param bool $preferSource prefer downloading from source
|
||||
* @return DownloadManager
|
||||
*/
|
||||
public function setPreferSource(bool $preferSource): DownloadManager
|
||||
public function setPreferSource(bool $preferSource): self
|
||||
{
|
||||
$this->preferSource = $preferSource;
|
||||
|
||||
|
@ -72,7 +72,7 @@ class DownloadManager
|
|||
* @param bool $preferDist prefer downloading from dist
|
||||
* @return DownloadManager
|
||||
*/
|
||||
public function setPreferDist(bool $preferDist): DownloadManager
|
||||
public function setPreferDist(bool $preferDist): self
|
||||
{
|
||||
$this->preferDist = $preferDist;
|
||||
|
||||
|
@ -86,7 +86,7 @@ class DownloadManager
|
|||
*
|
||||
* @return DownloadManager
|
||||
*/
|
||||
public function setPreferences(array $preferences): DownloadManager
|
||||
public function setPreferences(array $preferences): self
|
||||
{
|
||||
$this->packagePreferences = $preferences;
|
||||
|
||||
|
@ -100,7 +100,7 @@ class DownloadManager
|
|||
* @param DownloaderInterface $downloader downloader instance
|
||||
* @return DownloadManager
|
||||
*/
|
||||
public function setDownloader(string $type, DownloaderInterface $downloader): DownloadManager
|
||||
public function setDownloader(string $type, DownloaderInterface $downloader): self
|
||||
{
|
||||
$type = strtolower($type);
|
||||
$this->downloaders[$type] = $downloader;
|
||||
|
@ -229,9 +229,6 @@ class DownloadManager
|
|||
} catch (\Exception $e) {
|
||||
return $handleError($e);
|
||||
}
|
||||
if (!$result instanceof PromiseInterface) {
|
||||
return \React\Promise\resolve($result);
|
||||
}
|
||||
|
||||
$res = $result->then(function ($res) {
|
||||
return $res;
|
||||
|
@ -251,9 +248,9 @@ class DownloadManager
|
|||
* @param string $targetDir target dir
|
||||
* @param PackageInterface|null $prevPackage previous package instance in case of updates
|
||||
*
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function prepare(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||
public function prepare(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||
$downloader = $this->getDownloaderForPackage($package);
|
||||
|
@ -272,9 +269,9 @@ class DownloadManager
|
|||
*
|
||||
* @throws \InvalidArgumentException if package have no urls to download from
|
||||
* @throws \RuntimeException
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function install(PackageInterface $package, string $targetDir): ?PromiseInterface
|
||||
public function install(PackageInterface $package, string $targetDir): PromiseInterface
|
||||
{
|
||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||
$downloader = $this->getDownloaderForPackage($package);
|
||||
|
@ -293,9 +290,9 @@ class DownloadManager
|
|||
* @param string $targetDir target dir
|
||||
*
|
||||
* @throws \InvalidArgumentException if initial package is not installed
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $targetDir): ?PromiseInterface
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $targetDir): PromiseInterface
|
||||
{
|
||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||
$downloader = $this->getDownloaderForPackage($target);
|
||||
|
@ -330,18 +327,10 @@ class DownloadManager
|
|||
// if downloader type changed, or update failed and user asks for reinstall,
|
||||
// we wipe the dir and do a new install instead of updating it
|
||||
$promise = $initialDownloader->remove($initial, $targetDir);
|
||||
if ($promise instanceof PromiseInterface) {
|
||||
return $promise->then(function ($res) use ($target, $targetDir): PromiseInterface {
|
||||
$promise = $this->install($target, $targetDir);
|
||||
if ($promise instanceof PromiseInterface) {
|
||||
return $promise;
|
||||
}
|
||||
|
||||
return \React\Promise\resolve();
|
||||
});
|
||||
}
|
||||
|
||||
return $this->install($target, $targetDir);
|
||||
return $promise->then(function ($res) use ($target, $targetDir): PromiseInterface {
|
||||
return $this->install($target, $targetDir);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -350,9 +339,9 @@ class DownloadManager
|
|||
* @param PackageInterface $package package instance
|
||||
* @param string $targetDir target dir
|
||||
*
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function remove(PackageInterface $package, string $targetDir): ?PromiseInterface
|
||||
public function remove(PackageInterface $package, string $targetDir): PromiseInterface
|
||||
{
|
||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||
$downloader = $this->getDownloaderForPackage($package);
|
||||
|
@ -371,9 +360,9 @@ class DownloadManager
|
|||
* @param string $targetDir target dir
|
||||
* @param PackageInterface|null $prevPackage previous package instance in case of updates
|
||||
*
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function cleanup(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||
public function cleanup(string $type, PackageInterface $package, string $targetDir, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
$targetDir = $this->normalizeTargetDir($targetDir);
|
||||
$downloader = $this->getDownloaderForPackage($package);
|
||||
|
|
|
@ -28,15 +28,15 @@ interface DownloaderInterface
|
|||
*
|
||||
* @return string "source" or "dist"
|
||||
*/
|
||||
public function getInstallationSource();
|
||||
public function getInstallationSource(): string;
|
||||
|
||||
/**
|
||||
* This should do any network-related tasks to prepare for an upcoming install/update
|
||||
*
|
||||
* @param string $path download path
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null);
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Do anything that needs to be done between all downloads have been completed and the actual operation is executed
|
||||
|
@ -50,18 +50,18 @@ interface DownloaderInterface
|
|||
* @param PackageInterface $package package instance
|
||||
* @param string $path download path
|
||||
* @param PackageInterface $prevPackage previous package instance in case of an update
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null);
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Installs specific package into specific folder.
|
||||
*
|
||||
* @param PackageInterface $package package instance
|
||||
* @param string $path download path
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function install(PackageInterface $package, string $path);
|
||||
public function install(PackageInterface $package, string $path): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Updates specific package in specific folder from initial to target version.
|
||||
|
@ -69,18 +69,18 @@ interface DownloaderInterface
|
|||
* @param PackageInterface $initial initial package
|
||||
* @param PackageInterface $target updated package
|
||||
* @param string $path download path
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $path);
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Removes specific package from specific folder.
|
||||
*
|
||||
* @param PackageInterface $package package instance
|
||||
* @param string $path download path
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function remove(PackageInterface $package, string $path);
|
||||
public function remove(PackageInterface $package, string $path): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Do anything to cleanup changes applied in the prepare or install/update/uninstall steps
|
||||
|
@ -93,7 +93,7 @@ interface DownloaderInterface
|
|||
* @param PackageInterface $package package instance
|
||||
* @param string $path download path
|
||||
* @param PackageInterface $prevPackage previous package instance in case of an update
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null);
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface;
|
||||
}
|
||||
|
|
|
@ -28,5 +28,5 @@ interface DvcsDownloaderInterface
|
|||
* @param string $path package directory
|
||||
* @return string|null changes or null
|
||||
*/
|
||||
public function getUnpushedChanges(PackageInterface $package, string $path);
|
||||
public function getUnpushedChanges(PackageInterface $package, string $path): ?string;
|
||||
}
|
||||
|
|
|
@ -66,11 +66,9 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
public static $downloadMetadata = array();
|
||||
|
||||
/**
|
||||
* @private this is only public for php 5.3 support in closures
|
||||
*
|
||||
* @var array<string, string> Map of package name to cache key
|
||||
*/
|
||||
public $lastCacheWrites = array();
|
||||
private $lastCacheWrites = array();
|
||||
/** @var array<string, string[]> Map of package name to list of paths */
|
||||
private $additionalCleanupPaths = array();
|
||||
|
||||
|
@ -103,7 +101,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getInstallationSource()
|
||||
public function getInstallationSource(): string
|
||||
{
|
||||
return 'dist';
|
||||
}
|
||||
|
@ -113,7 +111,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
*
|
||||
* @param bool $output
|
||||
*/
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true)
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
|
||||
{
|
||||
if (!$package->getDistUrl()) {
|
||||
throw new \InvalidArgumentException('The given package is missing url information');
|
||||
|
@ -296,7 +294,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
return \React\Promise\resolve();
|
||||
}
|
||||
|
@ -304,7 +302,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
$fileName = $this->getFileName($package, $path);
|
||||
if (file_exists($fileName)) {
|
||||
|
@ -337,7 +335,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
*
|
||||
* @param bool $output
|
||||
*/
|
||||
public function install(PackageInterface $package, string $path, bool $output = true)
|
||||
public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
|
||||
{
|
||||
if ($output) {
|
||||
$this->io->writeError(" - " . InstallOperation::format($package));
|
||||
|
@ -363,7 +361,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function clearLastCacheWrite(PackageInterface $package)
|
||||
protected function clearLastCacheWrite(PackageInterface $package): void
|
||||
{
|
||||
if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
|
||||
$this->cache->remove($this->lastCacheWrites[$package->getName()]);
|
||||
|
@ -376,7 +374,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addCleanupPath(PackageInterface $package, string $path)
|
||||
protected function addCleanupPath(PackageInterface $package, string $path): void
|
||||
{
|
||||
$this->additionalCleanupPaths[$package->getName()][] = $path;
|
||||
}
|
||||
|
@ -386,7 +384,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeCleanupPath(PackageInterface $package, string $path)
|
||||
protected function removeCleanupPath(PackageInterface $package, string $path): void
|
||||
{
|
||||
if (isset($this->additionalCleanupPaths[$package->getName()])) {
|
||||
$idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
|
||||
|
@ -399,22 +397,14 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $path)
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
|
||||
{
|
||||
$this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
|
||||
|
||||
$promise = $this->remove($initial, $path, false);
|
||||
if (!$promise instanceof PromiseInterface) {
|
||||
$promise = \React\Promise\resolve();
|
||||
}
|
||||
|
||||
return $promise->then(function () use ($target, $path): PromiseInterface {
|
||||
$promise = $this->install($target, $path, false);
|
||||
if ($promise instanceof PromiseInterface) {
|
||||
return $promise;
|
||||
}
|
||||
|
||||
return \React\Promise\resolve();
|
||||
return $this->install($target, $path, false);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -423,7 +413,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
*
|
||||
* @param bool $output
|
||||
*/
|
||||
public function remove(PackageInterface $package, string $path, bool $output = true)
|
||||
public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
|
||||
{
|
||||
if ($output) {
|
||||
$this->io->writeError(" - " . UninstallOperation::format($package));
|
||||
|
@ -444,7 +434,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
* @param string $path download path
|
||||
* @return string file name
|
||||
*/
|
||||
protected function getFileName(PackageInterface $package, string $path)
|
||||
protected function getFileName(PackageInterface $package, string $path): string
|
||||
{
|
||||
return rtrim($this->config->get('vendor-dir').'/composer/tmp-'.md5($package.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
|
||||
}
|
||||
|
@ -456,7 +446,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
* @param string $path download path
|
||||
* @return string
|
||||
*/
|
||||
protected function getInstallOperationAppendix(PackageInterface $package, string $path)
|
||||
protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
@ -469,7 +459,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
* @throws \RuntimeException If any problem with the url
|
||||
* @return string url
|
||||
*/
|
||||
protected function processUrl(PackageInterface $package, string $url)
|
||||
protected function processUrl(PackageInterface $package, string $url): string
|
||||
{
|
||||
if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
|
||||
throw new \RuntimeException('You must enable the openssl extension to download files via https');
|
||||
|
@ -486,7 +476,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
|
|||
* @inheritDoc
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getLocalChanges(PackageInterface $package, string $targetDir)
|
||||
public function getLocalChanges(PackageInterface $package, string $targetDir): ?string
|
||||
{
|
||||
$prevIO = $this->io;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class FossilDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
return \React\Promise\resolve();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class FossilDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url): ?PromiseInterface
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
|
||||
{
|
||||
// Ensure we are allowed to use this URL by config
|
||||
$this->config->prohibitUrlByConfig($url, $this->io);
|
||||
|
@ -61,7 +61,7 @@ class FossilDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): ?PromiseInterface
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
|
||||
{
|
||||
// Ensure we are allowed to use this URL by config
|
||||
$this->config->prohibitUrlByConfig($url, $this->io);
|
||||
|
|
|
@ -58,7 +58,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null)
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
GitUtil::cleanEnv();
|
||||
|
||||
|
@ -83,7 +83,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url)
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
|
||||
{
|
||||
GitUtil::cleanEnv();
|
||||
$path = $this->normalizePath($path);
|
||||
|
@ -148,7 +148,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url)
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
|
||||
{
|
||||
GitUtil::cleanEnv();
|
||||
$path = $this->normalizePath($path);
|
||||
|
@ -213,7 +213,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLocalChanges(PackageInterface $package, string $path)
|
||||
public function getLocalChanges(PackageInterface $package, string $path): ?string
|
||||
{
|
||||
GitUtil::cleanEnv();
|
||||
if (!$this->hasMetadataRepository($path)) {
|
||||
|
@ -231,7 +231,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @return null|string
|
||||
*/
|
||||
public function getUnpushedChanges(PackageInterface $package, string $path)
|
||||
public function getUnpushedChanges(PackageInterface $package, string $path): ?string
|
||||
{
|
||||
GitUtil::cleanEnv();
|
||||
$path = $this->normalizePath($path);
|
||||
|
@ -328,7 +328,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function cleanChanges(PackageInterface $package, string $path, bool $update)
|
||||
protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
|
||||
{
|
||||
GitUtil::cleanEnv();
|
||||
$path = $this->normalizePath($path);
|
||||
|
@ -415,7 +415,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function reapplyChanges(string $path)
|
||||
protected function reapplyChanges(string $path): void
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
if (!empty($this->hasStashedChanges[$path])) {
|
||||
|
@ -438,7 +438,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
* @throws \RuntimeException
|
||||
* @return null|string if a string is returned, it is the commit reference that was checked out if the original could not be found
|
||||
*/
|
||||
protected function updateToCommit(PackageInterface $package, string $path, string $reference, string $prettyVersion)
|
||||
protected function updateToCommit(PackageInterface $package, string $path, string $reference, string $prettyVersion): ?string
|
||||
{
|
||||
$force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
|
||||
|
||||
|
@ -505,7 +505,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function updateOriginUrl(string $path, string $url)
|
||||
protected function updateOriginUrl(string $path, string $url): void
|
||||
{
|
||||
$this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
|
||||
$this->setPushUrl($path, $url);
|
||||
|
@ -517,7 +517,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setPushUrl(string $path, string $url)
|
||||
protected function setPushUrl(string $path, string $url): void
|
||||
{
|
||||
// set push url for github projects
|
||||
if (Preg::isMatch('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
|
||||
|
@ -534,7 +534,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getCommitLogs(string $fromReference, string $toReference, string $path)
|
||||
protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
$command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
|
||||
|
@ -553,7 +553,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function discardChanges(string $path)
|
||||
protected function discardChanges(string $path): PromiseInterface
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
|
||||
|
@ -572,7 +572,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function stashChanges(string $path)
|
||||
protected function stashChanges(string $path): PromiseInterface
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
|
||||
|
@ -591,7 +591,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function viewDiff(string $path)
|
||||
protected function viewDiff(string $path): void
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
|
||||
|
@ -606,7 +606,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function normalizePath(string $path)
|
||||
protected function normalizePath(string $path): string
|
||||
{
|
||||
if (Platform::isWindows() && strlen($path) > 0) {
|
||||
$basePath = $path;
|
||||
|
@ -630,7 +630,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function hasMetadataRepository(string $path)
|
||||
protected function hasMetadataRepository(string $path): bool
|
||||
{
|
||||
$path = $this->normalizePath($path);
|
||||
|
||||
|
@ -641,7 +641,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
|
|||
* @param string $reference
|
||||
* @return string
|
||||
*/
|
||||
protected function getShortHash(string $reference)
|
||||
protected function getShortHash(string $reference): string
|
||||
{
|
||||
if (!$this->io->isVerbose() && Preg::isMatch('{^[0-9a-f]{40}$}', $reference)) {
|
||||
return substr($reference, 0, 10);
|
||||
|
|
|
@ -24,7 +24,7 @@ use Composer\Util\ProcessExecutor;
|
|||
*/
|
||||
class GzipDownloader extends ArchiveDownloader
|
||||
{
|
||||
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||
protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||
{
|
||||
$filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
|
||||
$targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
|
||||
|
|
|
@ -25,7 +25,7 @@ class HgDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
if (null === HgUtils::getVersion($this->process)) {
|
||||
throw new \RuntimeException('hg was not found in your PATH, skipping source download');
|
||||
|
@ -37,7 +37,7 @@ class HgDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url): ?PromiseInterface
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
|
||||
{
|
||||
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
||||
|
||||
|
@ -59,7 +59,7 @@ class HgDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): ?PromiseInterface
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
|
||||
{
|
||||
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): ?PromiseInterface
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
|
||||
{
|
||||
$path = Filesystem::trimTrailingSlash($path);
|
||||
$url = $package->getDistUrl();
|
||||
|
@ -75,7 +75,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function install(PackageInterface $package, string $path, bool $output = true): ?PromiseInterface
|
||||
public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
|
||||
{
|
||||
$path = Filesystem::trimTrailingSlash($path);
|
||||
$url = $package->getDistUrl();
|
||||
|
@ -161,7 +161,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function remove(PackageInterface $package, string $path, bool $output = true): ?PromiseInterface
|
||||
public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
|
||||
{
|
||||
$path = Filesystem::trimTrailingSlash($path);
|
||||
/**
|
||||
|
@ -250,7 +250,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
|
|||
*
|
||||
* @phpstan-return array{self::STRATEGY_*, non-empty-list<self::STRATEGY_*>}
|
||||
*/
|
||||
private function computeAllowedStrategies(array $transportOptions)
|
||||
private function computeAllowedStrategies(array $transportOptions): array
|
||||
{
|
||||
// When symlink transport option is null, both symlink and mirror are allowed
|
||||
$currentStrategy = self::STRATEGY_SYMLINK;
|
||||
|
|
|
@ -28,7 +28,7 @@ class PerforceDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): ?PromiseInterface
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
return \React\Promise\resolve();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class PerforceDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function doInstall(PackageInterface $package, string $path, string $url): ?PromiseInterface
|
||||
public function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
|
||||
{
|
||||
$ref = $package->getSourceReference();
|
||||
$label = $this->getLabelFromSourceReference((string) $ref);
|
||||
|
@ -101,7 +101,7 @@ class PerforceDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): ?PromiseInterface
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
|
||||
{
|
||||
return $this->doInstall($target, $path, $url);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class PharDownloader extends ArchiveDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||
protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||
{
|
||||
// Can throw an UnexpectedValueException
|
||||
$archive = new \Phar($file);
|
||||
|
|
|
@ -28,7 +28,7 @@ use RarArchive;
|
|||
*/
|
||||
class RarDownloader extends ArchiveDownloader
|
||||
{
|
||||
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||
protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||
{
|
||||
$processError = null;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class SvnDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null)
|
||||
protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
SvnUtil::cleanEnv();
|
||||
$util = new SvnUtil($url, $this->io, $this->config, $this->process);
|
||||
|
@ -45,7 +45,7 @@ class SvnDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url)
|
||||
protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
|
||||
{
|
||||
SvnUtil::cleanEnv();
|
||||
$ref = $package->getSourceReference();
|
||||
|
@ -67,7 +67,7 @@ class SvnDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url)
|
||||
protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
|
||||
{
|
||||
SvnUtil::cleanEnv();
|
||||
$ref = $target->getSourceReference();
|
||||
|
@ -91,7 +91,7 @@ class SvnDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLocalChanges(PackageInterface $package, string $path)
|
||||
public function getLocalChanges(PackageInterface $package, string $path): ?string
|
||||
{
|
||||
if (!$this->hasMetadataRepository($path)) {
|
||||
return null;
|
||||
|
@ -114,7 +114,7 @@ class SvnDownloader extends VcsDownloader
|
|||
* @throws \RuntimeException
|
||||
* @return string
|
||||
*/
|
||||
protected function execute(PackageInterface $package, string $baseUrl, string $command, string $url, string $cwd = null, string $path = null)
|
||||
protected function execute(PackageInterface $package, string $baseUrl, string $command, string $url, string $cwd = null, string $path = null): string
|
||||
{
|
||||
$util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
|
||||
$util->setCacheCredentials($this->cacheCredentials);
|
||||
|
@ -130,7 +130,7 @@ class SvnDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function cleanChanges(PackageInterface $package, string $path, bool $update)
|
||||
protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
|
||||
{
|
||||
if (!$changes = $this->getLocalChanges($package, $path)) {
|
||||
return \React\Promise\resolve();
|
||||
|
@ -191,7 +191,7 @@ class SvnDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getCommitLogs(string $fromReference, string $toReference, string $path)
|
||||
protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
|
||||
{
|
||||
if (Preg::isMatch('{@(\d+)$}', $fromReference) && Preg::isMatch('{@(\d+)$}', $toReference)) {
|
||||
// retrieve the svn base url from the checkout folder
|
||||
|
@ -236,7 +236,7 @@ class SvnDownloader extends VcsDownloader
|
|||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
protected function discardChanges(string $path)
|
||||
protected function discardChanges(string $path): PromiseInterface
|
||||
{
|
||||
if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
|
||||
throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
|
||||
|
@ -248,7 +248,7 @@ class SvnDownloader extends VcsDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function hasMetadataRepository(string $path)
|
||||
protected function hasMetadataRepository(string $path): bool
|
||||
{
|
||||
return is_dir($path.'/.svn');
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Downloader;
|
||||
|
||||
use Composer\Package\PackageInterface;
|
||||
use React\Promise\PromiseInterface;
|
||||
|
||||
/**
|
||||
* Downloader for tar files: tar, tar.gz or tar.bz2
|
||||
|
@ -24,7 +25,7 @@ class TarDownloader extends ArchiveDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function extract(PackageInterface $package, string $file, string $path)
|
||||
protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||
{
|
||||
// Can throw an UnexpectedValueException
|
||||
$archive = new \PharData($file);
|
||||
|
|
|
@ -28,5 +28,5 @@ interface VcsCapableDownloaderInterface
|
|||
* @param string $path package directory
|
||||
* @return string|null reference or null
|
||||
*/
|
||||
public function getVcsReference(PackageInterface $package, string $path);
|
||||
public function getVcsReference(PackageInterface $package, string $path): ?string;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getInstallationSource()
|
||||
public function getInstallationSource(): string
|
||||
{
|
||||
return 'source';
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
if (!$package->getSourceReference()) {
|
||||
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
||||
|
@ -93,7 +93,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||
public function prepare(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
if ($type === 'update') {
|
||||
$this->cleanChanges($prevPackage, $path, true);
|
||||
|
@ -110,7 +110,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null)
|
||||
public function cleanup(string $type, PackageInterface $package, string $path, PackageInterface $prevPackage = null): PromiseInterface
|
||||
{
|
||||
if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
|
||||
$this->reapplyChanges($path);
|
||||
|
@ -123,7 +123,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function install(PackageInterface $package, string $path)
|
||||
public function install(PackageInterface $package, string $path): PromiseInterface
|
||||
{
|
||||
if (!$package->getSourceReference()) {
|
||||
throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
|
||||
|
@ -158,7 +158,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $path)
|
||||
public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
|
||||
{
|
||||
if (!$target->getSourceReference()) {
|
||||
throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
|
||||
|
@ -222,7 +222,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function remove(PackageInterface $package, string $path)
|
||||
public function remove(PackageInterface $package, string $path): PromiseInterface
|
||||
{
|
||||
$this->io->writeError(" - " . UninstallOperation::format($package));
|
||||
|
||||
|
@ -238,7 +238,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getVcsReference(PackageInterface $package, string $path)
|
||||
public function getVcsReference(PackageInterface $package, string $path): ?string
|
||||
{
|
||||
$parser = new VersionParser;
|
||||
$guesser = new VersionGuesser($this->config, $this->process, $parser);
|
||||
|
@ -264,7 +264,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
*
|
||||
* @throws \RuntimeException in case the operation must be aborted
|
||||
*/
|
||||
protected function cleanChanges(PackageInterface $package, string $path, bool $update)
|
||||
protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
|
||||
{
|
||||
// the default implementation just fails if there are any changes, override in child classes to provide stash-ability
|
||||
if (null !== $this->getLocalChanges($package, $path)) {
|
||||
|
@ -283,7 +283,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
*
|
||||
* @throws \RuntimeException in case the operation must be aborted or the patch does not apply cleanly
|
||||
*/
|
||||
protected function reapplyChanges(string $path)
|
||||
protected function reapplyChanges(string $path): void
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -295,9 +295,9 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
* @param string $url package url
|
||||
* @param PackageInterface|null $prevPackage previous package (in case of an update)
|
||||
*
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
abstract protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null);
|
||||
abstract protected function doDownload(PackageInterface $package, string $path, string $url, PackageInterface $prevPackage = null): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Downloads specific package into specific folder.
|
||||
|
@ -306,9 +306,9 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
* @param string $path download path
|
||||
* @param string $url package url
|
||||
*
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
abstract protected function doInstall(PackageInterface $package, string $path, string $url);
|
||||
abstract protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Updates specific package in specific folder from initial to target version.
|
||||
|
@ -318,9 +318,9 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
* @param string $path download path
|
||||
* @param string $url package url
|
||||
*
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url);
|
||||
abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Fetches the commit logs between two commits
|
||||
|
@ -330,7 +330,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
* @param string $path the package path
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getCommitLogs(string $fromReference, string $toReference, string $path);
|
||||
abstract protected function getCommitLogs(string $fromReference, string $toReference, string $path): string;
|
||||
|
||||
/**
|
||||
* Checks if VCS metadata repository has been initialized
|
||||
|
@ -339,7 +339,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
|
|||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function hasMetadataRepository(string $path);
|
||||
abstract protected function hasMetadataRepository(string $path): bool;
|
||||
|
||||
/**
|
||||
* @param string[] $urls
|
||||
|
|
|
@ -24,7 +24,7 @@ use Composer\Util\ProcessExecutor;
|
|||
*/
|
||||
class XzDownloader extends ArchiveDownloader
|
||||
{
|
||||
protected function extract(PackageInterface $package, string $file, string $path): ?PromiseInterface
|
||||
protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||
{
|
||||
$command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class ZipDownloader extends ArchiveDownloader
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true)
|
||||
public function download(PackageInterface $package, string $path, PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
|
||||
{
|
||||
if (null === self::$unzipCommands) {
|
||||
self::$unzipCommands = array();
|
||||
|
@ -206,9 +206,9 @@ class ZipDownloader extends ArchiveDownloader
|
|||
*
|
||||
* @param string $file File to extract
|
||||
* @param string $path Path where to extract file
|
||||
* @return PromiseInterface|null
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
protected function extract(PackageInterface $package, string $file, string $path)
|
||||
protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
|
||||
{
|
||||
return $this->extractWithSystemUnzip($package, $file, $path);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class Event
|
|||
*
|
||||
* @return string The event name
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class Event
|
|||
*
|
||||
* @return string[] The event arguments
|
||||
*/
|
||||
public function getArguments()
|
||||
public function getArguments(): array
|
||||
{
|
||||
return $this->args;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class Event
|
|||
*
|
||||
* @return mixed[] The event flags
|
||||
*/
|
||||
public function getFlags()
|
||||
public function getFlags(): array
|
||||
{
|
||||
return $this->flags;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class Event
|
|||
*
|
||||
* @return bool Whether propagation has been stopped
|
||||
*/
|
||||
public function isPropagationStopped()
|
||||
public function isPropagationStopped(): bool
|
||||
{
|
||||
return $this->propagationStopped;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class Event
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function stopPropagation()
|
||||
public function stopPropagation(): void
|
||||
{
|
||||
$this->propagationStopped = true;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ class EventDispatcher
|
|||
* @return int return code of the executed script if any, for php scripts a false return
|
||||
* value is changed to 1, anything else to 0
|
||||
*/
|
||||
public function dispatch(string $eventName, Event $event = null)
|
||||
public function dispatch(string $eventName, Event $event = null): int
|
||||
{
|
||||
if (null === $event) {
|
||||
$event = new Event($eventName);
|
||||
|
@ -115,7 +115,7 @@ class EventDispatcher
|
|||
* @return int return code of the executed script if any, for php scripts a false return
|
||||
* value is changed to 1, anything else to 0
|
||||
*/
|
||||
public function dispatchScript(string $eventName, bool $devMode = false, array $additionalArgs = array(), array $flags = array())
|
||||
public function dispatchScript(string $eventName, bool $devMode = false, array $additionalArgs = array(), array $flags = array()): int
|
||||
{
|
||||
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
||||
|
||||
|
@ -134,7 +134,7 @@ class EventDispatcher
|
|||
* @return int return code of the executed script if any, for php scripts a false return
|
||||
* value is changed to 1, anything else to 0
|
||||
*/
|
||||
public function dispatchPackageEvent(string $eventName, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
|
||||
public function dispatchPackageEvent(string $eventName, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation): int
|
||||
{
|
||||
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
||||
|
||||
|
@ -152,7 +152,7 @@ class EventDispatcher
|
|||
* @return int return code of the executed script if any, for php scripts a false return
|
||||
* value is changed to 1, anything else to 0
|
||||
*/
|
||||
public function dispatchInstallerEvent(string $eventName, bool $devMode, bool $executeOperations, Transaction $transaction)
|
||||
public function dispatchInstallerEvent(string $eventName, bool $devMode, bool $executeOperations, Transaction $transaction): int
|
||||
{
|
||||
assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
|
||||
|
||||
|
@ -342,7 +342,7 @@ class EventDispatcher
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function executeTty(string $exec)
|
||||
protected function executeTty(string $exec): int
|
||||
{
|
||||
if ($this->io->isInteractive()) {
|
||||
return $this->process->executeTty($exec);
|
||||
|
@ -354,7 +354,7 @@ class EventDispatcher
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getPhpExecCommand()
|
||||
protected function getPhpExecCommand(): string
|
||||
{
|
||||
$finder = new PhpExecutableFinder();
|
||||
$phpPath = $finder->find(false);
|
||||
|
@ -397,7 +397,7 @@ class EventDispatcher
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addListener(string $eventName, callable $listener, int $priority = 0)
|
||||
public function addListener(string $eventName, callable $listener, int $priority = 0): void
|
||||
{
|
||||
$this->listeners[$eventName][$priority][] = $listener;
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ class EventDispatcher
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeListener($listener)
|
||||
public function removeListener($listener): void
|
||||
{
|
||||
foreach ($this->listeners as $eventName => $priorities) {
|
||||
foreach ($priorities as $priority => $listeners) {
|
||||
|
@ -429,7 +429,7 @@ class EventDispatcher
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addSubscriber(EventSubscriberInterface $subscriber)
|
||||
public function addSubscriber(EventSubscriberInterface $subscriber): void
|
||||
{
|
||||
foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
|
||||
if (is_string($params)) {
|
||||
|
@ -450,7 +450,7 @@ class EventDispatcher
|
|||
* @param Event $event
|
||||
* @return array<callable|string> All listeners: callables and scripts
|
||||
*/
|
||||
protected function getListeners(Event $event)
|
||||
protected function getListeners(Event $event): array
|
||||
{
|
||||
$scriptListeners = $this->runScripts ? $this->getScriptListeners($event) : array();
|
||||
|
||||
|
@ -471,7 +471,7 @@ class EventDispatcher
|
|||
* @param Event $event
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEventListeners(Event $event)
|
||||
public function hasEventListeners(Event $event): bool
|
||||
{
|
||||
$listeners = $this->getListeners($event);
|
||||
|
||||
|
@ -484,7 +484,7 @@ class EventDispatcher
|
|||
* @param Event $event Event object
|
||||
* @return string[] Listeners
|
||||
*/
|
||||
protected function getScriptListeners(Event $event)
|
||||
protected function getScriptListeners(Event $event): array
|
||||
{
|
||||
$package = $this->composer->getPackage();
|
||||
$scripts = $package->getScripts();
|
||||
|
@ -519,7 +519,7 @@ class EventDispatcher
|
|||
* @param string $callable
|
||||
* @return bool
|
||||
*/
|
||||
protected function isPhpScript(string $callable)
|
||||
protected function isPhpScript(string $callable): bool
|
||||
{
|
||||
return false === strpos($callable, ' ') && false !== strpos($callable, '::');
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ class EventDispatcher
|
|||
* @param string $callable
|
||||
* @return bool
|
||||
*/
|
||||
protected function isComposerScript(string $callable)
|
||||
protected function isComposerScript(string $callable): bool
|
||||
{
|
||||
return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
|
||||
}
|
||||
|
@ -542,7 +542,7 @@ class EventDispatcher
|
|||
* @throws \RuntimeException
|
||||
* @return int
|
||||
*/
|
||||
protected function pushEvent(Event $event)
|
||||
protected function pushEvent(Event $event): int
|
||||
{
|
||||
$eventName = $event->getName();
|
||||
if (in_array($eventName, $this->eventStack)) {
|
||||
|
@ -557,7 +557,7 @@ class EventDispatcher
|
|||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function popEvent()
|
||||
protected function popEvent(): ?string
|
||||
{
|
||||
return array_pop($this->eventStack);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ class InstallationManager
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
public function reset(): void
|
||||
{
|
||||
$this->notifiablePackages = array();
|
||||
FileDownloader::$downloadMetadata = array();
|
||||
|
@ -76,7 +76,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addInstaller(InstallerInterface $installer)
|
||||
public function addInstaller(InstallerInterface $installer): void
|
||||
{
|
||||
array_unshift($this->installers, $installer);
|
||||
$this->cache = array();
|
||||
|
@ -89,7 +89,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function removeInstaller(InstallerInterface $installer)
|
||||
public function removeInstaller(InstallerInterface $installer): void
|
||||
{
|
||||
if (false !== ($key = array_search($installer, $this->installers, true))) {
|
||||
array_splice($this->installers, $key, 1);
|
||||
|
@ -106,7 +106,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disablePlugins()
|
||||
public function disablePlugins(): void
|
||||
{
|
||||
foreach ($this->installers as $i => $installer) {
|
||||
if (!$installer instanceof PluginInstaller) {
|
||||
|
@ -125,7 +125,7 @@ class InstallationManager
|
|||
* @throws \InvalidArgumentException if installer for provided type is not registered
|
||||
* @return InstallerInterface
|
||||
*/
|
||||
public function getInstaller(string $type)
|
||||
public function getInstaller(string $type): InstallerInterface
|
||||
{
|
||||
$type = strtolower($type);
|
||||
|
||||
|
@ -150,7 +150,7 @@ class InstallationManager
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
|
||||
public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
|
||||
{
|
||||
if ($package instanceof AliasPackage) {
|
||||
return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
|
||||
|
@ -167,7 +167,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ensureBinariesPresence(PackageInterface $package)
|
||||
public function ensureBinariesPresence(PackageInterface $package): void
|
||||
{
|
||||
try {
|
||||
$installer = $this->getInstaller($package->getType());
|
||||
|
@ -192,7 +192,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute(InstalledRepositoryInterface $repo, array $operations, bool $devMode = true, bool $runScripts = true)
|
||||
public function execute(InstalledRepositoryInterface $repo, array $operations, bool $devMode = true, bool $runScripts = true): void
|
||||
{
|
||||
/** @var PromiseInterface[] */
|
||||
$cleanupPromises = array();
|
||||
|
@ -511,7 +511,7 @@ class InstallationManager
|
|||
*
|
||||
* @return PromiseInterface|null
|
||||
*/
|
||||
public function install(InstalledRepositoryInterface $repo, InstallOperation $operation)
|
||||
public function install(InstalledRepositoryInterface $repo, InstallOperation $operation): ?PromiseInterface
|
||||
{
|
||||
$package = $operation->getPackage();
|
||||
$installer = $this->getInstaller($package->getType());
|
||||
|
@ -529,7 +529,7 @@ class InstallationManager
|
|||
*
|
||||
* @return PromiseInterface|null
|
||||
*/
|
||||
public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation)
|
||||
public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation): ?PromiseInterface
|
||||
{
|
||||
$initial = $operation->getInitialPackage();
|
||||
$target = $operation->getTargetPackage();
|
||||
|
@ -569,7 +569,7 @@ class InstallationManager
|
|||
*
|
||||
* @return PromiseInterface|null
|
||||
*/
|
||||
public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation)
|
||||
public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation): ?PromiseInterface
|
||||
{
|
||||
$package = $operation->getPackage();
|
||||
$installer = $this->getInstaller($package->getType());
|
||||
|
@ -585,7 +585,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation)
|
||||
public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation): void
|
||||
{
|
||||
$package = $operation->getPackage();
|
||||
|
||||
|
@ -602,7 +602,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
|
||||
public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation): void
|
||||
{
|
||||
$package = $operation->getPackage();
|
||||
|
||||
|
@ -615,7 +615,7 @@ class InstallationManager
|
|||
* @param PackageInterface $package
|
||||
* @return string path
|
||||
*/
|
||||
public function getInstallPath(PackageInterface $package)
|
||||
public function getInstallPath(PackageInterface $package): string
|
||||
{
|
||||
$installer = $this->getInstaller($package->getType());
|
||||
|
||||
|
@ -627,7 +627,7 @@ class InstallationManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setOutputProgress(bool $outputProgress)
|
||||
public function setOutputProgress(bool $outputProgress): void
|
||||
{
|
||||
$this->outputProgress = $outputProgress;
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ class InstallationManager
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function notifyInstalls(IOInterface $io)
|
||||
public function notifyInstalls(IOInterface $io): void
|
||||
{
|
||||
$promises = array();
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class InstallerEvent extends Event
|
|||
/**
|
||||
* @return Composer
|
||||
*/
|
||||
public function getComposer()
|
||||
public function getComposer(): Composer
|
||||
{
|
||||
return $this->composer;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class InstallerEvent extends Event
|
|||
/**
|
||||
* @return IOInterface
|
||||
*/
|
||||
public function getIO()
|
||||
public function getIO(): IOInterface
|
||||
{
|
||||
return $this->io;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class InstallerEvent extends Event
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDevMode()
|
||||
public function isDevMode(): bool
|
||||
{
|
||||
return $this->devMode;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class InstallerEvent extends Event
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isExecutingOperations()
|
||||
public function isExecutingOperations(): bool
|
||||
{
|
||||
return $this->executeOperations;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class InstallerEvent extends Event
|
|||
/**
|
||||
* @return Transaction|null
|
||||
*/
|
||||
public function getTransaction()
|
||||
public function getTransaction(): ?Transaction
|
||||
{
|
||||
return $this->transaction;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class PackageEvent extends Event
|
|||
/**
|
||||
* @return Composer
|
||||
*/
|
||||
public function getComposer()
|
||||
public function getComposer(): Composer
|
||||
{
|
||||
return $this->composer;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class PackageEvent extends Event
|
|||
/**
|
||||
* @return IOInterface
|
||||
*/
|
||||
public function getIO()
|
||||
public function getIO(): IOInterface
|
||||
{
|
||||
return $this->io;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class PackageEvent extends Event
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDevMode()
|
||||
public function isDevMode(): bool
|
||||
{
|
||||
return $this->devMode;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class PackageEvent extends Event
|
|||
/**
|
||||
* @return RepositoryInterface
|
||||
*/
|
||||
public function getLocalRepo()
|
||||
public function getLocalRepo(): RepositoryInterface
|
||||
{
|
||||
return $this->localRepo;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class PackageEvent extends Event
|
|||
/**
|
||||
* @return OperationInterface[]
|
||||
*/
|
||||
public function getOperations()
|
||||
public function getOperations(): array
|
||||
{
|
||||
return $this->operations;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class PackageEvent extends Event
|
|||
*
|
||||
* @return OperationInterface
|
||||
*/
|
||||
public function getOperation()
|
||||
public function getOperation(): OperationInterface
|
||||
{
|
||||
return $this->operation;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class JsonFile
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class JsonFile
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists()
|
||||
public function exists(): bool
|
||||
{
|
||||
return is_file($this->path);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class JsonFile
|
|||
* @throws ParsingException
|
||||
* @return bool true on success
|
||||
*/
|
||||
public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null)
|
||||
public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null): bool
|
||||
{
|
||||
$content = file_get_contents($this->path);
|
||||
$data = json_decode($content);
|
||||
|
@ -309,7 +309,7 @@ class JsonFile
|
|||
* @throws ParsingException
|
||||
* @return bool true on success
|
||||
*/
|
||||
protected static function validateSyntax(string $json, string $file = null)
|
||||
protected static function validateSyntax(string $json, string $file = null): bool
|
||||
{
|
||||
$parser = new JsonParser();
|
||||
$result = $parser->lint($json);
|
||||
|
|
|
@ -58,7 +58,7 @@ class JsonManipulator
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContents()
|
||||
public function getContents(): string
|
||||
{
|
||||
return $this->contents . $this->newline;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class JsonManipulator
|
|||
* @param bool $sortPackages
|
||||
* @return bool
|
||||
*/
|
||||
public function addLink(string $type, string $package, string $constraint, bool $sortPackages = false)
|
||||
public function addLink(string $type, string $package, string $constraint, bool $sortPackages = false): bool
|
||||
{
|
||||
$decoded = JsonFile::parseJson($this->contents);
|
||||
|
||||
|
@ -170,7 +170,7 @@ class JsonManipulator
|
|||
* @param bool $append
|
||||
* @return bool
|
||||
*/
|
||||
public function addRepository(string $name, $config, bool $append = true)
|
||||
public function addRepository(string $name, $config, bool $append = true): bool
|
||||
{
|
||||
return $this->addSubNode('repositories', $name, $config, $append);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ class JsonManipulator
|
|||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function removeRepository(string $name)
|
||||
public function removeRepository(string $name): bool
|
||||
{
|
||||
return $this->removeSubNode('repositories', $name);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class JsonManipulator
|
|||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function addConfigSetting(string $name, $value)
|
||||
public function addConfigSetting(string $name, $value): bool
|
||||
{
|
||||
return $this->addSubNode('config', $name, $value);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ class JsonManipulator
|
|||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function removeConfigSetting(string $name)
|
||||
public function removeConfigSetting(string $name): bool
|
||||
{
|
||||
return $this->removeSubNode('config', $name);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ class JsonManipulator
|
|||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function addProperty(string $name, $value)
|
||||
public function addProperty(string $name, $value): bool
|
||||
{
|
||||
if (strpos($name, 'suggest.') === 0) {
|
||||
return $this->addSubNode('suggest', substr($name, 8), $value);
|
||||
|
@ -229,7 +229,7 @@ class JsonManipulator
|
|||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function removeProperty(string $name)
|
||||
public function removeProperty(string $name): bool
|
||||
{
|
||||
if (strpos($name, 'suggest.') === 0) {
|
||||
return $this->removeSubNode('suggest', substr($name, 8));
|
||||
|
@ -253,7 +253,7 @@ class JsonManipulator
|
|||
* @param bool $append
|
||||
* @return bool
|
||||
*/
|
||||
public function addSubNode(string $mainNode, string $name, $value, bool $append = true)
|
||||
public function addSubNode(string $mainNode, string $name, $value, bool $append = true): bool
|
||||
{
|
||||
$decoded = JsonFile::parseJson($this->contents);
|
||||
|
||||
|
@ -363,7 +363,7 @@ class JsonManipulator
|
|||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function removeSubNode(string $mainNode, string $name)
|
||||
public function removeSubNode(string $mainNode, string $name): bool
|
||||
{
|
||||
$decoded = JsonFile::parseJson($this->contents);
|
||||
|
||||
|
@ -468,7 +468,7 @@ class JsonManipulator
|
|||
* @param mixed $content
|
||||
* @return bool
|
||||
*/
|
||||
public function addMainKey(string $key, $content)
|
||||
public function addMainKey(string $key, $content): bool
|
||||
{
|
||||
$decoded = JsonFile::parseJson($this->contents);
|
||||
$content = $this->format($content);
|
||||
|
@ -512,7 +512,7 @@ class JsonManipulator
|
|||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function removeMainKey(string $key)
|
||||
public function removeMainKey(string $key): bool
|
||||
{
|
||||
$decoded = JsonFile::parseJson($this->contents);
|
||||
|
||||
|
@ -549,7 +549,7 @@ class JsonManipulator
|
|||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function removeMainKeyIfEmpty(string $key)
|
||||
public function removeMainKeyIfEmpty(string $key): bool
|
||||
{
|
||||
$decoded = JsonFile::parseJson($this->contents);
|
||||
|
||||
|
@ -569,7 +569,7 @@ class JsonManipulator
|
|||
* @param int $depth
|
||||
* @return string
|
||||
*/
|
||||
public function format($data, int $depth = 0)
|
||||
public function format($data, int $depth = 0): string
|
||||
{
|
||||
if (is_array($data)) {
|
||||
reset($data);
|
||||
|
@ -597,7 +597,7 @@ class JsonManipulator
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function detectIndenting()
|
||||
protected function detectIndenting(): void
|
||||
{
|
||||
if (Preg::isMatch('{^([ \t]+)"}m', $this->contents, $match)) {
|
||||
$this->indent = $match[1];
|
||||
|
|
|
@ -159,14 +159,10 @@ class AliasPackage extends BasePackage
|
|||
* Stores whether this is an alias created by an aliasing in the requirements of the root package or not
|
||||
*
|
||||
* Use by the policy for sorting manually aliased packages first, see #576
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setRootPackageAlias(bool $value)
|
||||
public function setRootPackageAlias(bool $value): void
|
||||
{
|
||||
return $this->rootPackageAlias = $value;
|
||||
$this->rootPackageAlias = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,7 +221,7 @@ class AliasPackage extends BasePackage
|
|||
return $this->hasSelfVersionRequires;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getPrettyName()
|
||||
public function getPrettyName(): string
|
||||
{
|
||||
return $this->prettyName;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getNames($provides = true)
|
||||
public function getNames($provides = true): array
|
||||
{
|
||||
$names = array(
|
||||
$this->getName() => true,
|
||||
|
@ -116,7 +116,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setId(int $id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getId()
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setRepository(RepositoryInterface $repository)
|
||||
public function setRepository(RepositoryInterface $repository): void
|
||||
{
|
||||
if ($this->repository && $repository !== $this->repository) {
|
||||
throw new \LogicException('A package can only be added to one repository');
|
||||
|
@ -143,7 +143,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRepository()
|
||||
public function getRepository(): ?RepositoryInterface
|
||||
{
|
||||
return $this->repository;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ abstract class BasePackage implements PackageInterface
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlatform()
|
||||
public function isPlatform(): bool
|
||||
{
|
||||
return $this->getRepository() instanceof PlatformRepository;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ abstract class BasePackage implements PackageInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueName()
|
||||
public function getUniqueName(): string
|
||||
{
|
||||
return $this->getName().'-'.$this->getVersion();
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function equals(PackageInterface $package)
|
||||
public function equals(PackageInterface $package): bool
|
||||
{
|
||||
$self = $this;
|
||||
if ($this instanceof AliasPackage) {
|
||||
|
@ -189,12 +189,12 @@ abstract class BasePackage implements PackageInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->getUniqueName();
|
||||
}
|
||||
|
||||
public function getPrettyString()
|
||||
public function getPrettyString(): string
|
||||
{
|
||||
return $this->getPrettyName().' '.$this->getPrettyVersion();
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ abstract class BasePackage implements PackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
|
||||
public function getFullPrettyVersion(bool $truncate = true, int $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV): string
|
||||
{
|
||||
if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
|
||||
(!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
|
||||
|
@ -239,7 +239,7 @@ abstract class BasePackage implements PackageInterface
|
|||
*
|
||||
* @phpstan-return self::STABILITY_*
|
||||
*/
|
||||
public function getStabilityPriority()
|
||||
public function getStabilityPriority(): int
|
||||
{
|
||||
return self::$stabilities[$this->getStability()];
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ abstract class BasePackage implements PackageInterface
|
|||
* @param non-empty-string $wrap Wrap the cleaned string by the given string
|
||||
* @return non-empty-string
|
||||
*/
|
||||
public static function packageNameToRegexp(string $allowPattern, string $wrap = '{^%s$}i')
|
||||
public static function packageNameToRegexp(string $allowPattern, string $wrap = '{^%s$}i'): string
|
||||
{
|
||||
$cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
|
||||
|
||||
|
@ -271,7 +271,7 @@ abstract class BasePackage implements PackageInterface
|
|||
* @param non-empty-string $wrap
|
||||
* @return non-empty-string
|
||||
*/
|
||||
public static function packageNamesToRegexp(array $packageNames, string $wrap = '{^(?:%s)$}iD')
|
||||
public static function packageNamesToRegexp(array $packageNames, string $wrap = '{^(?:%s)$}iD'): string
|
||||
{
|
||||
$packageNames = array_map(
|
||||
function ($packageName): string {
|
||||
|
|
|
@ -47,7 +47,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setScripts(array $scripts)
|
||||
public function setScripts(array $scripts): void
|
||||
{
|
||||
$this->scripts = $scripts;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getScripts()
|
||||
public function getScripts(): array
|
||||
{
|
||||
return $this->scripts;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setRepositories(array $repositories)
|
||||
public function setRepositories(array $repositories): void
|
||||
{
|
||||
$this->repositories = $repositories;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRepositories()
|
||||
public function getRepositories(): array
|
||||
{
|
||||
return $this->repositories;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setLicense(array $license)
|
||||
public function setLicense(array $license): void
|
||||
{
|
||||
$this->license = $license;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getLicense()
|
||||
public function getLicense(): array
|
||||
{
|
||||
return $this->license;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setKeywords(array $keywords)
|
||||
public function setKeywords(array $keywords): void
|
||||
{
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getKeywords()
|
||||
public function getKeywords(): array
|
||||
{
|
||||
return $this->keywords;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setAuthors(array $authors)
|
||||
public function setAuthors(array $authors): void
|
||||
{
|
||||
$this->authors = $authors;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getAuthors()
|
||||
public function getAuthors(): array
|
||||
{
|
||||
return $this->authors;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setDescription(?string $description)
|
||||
public function setDescription(?string $description): void
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDescription()
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setHomepage(?string $homepage)
|
||||
public function setHomepage(?string $homepage): void
|
||||
{
|
||||
$this->homepage = $homepage;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getHomepage()
|
||||
public function getHomepage(): ?string
|
||||
{
|
||||
return $this->homepage;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSupport(array $support)
|
||||
public function setSupport(array $support): void
|
||||
{
|
||||
$this->support = $support;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSupport()
|
||||
public function getSupport(): array
|
||||
{
|
||||
return $this->support;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setFunding(array $funding)
|
||||
public function setFunding(array $funding): void
|
||||
{
|
||||
$this->funding = $funding;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFunding()
|
||||
public function getFunding(): array
|
||||
{
|
||||
return $this->funding;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isAbandoned()
|
||||
public function isAbandoned(): bool
|
||||
{
|
||||
return (bool) $this->abandoned;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setAbandoned($abandoned)
|
||||
public function setAbandoned($abandoned): void
|
||||
{
|
||||
$this->abandoned = $abandoned;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReplacementPackage()
|
||||
public function getReplacementPackage(): ?string
|
||||
{
|
||||
return \is_string($this->abandoned) ? $this->abandoned : null;
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setArchiveName(?string $name)
|
||||
public function setArchiveName(?string $name): void
|
||||
{
|
||||
$this->archiveName = $name;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getArchiveName()
|
||||
public function getArchiveName(): ?string
|
||||
{
|
||||
return $this->archiveName;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setArchiveExcludes(array $excludes)
|
||||
public function setArchiveExcludes(array $excludes): void
|
||||
{
|
||||
$this->archiveExcludes = $excludes;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ class CompletePackage extends Package implements CompletePackageInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getArchiveExcludes()
|
||||
public function getArchiveExcludes(): array
|
||||
{
|
||||
return $this->archiveExcludes;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace Composer\Package;
|
|||
/**
|
||||
* Defines package metadata that is not necessarily needed for solving and installing packages
|
||||
*
|
||||
* PackageInterface & derivatives are considered internal, you may use them in type hints but extending/implementing them is not recommended and not supported. Things may change without notice.
|
||||
*
|
||||
* @author Nils Adermann <naderman@naderman.de>
|
||||
*/
|
||||
interface CompletePackageInterface extends PackageInterface
|
||||
|
@ -24,20 +26,20 @@ interface CompletePackageInterface extends PackageInterface
|
|||
*
|
||||
* @return array<string, string[]> Map of script name to array of handlers
|
||||
*/
|
||||
public function getScripts();
|
||||
public function getScripts(): array;
|
||||
|
||||
/**
|
||||
* @param array<string, string[]> $scripts
|
||||
* @return void
|
||||
*/
|
||||
public function setScripts(array $scripts);
|
||||
public function setScripts(array $scripts): void;
|
||||
|
||||
/**
|
||||
* Returns an array of repositories
|
||||
*
|
||||
* @return mixed[] Repositories
|
||||
*/
|
||||
public function getRepositories();
|
||||
public function getRepositories(): array;
|
||||
|
||||
/**
|
||||
* Set the repositories
|
||||
|
@ -45,14 +47,14 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param mixed[] $repositories
|
||||
* @return void
|
||||
*/
|
||||
public function setRepositories(array $repositories);
|
||||
public function setRepositories(array $repositories): void;
|
||||
|
||||
/**
|
||||
* Returns the package license, e.g. MIT, BSD, GPL
|
||||
*
|
||||
* @return string[] The package licenses
|
||||
*/
|
||||
public function getLicense();
|
||||
public function getLicense(): array;
|
||||
|
||||
/**
|
||||
* Set the license
|
||||
|
@ -60,14 +62,14 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param string[] $license
|
||||
* @return void
|
||||
*/
|
||||
public function setLicense(array $license);
|
||||
public function setLicense(array $license): void;
|
||||
|
||||
/**
|
||||
* Returns an array of keywords relating to the package
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getKeywords();
|
||||
public function getKeywords(): array;
|
||||
|
||||
/**
|
||||
* Set the keywords
|
||||
|
@ -75,14 +77,14 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param string[] $keywords
|
||||
* @return void
|
||||
*/
|
||||
public function setKeywords(array $keywords);
|
||||
public function setKeywords(array $keywords): void;
|
||||
|
||||
/**
|
||||
* Returns the package description
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getDescription();
|
||||
public function getDescription(): ?string;
|
||||
|
||||
/**
|
||||
* Set the description
|
||||
|
@ -90,14 +92,14 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param string $description
|
||||
* @return void
|
||||
*/
|
||||
public function setDescription(string $description);
|
||||
public function setDescription(string $description): void;
|
||||
|
||||
/**
|
||||
* Returns the package homepage
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getHomepage();
|
||||
public function getHomepage(): ?string;
|
||||
|
||||
/**
|
||||
* Set the homepage
|
||||
|
@ -105,7 +107,7 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param string $homepage
|
||||
* @return void
|
||||
*/
|
||||
public function setHomepage(string $homepage);
|
||||
public function setHomepage(string $homepage): void;
|
||||
|
||||
/**
|
||||
* Returns an array of authors of the package
|
||||
|
@ -114,7 +116,7 @@ interface CompletePackageInterface extends PackageInterface
|
|||
*
|
||||
* @return array<array{name?: string, homepage?: string, email?: string, role?: string}>
|
||||
*/
|
||||
public function getAuthors();
|
||||
public function getAuthors(): array;
|
||||
|
||||
/**
|
||||
* Set the authors
|
||||
|
@ -122,14 +124,14 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param array<array{name?: string, homepage?: string, email?: string, role?: string}> $authors
|
||||
* @return void
|
||||
*/
|
||||
public function setAuthors(array $authors);
|
||||
public function setAuthors(array $authors): void;
|
||||
|
||||
/**
|
||||
* Returns the support information
|
||||
*
|
||||
* @return array{issues?: string, forum?: string, wiki?: string, source?: string, email?: string, irc?: string, docs?: string, rss?: string, chat?: string}
|
||||
*/
|
||||
public function getSupport();
|
||||
public function getSupport(): array;
|
||||
|
||||
/**
|
||||
* Set the support information
|
||||
|
@ -137,7 +139,7 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param array{issues?: string, forum?: string, wiki?: string, source?: string, email?: string, irc?: string, docs?: string, rss?: string, chat?: string} $support
|
||||
* @return void
|
||||
*/
|
||||
public function setSupport(array $support);
|
||||
public function setSupport(array $support): void;
|
||||
|
||||
/**
|
||||
* Returns an array of funding options for the package
|
||||
|
@ -146,7 +148,7 @@ interface CompletePackageInterface extends PackageInterface
|
|||
*
|
||||
* @return array<array{type?: string, url?: string}>
|
||||
*/
|
||||
public function getFunding();
|
||||
public function getFunding(): array;
|
||||
|
||||
/**
|
||||
* Set the funding
|
||||
|
@ -154,34 +156,34 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param array<array{type?: string, url?: string}> $funding
|
||||
* @return void
|
||||
*/
|
||||
public function setFunding(array $funding);
|
||||
public function setFunding(array $funding): void;
|
||||
|
||||
/**
|
||||
* Returns if the package is abandoned or not
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAbandoned();
|
||||
public function isAbandoned(): bool;
|
||||
|
||||
/**
|
||||
* If the package is abandoned and has a suggested replacement, this method returns it
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReplacementPackage();
|
||||
public function getReplacementPackage(): ?string;
|
||||
|
||||
/**
|
||||
* @param bool|string $abandoned
|
||||
* @return void
|
||||
*/
|
||||
public function setAbandoned($abandoned);
|
||||
public function setAbandoned($abandoned): void;
|
||||
|
||||
/**
|
||||
* Returns default base filename for archive
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getArchiveName();
|
||||
public function getArchiveName(): ?string;
|
||||
|
||||
/**
|
||||
* Sets default base filename for archive
|
||||
|
@ -189,14 +191,14 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setArchiveName(string $name);
|
||||
public function setArchiveName(string $name): void;
|
||||
|
||||
/**
|
||||
* Returns a list of patterns to exclude from package archives
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getArchiveExcludes();
|
||||
public function getArchiveExcludes(): array;
|
||||
|
||||
/**
|
||||
* Sets a list of patterns to be excluded from archives
|
||||
|
@ -204,5 +206,5 @@ interface CompletePackageInterface extends PackageInterface
|
|||
* @param string[] $excludes
|
||||
* @return void
|
||||
*/
|
||||
public function setArchiveExcludes(array $excludes);
|
||||
public function setArchiveExcludes(array $excludes): void;
|
||||
}
|
||||
|
|
|
@ -21,22 +21,22 @@ use Composer\Semver\Constraint\ConstraintInterface;
|
|||
*/
|
||||
class Link
|
||||
{
|
||||
const TYPE_REQUIRE = 'requires';
|
||||
const TYPE_DEV_REQUIRE = 'devRequires';
|
||||
const TYPE_PROVIDE = 'provides';
|
||||
const TYPE_CONFLICT = 'conflicts';
|
||||
const TYPE_REPLACE = 'replaces';
|
||||
public const TYPE_REQUIRE = 'requires';
|
||||
public const TYPE_DEV_REQUIRE = 'devRequires';
|
||||
public const TYPE_PROVIDE = 'provides';
|
||||
public const TYPE_CONFLICT = 'conflicts';
|
||||
public const TYPE_REPLACE = 'replaces';
|
||||
|
||||
/**
|
||||
* Special type
|
||||
* @internal
|
||||
*/
|
||||
const TYPE_DOES_NOT_REQUIRE = 'does not require';
|
||||
public const TYPE_DOES_NOT_REQUIRE = 'does not require';
|
||||
/**
|
||||
* TODO should be marked private once 5.3 is dropped
|
||||
* @private
|
||||
*/
|
||||
const TYPE_UNKNOWN = 'relates to';
|
||||
private const TYPE_UNKNOWN = 'relates to';
|
||||
|
||||
/**
|
||||
* Will be converted into a constant once the min PHP version allows this
|
||||
|
|
|
@ -120,7 +120,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isDev()
|
||||
public function isDev(): bool
|
||||
{
|
||||
return $this->dev;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setType(string $type)
|
||||
public function setType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type ?: 'library';
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getStability()
|
||||
public function getStability(): string
|
||||
{
|
||||
return $this->stability;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setTargetDir(?string $targetDir)
|
||||
public function setTargetDir(?string $targetDir): void
|
||||
{
|
||||
$this->targetDir = $targetDir;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTargetDir()
|
||||
public function getTargetDir(): ?string
|
||||
{
|
||||
if (null === $this->targetDir) {
|
||||
return null;
|
||||
|
@ -176,7 +176,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setExtra(array $extra)
|
||||
public function setExtra(array $extra): void
|
||||
{
|
||||
$this->extra = $extra;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getExtra()
|
||||
public function getExtra(): array
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setBinaries(array $binaries)
|
||||
public function setBinaries(array $binaries): void
|
||||
{
|
||||
$this->binaries = $binaries;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getBinaries()
|
||||
public function getBinaries(): array
|
||||
{
|
||||
return $this->binaries;
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setInstallationSource(?string $type)
|
||||
public function setInstallationSource(?string $type): void
|
||||
{
|
||||
$this->installationSource = $type;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getInstallationSource()
|
||||
public function getInstallationSource(): ?string
|
||||
{
|
||||
return $this->installationSource;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceType(?string $type)
|
||||
public function setSourceType(?string $type): void
|
||||
{
|
||||
$this->sourceType = $type;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSourceType()
|
||||
public function getSourceType(): ?string
|
||||
{
|
||||
return $this->sourceType;
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceUrl(?string $url)
|
||||
public function setSourceUrl(?string $url): void
|
||||
{
|
||||
$this->sourceUrl = $url;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSourceUrl()
|
||||
public function getSourceUrl(): ?string
|
||||
{
|
||||
return $this->sourceUrl;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceReference(?string $reference)
|
||||
public function setSourceReference(?string $reference): void
|
||||
{
|
||||
$this->sourceReference = $reference;
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSourceReference()
|
||||
public function getSourceReference(): ?string
|
||||
{
|
||||
return $this->sourceReference;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceMirrors(?array $mirrors)
|
||||
public function setSourceMirrors(?array $mirrors): void
|
||||
{
|
||||
$this->sourceMirrors = $mirrors;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSourceMirrors()
|
||||
public function getSourceMirrors(): ?array
|
||||
{
|
||||
return $this->sourceMirrors;
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSourceUrls()
|
||||
public function getSourceUrls(): array
|
||||
{
|
||||
return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDistType(?string $type)
|
||||
public function setDistType(?string $type): void
|
||||
{
|
||||
$this->distType = $type;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDistType()
|
||||
public function getDistType(): ?string
|
||||
{
|
||||
return $this->distType;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDistUrl(?string $url)
|
||||
public function setDistUrl(?string $url): void
|
||||
{
|
||||
$this->distUrl = $url;
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDistUrl()
|
||||
public function getDistUrl(): ?string
|
||||
{
|
||||
return $this->distUrl;
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDistReference(?string $reference)
|
||||
public function setDistReference(?string $reference): void
|
||||
{
|
||||
$this->distReference = $reference;
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDistReference()
|
||||
public function getDistReference(): ?string
|
||||
{
|
||||
return $this->distReference;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDistSha1Checksum(?string $sha1checksum)
|
||||
public function setDistSha1Checksum(?string $sha1checksum): void
|
||||
{
|
||||
$this->distSha1Checksum = $sha1checksum;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDistSha1Checksum()
|
||||
public function getDistSha1Checksum(): ?string
|
||||
{
|
||||
return $this->distSha1Checksum;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setDistMirrors(?array $mirrors)
|
||||
public function setDistMirrors(?array $mirrors): void
|
||||
{
|
||||
$this->distMirrors = $mirrors;
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDistMirrors()
|
||||
public function getDistMirrors(): ?array
|
||||
{
|
||||
return $this->distMirrors;
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDistUrls()
|
||||
public function getDistUrls(): array
|
||||
{
|
||||
return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTransportOptions()
|
||||
public function getTransportOptions(): array
|
||||
{
|
||||
return $this->transportOptions;
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setTransportOptions(array $options)
|
||||
public function setTransportOptions(array $options): void
|
||||
{
|
||||
$this->transportOptions = $options;
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getVersion()
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getPrettyVersion()
|
||||
public function getPrettyVersion(): string
|
||||
{
|
||||
return $this->prettyVersion;
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setReleaseDate(?\DateTimeInterface $releaseDate)
|
||||
public function setReleaseDate(?\DateTimeInterface $releaseDate): void
|
||||
{
|
||||
$this->releaseDate = $releaseDate;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReleaseDate()
|
||||
public function getReleaseDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->releaseDate;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRequires(array $requires)
|
||||
public function setRequires(array $requires): void
|
||||
{
|
||||
if (isset($requires[0])) { // @phpstan-ignore-line
|
||||
$requires = $this->convertLinksToMap($requires, 'setRequires');
|
||||
|
@ -460,7 +460,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRequires()
|
||||
public function getRequires(): array
|
||||
{
|
||||
return $this->requires;
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setConflicts(array $conflicts)
|
||||
public function setConflicts(array $conflicts): void
|
||||
{
|
||||
if (isset($conflicts[0])) { // @phpstan-ignore-line
|
||||
$conflicts = $this->convertLinksToMap($conflicts, 'setConflicts');
|
||||
|
@ -485,7 +485,7 @@ class Package extends BasePackage
|
|||
* @inheritDoc
|
||||
* @return array<string, Link>
|
||||
*/
|
||||
public function getConflicts()
|
||||
public function getConflicts(): array
|
||||
{
|
||||
return $this->conflicts;
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setProvides(array $provides)
|
||||
public function setProvides(array $provides): void
|
||||
{
|
||||
if (isset($provides[0])) { // @phpstan-ignore-line
|
||||
$provides = $this->convertLinksToMap($provides, 'setProvides');
|
||||
|
@ -510,7 +510,7 @@ class Package extends BasePackage
|
|||
* @inheritDoc
|
||||
* @return array<string, Link>
|
||||
*/
|
||||
public function getProvides()
|
||||
public function getProvides(): array
|
||||
{
|
||||
return $this->provides;
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setReplaces(array $replaces)
|
||||
public function setReplaces(array $replaces): void
|
||||
{
|
||||
if (isset($replaces[0])) { // @phpstan-ignore-line
|
||||
$replaces = $this->convertLinksToMap($replaces, 'setReplaces');
|
||||
|
@ -535,7 +535,7 @@ class Package extends BasePackage
|
|||
* @inheritDoc
|
||||
* @return array<string, Link>
|
||||
*/
|
||||
public function getReplaces()
|
||||
public function getReplaces(): array
|
||||
{
|
||||
return $this->replaces;
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDevRequires(array $devRequires)
|
||||
public function setDevRequires(array $devRequires): void
|
||||
{
|
||||
if (isset($devRequires[0])) { // @phpstan-ignore-line
|
||||
$devRequires = $this->convertLinksToMap($devRequires, 'setDevRequires');
|
||||
|
@ -559,7 +559,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDevRequires()
|
||||
public function getDevRequires(): array
|
||||
{
|
||||
return $this->devRequires;
|
||||
}
|
||||
|
@ -571,7 +571,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSuggests(array $suggests)
|
||||
public function setSuggests(array $suggests): void
|
||||
{
|
||||
$this->suggests = $suggests;
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSuggests()
|
||||
public function getSuggests(): array
|
||||
{
|
||||
return $this->suggests;
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @phpstan-param AutoloadRules $autoload
|
||||
*/
|
||||
public function setAutoload(array $autoload)
|
||||
public function setAutoload(array $autoload): void
|
||||
{
|
||||
$this->autoload = $autoload;
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getAutoload()
|
||||
public function getAutoload(): array
|
||||
{
|
||||
return $this->autoload;
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @phpstan-param DevAutoloadRules $devAutoload
|
||||
*/
|
||||
public function setDevAutoload(array $devAutoload)
|
||||
public function setDevAutoload(array $devAutoload): void
|
||||
{
|
||||
$this->devAutoload = $devAutoload;
|
||||
}
|
||||
|
@ -623,7 +623,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDevAutoload()
|
||||
public function getDevAutoload(): array
|
||||
{
|
||||
return $this->devAutoload;
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIncludePaths(array $includePaths)
|
||||
public function setIncludePaths(array $includePaths): void
|
||||
{
|
||||
$this->includePaths = $includePaths;
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getIncludePaths()
|
||||
public function getIncludePaths(): array
|
||||
{
|
||||
return $this->includePaths;
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNotificationUrl(string $notificationUrl)
|
||||
public function setNotificationUrl(string $notificationUrl): void
|
||||
{
|
||||
$this->notificationUrl = $notificationUrl;
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getNotificationUrl()
|
||||
public function getNotificationUrl(): ?string
|
||||
{
|
||||
return $this->notificationUrl;
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIsDefaultBranch(bool $defaultBranch)
|
||||
public function setIsDefaultBranch(bool $defaultBranch): void
|
||||
{
|
||||
$this->isDefaultBranch = $defaultBranch;
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isDefaultBranch()
|
||||
public function isDefaultBranch(): bool
|
||||
{
|
||||
return $this->isDefaultBranch;
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ class Package extends BasePackage
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setSourceDistReferences(string $reference)
|
||||
public function setSourceDistReferences(string $reference): void
|
||||
{
|
||||
$this->setSourceReference($reference);
|
||||
|
||||
|
@ -715,7 +715,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function replaceVersion(string $version, string $prettyVersion)
|
||||
public function replaceVersion(string $version, string $prettyVersion): void
|
||||
{
|
||||
$this->version = $version;
|
||||
$this->prettyVersion = $prettyVersion;
|
||||
|
@ -735,7 +735,7 @@ class Package extends BasePackage
|
|||
*
|
||||
* @phpstan-param list<array{url: string, preferred: bool}>|null $mirrors
|
||||
*/
|
||||
protected function getUrls(?string $url, ?array $mirrors, ?string $ref, ?string $type, string $urlType)
|
||||
protected function getUrls(?string $url, ?array $mirrors, ?string $ref, ?string $type, string $urlType): array
|
||||
{
|
||||
if (!$url) {
|
||||
return array();
|
||||
|
|
|
@ -17,6 +17,8 @@ use Composer\Repository\RepositoryInterface;
|
|||
/**
|
||||
* Defines the essential information a package has that is used during solving/installation
|
||||
*
|
||||
* PackageInterface & derivatives are considered internal, you may use them in type hints but extending/implementing them is not recommended and not supported. Things may change without notice.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @phpstan-type AutoloadRules array{psr-0?: array<string, string|string[]>, psr-4?: array<string, string|string[]>, classmap?: list<string>, files?: list<string>, exclude-from-classmap?: list<string>}
|
||||
|
@ -33,14 +35,14 @@ interface PackageInterface
|
|||
*
|
||||
* @return string package name
|
||||
*/
|
||||
public function getName();
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* Returns the package's pretty (i.e. with proper case) name
|
||||
*
|
||||
* @return string package name
|
||||
*/
|
||||
public function getPrettyName();
|
||||
public function getPrettyName(): string;
|
||||
|
||||
/**
|
||||
* Returns a set of names that could refer to this package
|
||||
|
@ -52,7 +54,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return string[] An array of strings referring to this package
|
||||
*/
|
||||
public function getNames(bool $provides = true);
|
||||
public function getNames(bool $provides = true): array;
|
||||
|
||||
/**
|
||||
* Allows the solver to set an id for this package to refer to it.
|
||||
|
@ -61,42 +63,42 @@ interface PackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setId(int $id);
|
||||
public function setId(int $id): void;
|
||||
|
||||
/**
|
||||
* Retrieves the package's id set through setId
|
||||
*
|
||||
* @return int The previously set package id
|
||||
*/
|
||||
public function getId();
|
||||
public function getId(): int;
|
||||
|
||||
/**
|
||||
* Returns whether the package is a development virtual package or a concrete one
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDev();
|
||||
public function isDev(): bool;
|
||||
|
||||
/**
|
||||
* Returns the package type, e.g. library
|
||||
*
|
||||
* @return string The package type
|
||||
*/
|
||||
public function getType();
|
||||
public function getType(): string;
|
||||
|
||||
/**
|
||||
* Returns the package targetDir property
|
||||
*
|
||||
* @return ?string The package targetDir
|
||||
*/
|
||||
public function getTargetDir();
|
||||
public function getTargetDir(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the package extra data
|
||||
*
|
||||
* @return mixed[] The package extra data
|
||||
*/
|
||||
public function getExtra();
|
||||
public function getExtra(): array;
|
||||
|
||||
/**
|
||||
* Sets source from which this package was installed (source/dist).
|
||||
|
@ -106,7 +108,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setInstallationSource(?string $type);
|
||||
public function setInstallationSource(?string $type): void;
|
||||
|
||||
/**
|
||||
* Returns source from which this package was installed (source/dist).
|
||||
|
@ -114,110 +116,110 @@ interface PackageInterface
|
|||
* @return ?string source/dist
|
||||
* @phpstan-return 'source'|'dist'|null
|
||||
*/
|
||||
public function getInstallationSource();
|
||||
public function getInstallationSource(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the repository type of this package, e.g. git, svn
|
||||
*
|
||||
* @return ?string The repository type
|
||||
*/
|
||||
public function getSourceType();
|
||||
public function getSourceType(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the repository url of this package, e.g. git://github.com/naderman/composer.git
|
||||
*
|
||||
* @return ?string The repository url
|
||||
*/
|
||||
public function getSourceUrl();
|
||||
public function getSourceUrl(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the repository urls of this package including mirrors, e.g. git://github.com/naderman/composer.git
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSourceUrls();
|
||||
public function getSourceUrls(): array;
|
||||
|
||||
/**
|
||||
* Returns the repository reference of this package, e.g. master, 1.0.0 or a commit hash for git
|
||||
*
|
||||
* @return ?string The repository reference
|
||||
*/
|
||||
public function getSourceReference();
|
||||
public function getSourceReference(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the source mirrors of this package
|
||||
*
|
||||
* @return ?array<int, array{url: string, preferred: bool}>
|
||||
*/
|
||||
public function getSourceMirrors();
|
||||
public function getSourceMirrors(): ?array;
|
||||
|
||||
/**
|
||||
* @param null|array<int, array{url: string, preferred: bool}> $mirrors
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceMirrors(?array $mirrors);
|
||||
public function setSourceMirrors(?array $mirrors): void;
|
||||
|
||||
/**
|
||||
* Returns the type of the distribution archive of this version, e.g. zip, tarball
|
||||
*
|
||||
* @return ?string The repository type
|
||||
*/
|
||||
public function getDistType();
|
||||
public function getDistType(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the url of the distribution archive of this version
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getDistUrl();
|
||||
public function getDistUrl(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the urls of the distribution archive of this version, including mirrors
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDistUrls();
|
||||
public function getDistUrls(): array;
|
||||
|
||||
/**
|
||||
* Returns the reference of the distribution archive of this version, e.g. master, 1.0.0 or a commit hash for git
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getDistReference();
|
||||
public function getDistReference(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the sha1 checksum for the distribution archive of this version
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getDistSha1Checksum();
|
||||
public function getDistSha1Checksum(): ?string;
|
||||
|
||||
/**
|
||||
* Returns the dist mirrors of this package
|
||||
*
|
||||
* @return ?array<int, array{url: string, preferred: bool}>
|
||||
*/
|
||||
public function getDistMirrors();
|
||||
public function getDistMirrors(): ?array;
|
||||
|
||||
/**
|
||||
* @param null|array<int, array{url: string, preferred: bool}> $mirrors
|
||||
* @return void
|
||||
*/
|
||||
public function setDistMirrors(?array $mirrors);
|
||||
public function setDistMirrors(?array $mirrors): void;
|
||||
|
||||
/**
|
||||
* Returns the version of this package
|
||||
*
|
||||
* @return string version
|
||||
*/
|
||||
public function getVersion();
|
||||
public function getVersion(): string;
|
||||
|
||||
/**
|
||||
* Returns the pretty (i.e. non-normalized) version string of this package
|
||||
*
|
||||
* @return string version
|
||||
*/
|
||||
public function getPrettyVersion();
|
||||
public function getPrettyVersion(): string;
|
||||
|
||||
/**
|
||||
* Returns the pretty version string plus a git or hg commit hash of this package
|
||||
|
@ -230,14 +232,14 @@ interface PackageInterface
|
|||
*
|
||||
* @phpstan-param self::DISPLAY_SOURCE_REF_IF_DEV|self::DISPLAY_SOURCE_REF|self::DISPLAY_DIST_REF $displayMode
|
||||
*/
|
||||
public function getFullPrettyVersion(bool $truncate = true, int $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
|
||||
public function getFullPrettyVersion(bool $truncate = true, int $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV): string;
|
||||
|
||||
/**
|
||||
* Returns the release date of the package
|
||||
*
|
||||
* @return ?\DateTimeInterface
|
||||
*/
|
||||
public function getReleaseDate();
|
||||
public function getReleaseDate(): ?\DateTimeInterface;
|
||||
|
||||
/**
|
||||
* Returns the stability of this package: one of (dev, alpha, beta, RC, stable)
|
||||
|
@ -246,7 +248,7 @@ interface PackageInterface
|
|||
*
|
||||
* @phpstan-return 'stable'|'RC'|'beta'|'alpha'|'dev'
|
||||
*/
|
||||
public function getStability();
|
||||
public function getStability(): string;
|
||||
|
||||
/**
|
||||
* Returns a set of links to packages which need to be installed before
|
||||
|
@ -254,7 +256,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return array<string, Link> A map of package links defining required packages, indexed by the require package's name
|
||||
*/
|
||||
public function getRequires();
|
||||
public function getRequires(): array;
|
||||
|
||||
/**
|
||||
* Returns a set of links to packages which must not be installed at the
|
||||
|
@ -262,7 +264,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return Link[] An array of package links defining conflicting packages
|
||||
*/
|
||||
public function getConflicts();
|
||||
public function getConflicts(): array;
|
||||
|
||||
/**
|
||||
* Returns a set of links to virtual packages that are provided through
|
||||
|
@ -270,7 +272,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return Link[] An array of package links defining provided packages
|
||||
*/
|
||||
public function getProvides();
|
||||
public function getProvides(): array;
|
||||
|
||||
/**
|
||||
* Returns a set of links to packages which can alternatively be
|
||||
|
@ -278,7 +280,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return Link[] An array of package links defining replaced packages
|
||||
*/
|
||||
public function getReplaces();
|
||||
public function getReplaces(): array;
|
||||
|
||||
/**
|
||||
* Returns a set of links to packages which are required to develop
|
||||
|
@ -286,7 +288,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return array<string, Link> A map of package links defining packages required for development, indexed by the require package's name
|
||||
*/
|
||||
public function getDevRequires();
|
||||
public function getDevRequires(): array;
|
||||
|
||||
/**
|
||||
* Returns a set of package names and reasons why they are useful in
|
||||
|
@ -295,7 +297,7 @@ interface PackageInterface
|
|||
* @return array An array of package suggestions with descriptions
|
||||
* @phpstan-return array<string, string>
|
||||
*/
|
||||
public function getSuggests();
|
||||
public function getSuggests(): array;
|
||||
|
||||
/**
|
||||
* Returns an associative array of autoloading rules
|
||||
|
@ -308,7 +310,7 @@ interface PackageInterface
|
|||
* @return array Mapping of autoloading rules
|
||||
* @phpstan-return AutoloadRules
|
||||
*/
|
||||
public function getAutoload();
|
||||
public function getAutoload(): array;
|
||||
|
||||
/**
|
||||
* Returns an associative array of dev autoloading rules
|
||||
|
@ -321,7 +323,7 @@ interface PackageInterface
|
|||
* @return array Mapping of dev autoloading rules
|
||||
* @phpstan-return DevAutoloadRules
|
||||
*/
|
||||
public function getDevAutoload();
|
||||
public function getDevAutoload(): array;
|
||||
|
||||
/**
|
||||
* Returns a list of directories which should get added to PHP's
|
||||
|
@ -329,7 +331,7 @@ interface PackageInterface
|
|||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getIncludePaths();
|
||||
public function getIncludePaths(): array;
|
||||
|
||||
/**
|
||||
* Stores a reference to the repository that owns the package
|
||||
|
@ -338,61 +340,61 @@ interface PackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRepository(RepositoryInterface $repository);
|
||||
public function setRepository(RepositoryInterface $repository): void;
|
||||
|
||||
/**
|
||||
* Returns a reference to the repository that owns the package
|
||||
*
|
||||
* @return ?RepositoryInterface
|
||||
*/
|
||||
public function getRepository();
|
||||
public function getRepository(): ?RepositoryInterface;
|
||||
|
||||
/**
|
||||
* Returns the package binaries
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getBinaries();
|
||||
public function getBinaries(): array;
|
||||
|
||||
/**
|
||||
* Returns package unique name, constructed from name and version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueName();
|
||||
public function getUniqueName(): string;
|
||||
|
||||
/**
|
||||
* Returns the package notification url
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
public function getNotificationUrl();
|
||||
public function getNotificationUrl(): ?string;
|
||||
|
||||
/**
|
||||
* Converts the package into a readable and unique string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
public function __toString(): string;
|
||||
|
||||
/**
|
||||
* Converts the package into a pretty readable string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrettyString();
|
||||
public function getPrettyString(): string;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefaultBranch();
|
||||
public function isDefaultBranch(): bool;
|
||||
|
||||
/**
|
||||
* Returns a list of options to download package dist files
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getTransportOptions();
|
||||
public function getTransportOptions(): array;
|
||||
|
||||
/**
|
||||
* Configures the list of options to download package dist files
|
||||
|
@ -401,32 +403,32 @@ interface PackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setTransportOptions(array $options);
|
||||
public function setTransportOptions(array $options): void;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceReference(?string $reference);
|
||||
public function setSourceReference(?string $reference): void;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setDistUrl(?string $url);
|
||||
public function setDistUrl(?string $url): void;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setDistType(?string $type);
|
||||
public function setDistType(?string $type): void;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setDistReference(?string $reference);
|
||||
public function setDistReference(?string $reference): void;
|
||||
|
||||
/**
|
||||
* Set dist and source references and update dist URL for ones that contain a reference
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceDistReferences(string $reference);
|
||||
public function setSourceDistReferences(string $reference): void;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace Composer\Package;
|
|||
/**
|
||||
* Defines additional fields that are only needed for the root package
|
||||
*
|
||||
* PackageInterface & derivatives are considered internal, you may use them in type hints but extending/implementing them is not recommended and not supported. Things may change without notice.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @phpstan-import-type AutoloadRules from PackageInterface
|
||||
|
@ -27,14 +29,14 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
|
||||
*/
|
||||
public function getAliases();
|
||||
public function getAliases(): array;
|
||||
|
||||
/**
|
||||
* Returns the minimum stability of the package
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMinimumStability();
|
||||
public function getMinimumStability(): string;
|
||||
|
||||
/**
|
||||
* Returns the stability flags to apply to dependencies
|
||||
|
@ -43,7 +45,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return array<string, BasePackage::STABILITY_*>
|
||||
*/
|
||||
public function getStabilityFlags();
|
||||
public function getStabilityFlags(): array;
|
||||
|
||||
/**
|
||||
* Returns a set of package names and source references that must be enforced on them
|
||||
|
@ -52,21 +54,21 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getReferences();
|
||||
public function getReferences(): array;
|
||||
|
||||
/**
|
||||
* Returns true if the root package prefers picking stable packages over unstable ones
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getPreferStable();
|
||||
public function getPreferStable(): bool;
|
||||
|
||||
/**
|
||||
* Returns the root package's configuration
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getConfig();
|
||||
public function getConfig(): array;
|
||||
|
||||
/**
|
||||
* Set the required packages
|
||||
|
@ -75,7 +77,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRequires(array $requires);
|
||||
public function setRequires(array $requires): void;
|
||||
|
||||
/**
|
||||
* Set the recommended packages
|
||||
|
@ -84,7 +86,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDevRequires(array $devRequires);
|
||||
public function setDevRequires(array $devRequires): void;
|
||||
|
||||
/**
|
||||
* Set the conflicting packages
|
||||
|
@ -93,7 +95,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setConflicts(array $conflicts);
|
||||
public function setConflicts(array $conflicts): void;
|
||||
|
||||
/**
|
||||
* Set the provided virtual packages
|
||||
|
@ -102,7 +104,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setProvides(array $provides);
|
||||
public function setProvides(array $provides): void;
|
||||
|
||||
/**
|
||||
* Set the packages this one replaces
|
||||
|
@ -111,7 +113,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setReplaces(array $replaces);
|
||||
public function setReplaces(array $replaces): void;
|
||||
|
||||
/**
|
||||
* Set the repositories
|
||||
|
@ -120,7 +122,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRepositories(array $repositories);
|
||||
public function setRepositories(array $repositories): void;
|
||||
|
||||
/**
|
||||
* Set the autoload mapping
|
||||
|
@ -130,7 +132,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAutoload(array $autoload);
|
||||
public function setAutoload(array $autoload): void;
|
||||
|
||||
/**
|
||||
* Set the dev autoload mapping
|
||||
|
@ -140,7 +142,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDevAutoload(array $devAutoload);
|
||||
public function setDevAutoload(array $devAutoload): void;
|
||||
|
||||
/**
|
||||
* Set the stabilityFlags
|
||||
|
@ -149,7 +151,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setStabilityFlags(array $stabilityFlags);
|
||||
public function setStabilityFlags(array $stabilityFlags): void;
|
||||
|
||||
/**
|
||||
* Set the minimumStability
|
||||
|
@ -158,7 +160,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setMinimumStability(string $minimumStability);
|
||||
public function setMinimumStability(string $minimumStability): void;
|
||||
|
||||
/**
|
||||
* Set the preferStable
|
||||
|
@ -167,7 +169,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPreferStable(bool $preferStable);
|
||||
public function setPreferStable(bool $preferStable): void;
|
||||
|
||||
/**
|
||||
* Set the config
|
||||
|
@ -176,7 +178,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setConfig(array $config);
|
||||
public function setConfig(array $config): void;
|
||||
|
||||
/**
|
||||
* Set the references
|
||||
|
@ -185,7 +187,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setReferences(array $references);
|
||||
public function setReferences(array $references): void;
|
||||
|
||||
/**
|
||||
* Set the aliases
|
||||
|
@ -194,7 +196,7 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setAliases(array $aliases);
|
||||
public function setAliases(array $aliases): void;
|
||||
|
||||
/**
|
||||
* Set the suggested packages
|
||||
|
@ -203,12 +205,12 @@ interface RootPackageInterface extends CompletePackageInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSuggests(array $suggests);
|
||||
public function setSuggests(array $suggests): void;
|
||||
|
||||
/**
|
||||
* @param mixed[] $extra
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setExtra(array $extra);
|
||||
public function setExtra(array $extra): void;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class VersionParser extends SemverVersionParser
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function parseConstraints($constraints)
|
||||
public function parseConstraints($constraints): ConstraintInterface
|
||||
{
|
||||
if (!isset(self::$constraints[$constraints])) {
|
||||
self::$constraints[$constraints] = parent::parseConstraints($constraints);
|
||||
|
@ -47,7 +47,7 @@ class VersionParser extends SemverVersionParser
|
|||
*
|
||||
* @return list<array{name: string, version?: string}>
|
||||
*/
|
||||
public function parseNameVersionPairs(array $pairs)
|
||||
public function parseNameVersionPairs(array $pairs): array
|
||||
{
|
||||
$pairs = array_values($pairs);
|
||||
$result = array();
|
||||
|
@ -76,7 +76,7 @@ class VersionParser extends SemverVersionParser
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isUpgrade(string $normalizedFrom, string $normalizedTo)
|
||||
public static function isUpgrade(string $normalizedFrom, string $normalizedTo): bool
|
||||
{
|
||||
if ($normalizedFrom === $normalizedTo) {
|
||||
return true;
|
||||
|
|
|
@ -62,7 +62,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return PackageInterface|null
|
||||
*/
|
||||
public function findPackage(string $name, $constraint)
|
||||
public function findPackage(string $name, $constraint): ?PackageInterface
|
||||
{
|
||||
foreach ($this->repositories as $repository) {
|
||||
/** @var RepositoryInterface $repository */
|
||||
|
@ -82,7 +82,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return PackageInterface[]
|
||||
*/
|
||||
public function findPackages(string $name, $constraint)
|
||||
public function findPackages(string $name, $constraint): array
|
||||
{
|
||||
$packages = array();
|
||||
|
||||
|
@ -100,7 +100,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addRepository(RepositoryInterface $repository)
|
||||
public function addRepository(RepositoryInterface $repository): void
|
||||
{
|
||||
$this->repositories[] = $repository;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function prependRepository(RepositoryInterface $repository)
|
||||
public function prependRepository(RepositoryInterface $repository): void
|
||||
{
|
||||
array_unshift($this->repositories, $repository);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class RepositoryManager
|
|||
* @throws \InvalidArgumentException if repository for provided type is not registered
|
||||
* @return RepositoryInterface
|
||||
*/
|
||||
public function createRepository(string $type, array $config, string $name = null)
|
||||
public function createRepository(string $type, array $config, string $name = null): RepositoryInterface
|
||||
{
|
||||
if (!isset($this->repositoryClasses[$type])) {
|
||||
throw new \InvalidArgumentException('Repository type is not registered: '.$type);
|
||||
|
@ -162,7 +162,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setRepositoryClass(string $type, $class)
|
||||
public function setRepositoryClass(string $type, $class): void
|
||||
{
|
||||
$this->repositoryClasses[$type] = $class;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return RepositoryInterface[]
|
||||
*/
|
||||
public function getRepositories()
|
||||
public function getRepositories(): array
|
||||
{
|
||||
return $this->repositories;
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLocalRepository(InstalledRepositoryInterface $repository)
|
||||
public function setLocalRepository(InstalledRepositoryInterface $repository): void
|
||||
{
|
||||
$this->localRepository = $repository;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ class RepositoryManager
|
|||
*
|
||||
* @return InstalledRepositoryInterface
|
||||
*/
|
||||
public function getLocalRepository()
|
||||
public function getLocalRepository(): InstalledRepositoryInterface
|
||||
{
|
||||
return $this->localRepository;
|
||||
}
|
||||
|
|
|
@ -172,12 +172,12 @@ class FossilDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier): ?\DateTime
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
$this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
|
||||
list(, $date) = explode(' ', trim($output), 3);
|
||||
|
||||
return new \DateTime($date, new \DateTimeZone('UTC'));
|
||||
return new \DateTimeImmutable($date, new \DateTimeZone('UTC'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function initialize()
|
||||
public function initialize(): void
|
||||
{
|
||||
if (!Preg::isMatch('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $this->url, $match)) {
|
||||
throw new \InvalidArgumentException(sprintf('The Bitbucket repository URL %s is invalid. It must be the HTTPS URL of a Bitbucket repository.', $this->url));
|
||||
|
@ -83,7 +83,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): string
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getUrl();
|
||||
|
@ -99,7 +99,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
* @return bool
|
||||
* @phpstan-impure
|
||||
*/
|
||||
protected function getRepoData()
|
||||
protected function getRepoData(): bool
|
||||
{
|
||||
$resource = sprintf(
|
||||
'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
|
||||
|
@ -131,7 +131,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComposerInformation(string $identifier)
|
||||
public function getComposerInformation(string $identifier): ?array
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getComposerInformation($identifier);
|
||||
|
@ -148,7 +148,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
}
|
||||
}
|
||||
|
||||
if ($composer) {
|
||||
if ($composer !== null) {
|
||||
// specials for bitbucket
|
||||
if (!isset($composer['support']['source'])) {
|
||||
$label = array_search(
|
||||
|
@ -205,7 +205,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier)
|
||||
public function getFileContent(string $file, string $identifier): ?string
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getFileContent($file, $identifier);
|
||||
|
@ -232,7 +232,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier)
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getChangeDate($identifier);
|
||||
|
@ -253,13 +253,13 @@ class GitBitbucketDriver extends VcsDriver
|
|||
);
|
||||
$commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
|
||||
|
||||
return new \DateTime($commit['date']);
|
||||
return new \DateTimeImmutable($commit['date']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSource(string $identifier)
|
||||
public function getSource(string $identifier): array
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getSource($identifier);
|
||||
|
@ -271,7 +271,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDist(string $identifier)
|
||||
public function getDist(string $identifier): ?array
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getDist($identifier);
|
||||
|
@ -290,7 +290,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getTags();
|
||||
|
@ -333,7 +333,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getBranches()
|
||||
public function getBranches(): array
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getBranches();
|
||||
|
@ -383,7 +383,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
*
|
||||
* @phpstan-impure
|
||||
*/
|
||||
protected function fetchWithOAuthCredentials(string $url, bool $fetchingRepoData = false)
|
||||
protected function fetchWithOAuthCredentials(string $url, bool $fetchingRepoData = false): Response
|
||||
{
|
||||
try {
|
||||
return parent::getContents($url);
|
||||
|
@ -413,7 +413,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generateSshUrl()
|
||||
protected function generateSshUrl(): string
|
||||
{
|
||||
return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
* @return true
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function attemptCloneFallback()
|
||||
protected function attemptCloneFallback(): bool
|
||||
{
|
||||
try {
|
||||
$this->setupFallbackDriver($this->generateSshUrl());
|
||||
|
@ -445,7 +445,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
* @param string $url
|
||||
* @return void
|
||||
*/
|
||||
protected function setupFallbackDriver(string $url)
|
||||
protected function setupFallbackDriver(string $url): void
|
||||
{
|
||||
$this->fallbackDriver = new GitDriver(
|
||||
array('url' => $url),
|
||||
|
@ -461,7 +461,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
* @param array<array{name: string, href: string}> $cloneLinks
|
||||
* @return void
|
||||
*/
|
||||
protected function parseCloneUrls(array $cloneLinks)
|
||||
protected function parseCloneUrls(array $cloneLinks): void
|
||||
{
|
||||
foreach ($cloneLinks as $cloneLink) {
|
||||
if ($cloneLink['name'] === 'https') {
|
||||
|
@ -475,7 +475,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @return (array{name: string}&mixed[])|null
|
||||
*/
|
||||
protected function getMainBranchData()
|
||||
protected function getMainBranchData(): ?array
|
||||
{
|
||||
$resource = sprintf(
|
||||
'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
|
||||
|
@ -494,7 +494,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRootIdentifier()
|
||||
public function getRootIdentifier(): string
|
||||
{
|
||||
if ($this->fallbackDriver) {
|
||||
return $this->fallbackDriver->getRootIdentifier();
|
||||
|
@ -527,7 +527,7 @@ class GitBitbucketDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false)
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
|
||||
{
|
||||
if (!Preg::isMatch('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $url)) {
|
||||
return false;
|
||||
|
|
|
@ -38,7 +38,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function initialize()
|
||||
public function initialize(): void
|
||||
{
|
||||
if (Filesystem::isLocalPath($this->url)) {
|
||||
$this->url = Preg::replace('{[\\/]\.git/?$}', '', $this->url);
|
||||
|
@ -88,7 +88,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRootIdentifier()
|
||||
public function getRootIdentifier(): string
|
||||
{
|
||||
if (null === $this->rootIdentifier) {
|
||||
$this->rootIdentifier = 'master';
|
||||
|
@ -112,7 +112,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSource(string $identifier)
|
||||
public function getSource(string $identifier): array
|
||||
{
|
||||
return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDist(string $identifier)
|
||||
public function getDist(string $identifier): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier)
|
||||
public function getFileContent(string $file, string $identifier): ?string
|
||||
{
|
||||
$resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
|
||||
$this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
|
||||
|
@ -151,20 +151,20 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier)
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
$this->process->execute(sprintf(
|
||||
'git -c log.showSignature=false log -1 --format=%%at %s',
|
||||
ProcessExecutor::escape($identifier)
|
||||
), $output, $this->repoDir);
|
||||
|
||||
return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
|
||||
return new \DateTimeImmutable('@'.trim($output), new \DateTimeZone('UTC'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
if (null === $this->tags) {
|
||||
$this->tags = array();
|
||||
|
@ -183,7 +183,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getBranches()
|
||||
public function getBranches(): array
|
||||
{
|
||||
if (null === $this->branches) {
|
||||
$branches = array();
|
||||
|
@ -206,7 +206,7 @@ class GitDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false)
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
|
||||
{
|
||||
if (Preg::isMatch('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
|
||||
return true;
|
||||
|
|
|
@ -57,7 +57,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function initialize()
|
||||
public function initialize(): void
|
||||
{
|
||||
if (!Preg::isMatch('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match)) {
|
||||
throw new \InvalidArgumentException(sprintf('The GitHub repository URL %s is invalid.', $this->url));
|
||||
|
@ -84,7 +84,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRepositoryUrl()
|
||||
public function getRepositoryUrl(): string
|
||||
{
|
||||
return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRootIdentifier()
|
||||
public function getRootIdentifier(): string
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getRootIdentifier();
|
||||
|
@ -104,7 +104,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): string
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getUrl();
|
||||
|
@ -116,7 +116,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getApiUrl()
|
||||
protected function getApiUrl(): string
|
||||
{
|
||||
if ('github.com' === $this->originUrl) {
|
||||
$apiUrl = 'api.github.com';
|
||||
|
@ -130,7 +130,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSource(string $identifier)
|
||||
public function getSource(string $identifier): array
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getSource($identifier);
|
||||
|
@ -149,7 +149,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDist(string $identifier)
|
||||
public function getDist(string $identifier): ?array
|
||||
{
|
||||
$url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
|
||||
|
||||
|
@ -159,7 +159,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComposerInformation(string $identifier)
|
||||
public function getComposerInformation(string $identifier): ?array
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getComposerInformation($identifier);
|
||||
|
@ -176,7 +176,7 @@ class GitHubDriver extends VcsDriver
|
|||
}
|
||||
}
|
||||
|
||||
if ($composer) {
|
||||
if ($composer !== null) {
|
||||
// specials for github
|
||||
if (!isset($composer['support']['source'])) {
|
||||
$label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
|
||||
|
@ -287,7 +287,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier)
|
||||
public function getFileContent(string $file, string $identifier): ?string
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getFileContent($file, $identifier);
|
||||
|
@ -305,7 +305,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier)
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getChangeDate($identifier);
|
||||
|
@ -314,13 +314,13 @@ class GitHubDriver extends VcsDriver
|
|||
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
|
||||
$commit = $this->getContents($resource)->decodeJson();
|
||||
|
||||
return new \DateTime($commit['commit']['committer']['date']);
|
||||
return new \DateTimeImmutable($commit['commit']['committer']['date']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getTags();
|
||||
|
@ -348,7 +348,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getBranches()
|
||||
public function getBranches(): array
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getBranches();
|
||||
|
@ -379,7 +379,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false)
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
|
||||
{
|
||||
if (!Preg::isMatch('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
|
||||
return false;
|
||||
|
@ -404,7 +404,7 @@ class GitHubDriver extends VcsDriver
|
|||
*
|
||||
* @return mixed[]|null
|
||||
*/
|
||||
public function getRepoData()
|
||||
public function getRepoData(): ?array
|
||||
{
|
||||
$this->fetchRootIdentifier();
|
||||
|
||||
|
@ -416,7 +416,7 @@ class GitHubDriver extends VcsDriver
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generateSshUrl()
|
||||
protected function generateSshUrl(): string
|
||||
{
|
||||
if (false !== strpos($this->originUrl, ':')) {
|
||||
return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
|
||||
|
@ -430,7 +430,7 @@ class GitHubDriver extends VcsDriver
|
|||
*
|
||||
* @param bool $fetchingRepoData
|
||||
*/
|
||||
protected function getContents(string $url, bool $fetchingRepoData = false)
|
||||
protected function getContents(string $url, bool $fetchingRepoData = false): Response
|
||||
{
|
||||
try {
|
||||
return parent::getContents($url);
|
||||
|
@ -521,7 +521,7 @@ class GitHubDriver extends VcsDriver
|
|||
* @return void
|
||||
* @throws TransportException
|
||||
*/
|
||||
protected function fetchRootIdentifier()
|
||||
protected function fetchRootIdentifier(): void
|
||||
{
|
||||
if ($this->repoData) {
|
||||
return;
|
||||
|
@ -563,7 +563,7 @@ class GitHubDriver extends VcsDriver
|
|||
* @return true
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function attemptCloneFallback()
|
||||
protected function attemptCloneFallback(): bool
|
||||
{
|
||||
$this->isPrivate = true;
|
||||
|
||||
|
@ -588,7 +588,7 @@ class GitHubDriver extends VcsDriver
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setupGitDriver(string $url)
|
||||
protected function setupGitDriver(string $url): void
|
||||
{
|
||||
$this->gitDriver = new GitDriver(
|
||||
array('url' => $url),
|
||||
|
@ -603,7 +603,7 @@ class GitHubDriver extends VcsDriver
|
|||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getNextPage(Response $response)
|
||||
protected function getNextPage(Response $response): ?string
|
||||
{
|
||||
$header = $response->getHeader('link');
|
||||
if (!$header) {
|
||||
|
|
|
@ -144,7 +144,7 @@ class GitLabDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComposerInformation($identifier): array
|
||||
public function getComposerInformation(string $identifier): ?array
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getComposerInformation($identifier);
|
||||
|
@ -161,7 +161,7 @@ class GitLabDriver extends VcsDriver
|
|||
}
|
||||
}
|
||||
|
||||
if ($composer) {
|
||||
if (null !== $composer) {
|
||||
// specials for gitlab (this data is only available if authentication is provided)
|
||||
if (!isset($composer['support']['source']) && isset($this->project['web_url'])) {
|
||||
$label = array_search($identifier, $this->getTags(), true) ?: array_search($identifier, $this->getBranches(), true) ?: $identifier;
|
||||
|
@ -216,17 +216,17 @@ class GitLabDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier): ?\DateTime
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
if ($this->gitDriver) {
|
||||
return $this->gitDriver->getChangeDate($identifier);
|
||||
}
|
||||
|
||||
if (isset($this->commits[$identifier])) {
|
||||
return new \DateTime($this->commits[$identifier]['committed_date']);
|
||||
return new \DateTimeImmutable($this->commits[$identifier]['committed_date']);
|
||||
}
|
||||
|
||||
return new \DateTime();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function initialize()
|
||||
public function initialize(): void
|
||||
{
|
||||
if (Filesystem::isLocalPath($this->url)) {
|
||||
$this->repoDir = $this->url;
|
||||
|
@ -86,7 +86,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRootIdentifier()
|
||||
public function getRootIdentifier(): string
|
||||
{
|
||||
if (null === $this->rootIdentifier) {
|
||||
$this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
|
||||
|
@ -100,7 +100,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSource(string $identifier)
|
||||
public function getSource(string $identifier): array
|
||||
{
|
||||
return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDist(string $identifier)
|
||||
public function getDist(string $identifier): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier)
|
||||
public function getFileContent(string $file, string $identifier): ?string
|
||||
{
|
||||
$resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
|
||||
$this->process->execute($resource, $content, $this->repoDir);
|
||||
|
@ -139,7 +139,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier)
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
$this->process->execute(
|
||||
sprintf(
|
||||
|
@ -150,13 +150,13 @@ class HgDriver extends VcsDriver
|
|||
$this->repoDir
|
||||
);
|
||||
|
||||
return new \DateTime(trim($output), new \DateTimeZone('UTC'));
|
||||
return new \DateTimeImmutable(trim($output), new \DateTimeZone('UTC'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
if (null === $this->tags) {
|
||||
$tags = array();
|
||||
|
@ -178,7 +178,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getBranches()
|
||||
public function getBranches(): array
|
||||
{
|
||||
if (null === $this->branches) {
|
||||
$branches = array();
|
||||
|
@ -208,7 +208,7 @@ class HgDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false)
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
|
||||
{
|
||||
if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
|
||||
return true;
|
||||
|
|
|
@ -18,6 +18,7 @@ use Composer\IO\IOInterface;
|
|||
use Composer\Pcre\Preg;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\Util\Perforce;
|
||||
use Composer\Util\Http\Response;
|
||||
|
||||
/**
|
||||
* @author Matt Whittom <Matt.Whittom@veteransunited.com>
|
||||
|
@ -34,7 +35,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function initialize()
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->depot = $this->repoConfig['depot'];
|
||||
$this->branch = '';
|
||||
|
@ -72,7 +73,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier)
|
||||
public function getFileContent(string $file, string $identifier): ?string
|
||||
{
|
||||
return $this->perforce->getFileContent($file, $identifier);
|
||||
}
|
||||
|
@ -80,7 +81,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier)
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -88,7 +89,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRootIdentifier()
|
||||
public function getRootIdentifier(): string
|
||||
{
|
||||
return $this->branch;
|
||||
}
|
||||
|
@ -96,7 +97,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getBranches()
|
||||
public function getBranches(): array
|
||||
{
|
||||
return $this->perforce->getBranches();
|
||||
}
|
||||
|
@ -104,7 +105,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
return $this->perforce->getTags();
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDist(string $identifier)
|
||||
public function getDist(string $identifier): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSource(string $identifier)
|
||||
public function getSource(string $identifier): array
|
||||
{
|
||||
return array(
|
||||
'type' => 'perforce',
|
||||
|
@ -133,7 +134,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
@ -141,7 +142,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasComposerFile(string $identifier)
|
||||
public function hasComposerFile(string $identifier): bool
|
||||
{
|
||||
$composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
|
||||
|
||||
|
@ -151,7 +152,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getContents(string $url)
|
||||
public function getContents(string $url): Response
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented/used in PerforceDriver');
|
||||
}
|
||||
|
@ -159,7 +160,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false)
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
|
||||
{
|
||||
if ($deep || Preg::isMatch('#\b(perforce|p4)\b#i', $url)) {
|
||||
return Perforce::checkServerExists($url, new ProcessExecutor($io));
|
||||
|
@ -171,7 +172,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function cleanup()
|
||||
public function cleanup(): void
|
||||
{
|
||||
$this->perforce->cleanupClientSpec();
|
||||
$this->perforce = null;
|
||||
|
@ -180,7 +181,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDepot()
|
||||
public function getDepot(): string
|
||||
{
|
||||
return $this->depot;
|
||||
}
|
||||
|
@ -188,7 +189,7 @@ class PerforceDriver extends VcsDriver
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBranch()
|
||||
public function getBranch(): string
|
||||
{
|
||||
return $this->branch;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function initialize()
|
||||
public function initialize(): void
|
||||
{
|
||||
$this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
|
||||
|
||||
|
@ -93,7 +93,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getRootIdentifier()
|
||||
public function getRootIdentifier(): string
|
||||
{
|
||||
return $this->rootIdentifier ?: $this->trunkPath;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getSource(string $identifier)
|
||||
public function getSource(string $identifier): array
|
||||
{
|
||||
return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getDist(string $identifier)
|
||||
public function getDist(string $identifier): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function shouldCache(string $identifier)
|
||||
protected function shouldCache(string $identifier): bool
|
||||
{
|
||||
return $this->cache && Preg::isMatch('{@\d+$}', $identifier);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComposerInformation(string $identifier)
|
||||
public function getComposerInformation(string $identifier): ?array
|
||||
{
|
||||
if (!isset($this->infoCache[$identifier])) {
|
||||
if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
|
||||
|
@ -165,7 +165,7 @@ class SvnDriver extends VcsDriver
|
|||
* @param string $file
|
||||
* @param string $identifier
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier)
|
||||
public function getFileContent(string $file, string $identifier): ?string
|
||||
{
|
||||
$identifier = '/' . trim($identifier, '/') . '/';
|
||||
|
||||
|
@ -194,7 +194,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getChangeDate(string $identifier)
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable
|
||||
{
|
||||
$identifier = '/' . trim($identifier, '/') . '/';
|
||||
|
||||
|
@ -210,7 +210,7 @@ class SvnDriver extends VcsDriver
|
|||
$output = $this->execute('svn info', $this->baseUrl . $path . $rev);
|
||||
foreach ($this->process->splitLines($output) as $line) {
|
||||
if ($line && Preg::isMatch('{^Last Changed Date: ([^(]+)}', $line, $match)) {
|
||||
return new \DateTime($match[1], new \DateTimeZone('UTC'));
|
||||
return new \DateTimeImmutable($match[1], new \DateTimeZone('UTC'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
if (null === $this->tags) {
|
||||
$tags = array();
|
||||
|
@ -251,7 +251,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getBranches()
|
||||
public function getBranches(): array
|
||||
{
|
||||
if (null === $this->branches) {
|
||||
$branches = array();
|
||||
|
@ -306,7 +306,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false)
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
|
||||
{
|
||||
$url = self::normalizeUrl($url);
|
||||
if (Preg::isMatch('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
|
||||
|
@ -353,7 +353,7 @@ class SvnDriver extends VcsDriver
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function normalizeUrl(string $url)
|
||||
protected static function normalizeUrl(string $url): string
|
||||
{
|
||||
$fs = new Filesystem();
|
||||
if ($fs->isAbsolutePath($url)) {
|
||||
|
@ -372,7 +372,7 @@ class SvnDriver extends VcsDriver
|
|||
* @throws \RuntimeException
|
||||
* @return string
|
||||
*/
|
||||
protected function execute(string $command, string $url)
|
||||
protected function execute(string $command, string $url): string
|
||||
{
|
||||
if (null === $this->util) {
|
||||
$this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
|
||||
|
@ -400,7 +400,7 @@ class SvnDriver extends VcsDriver
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function buildIdentifier(string $baseDir, int $revision)
|
||||
protected function buildIdentifier(string $baseDir, int $revision): string
|
||||
{
|
||||
return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
* @param string $identifier
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldCache(string $identifier)
|
||||
protected function shouldCache(string $identifier): bool
|
||||
{
|
||||
return $this->cache && Preg::isMatch('{^[a-f0-9]{40}$}iD', $identifier);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getComposerInformation(string $identifier)
|
||||
public function getComposerInformation(string $identifier): ?array
|
||||
{
|
||||
if (!isset($this->infoCache[$identifier])) {
|
||||
if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
|
||||
|
@ -111,7 +111,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
*
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
protected function getBaseComposerInformation(string $identifier)
|
||||
protected function getBaseComposerInformation(string $identifier): ?array
|
||||
{
|
||||
$composerFileContent = $this->getFileContent('composer.json', $identifier);
|
||||
|
||||
|
@ -121,7 +121,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
|
||||
$composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
|
||||
|
||||
if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
|
||||
if (empty($composer['time']) && null !== ($changeDate = $this->getChangeDate($identifier))) {
|
||||
$composer['time'] = $changeDate->format(DATE_RFC3339);
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function hasComposerFile(string $identifier)
|
||||
public function hasComposerFile(string $identifier): bool
|
||||
{
|
||||
try {
|
||||
return (bool) $this->getComposerInformation($identifier);
|
||||
|
@ -148,7 +148,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
*
|
||||
* @return string The correct type of protocol
|
||||
*/
|
||||
protected function getScheme()
|
||||
protected function getScheme(): string
|
||||
{
|
||||
if (extension_loaded('openssl')) {
|
||||
return 'https';
|
||||
|
@ -165,7 +165,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
* @return Response
|
||||
* @throws TransportException
|
||||
*/
|
||||
protected function getContents(string $url)
|
||||
protected function getContents(string $url): Response
|
||||
{
|
||||
$options = $this->repoConfig['options'] ?? array();
|
||||
|
||||
|
@ -175,7 +175,7 @@ abstract class VcsDriver implements VcsDriverInterface
|
|||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function cleanup()
|
||||
public function cleanup(): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ use Composer\IO\IOInterface;
|
|||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @internal
|
||||
*/
|
||||
interface VcsDriverInterface
|
||||
{
|
||||
|
@ -25,15 +26,15 @@ interface VcsDriverInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initialize();
|
||||
public function initialize(): void;
|
||||
|
||||
/**
|
||||
* Return the composer.json file information
|
||||
*
|
||||
* @param string $identifier Any identifier to a specific branch/tag/commit
|
||||
* @return mixed[] containing all infos from the composer.json file
|
||||
* @return mixed[]|null containing all infos from the composer.json file
|
||||
*/
|
||||
public function getComposerInformation(string $identifier);
|
||||
public function getComposerInformation(string $identifier): ?array;
|
||||
|
||||
/**
|
||||
* Return the content of $file or null if the file does not exist.
|
||||
|
@ -42,57 +43,56 @@ interface VcsDriverInterface
|
|||
* @param string $identifier
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier);
|
||||
public function getFileContent(string $file, string $identifier): ?string;
|
||||
|
||||
/**
|
||||
* Get the changedate for $identifier.
|
||||
*
|
||||
* @param string $identifier
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getChangeDate(string $identifier);
|
||||
public function getChangeDate(string $identifier): ?\DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* Return the root identifier (trunk, master, default/tip ..)
|
||||
*
|
||||
* @return string Identifier
|
||||
*/
|
||||
public function getRootIdentifier();
|
||||
public function getRootIdentifier(): string;
|
||||
|
||||
/**
|
||||
* Return list of branches in the repository
|
||||
*
|
||||
* @return array<int|string, string> Branch names as keys, identifiers as values
|
||||
*/
|
||||
public function getBranches();
|
||||
public function getBranches(): array;
|
||||
|
||||
/**
|
||||
* Return list of tags in the repository
|
||||
*
|
||||
* @return array<int|string, string> Tag names as keys, identifiers as values
|
||||
*/
|
||||
public function getTags();
|
||||
public function getTags(): array;
|
||||
|
||||
/**
|
||||
* @param string $identifier Any identifier to a specific branch/tag/commit
|
||||
*
|
||||
* @return array{type: string, url: string, reference: string, shasum: string}|null
|
||||
*/
|
||||
public function getDist(string $identifier);
|
||||
public function getDist(string $identifier): ?array;
|
||||
|
||||
/**
|
||||
* @param string $identifier Any identifier to a specific branch/tag/commit
|
||||
*
|
||||
* @return array{type: string, url: string, reference: string}
|
||||
*/
|
||||
public function getSource(string $identifier);
|
||||
public function getSource(string $identifier): array;
|
||||
|
||||
/**
|
||||
* Return the URL of the repository
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl();
|
||||
public function getUrl(): string;
|
||||
|
||||
/**
|
||||
* Return true if the repository has a composer file for a given identifier,
|
||||
|
@ -101,14 +101,14 @@ interface VcsDriverInterface
|
|||
* @param string $identifier Any identifier to a specific branch/tag/commit
|
||||
* @return bool Whether the repository has a composer file for a given identifier.
|
||||
*/
|
||||
public function hasComposerFile(string $identifier);
|
||||
public function hasComposerFile(string $identifier): bool;
|
||||
|
||||
/**
|
||||
* Performs any cleanup necessary as the driver is not longer needed
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cleanup();
|
||||
public function cleanup(): void;
|
||||
|
||||
/**
|
||||
* Checks if this driver can handle a given url
|
||||
|
@ -119,5 +119,5 @@ interface VcsDriverInterface
|
|||
* @param bool $deep unless true, only shallow checks (url matching typically) should be done
|
||||
* @return bool
|
||||
*/
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false);
|
||||
public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool;
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setLoader(LoaderInterface $loader)
|
||||
public function setLoader(LoaderInterface $loader): void
|
||||
{
|
||||
$this->loader = $loader;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
/**
|
||||
* @return VcsDriverInterface|null
|
||||
*/
|
||||
public function getDriver()
|
||||
public function getDriver(): ?VcsDriverInterface
|
||||
{
|
||||
if ($this->driver) {
|
||||
return $this->driver;
|
||||
|
@ -167,7 +167,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hadInvalidBranches()
|
||||
public function hadInvalidBranches(): bool
|
||||
{
|
||||
return $this->branchErrorOccurred;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getEmptyReferences()
|
||||
public function getEmptyReferences(): array
|
||||
{
|
||||
return $this->emptyReferences;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
/**
|
||||
* @return array<'tags'|'branches', array<string, TransportException>>
|
||||
*/
|
||||
public function getVersionTransportExceptions()
|
||||
public function getVersionTransportExceptions(): array
|
||||
{
|
||||
return $this->versionTransportExceptions;
|
||||
}
|
||||
|
@ -254,7 +254,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
}
|
||||
|
||||
try {
|
||||
if (!$data = $driver->getComposerInformation($identifier)) {
|
||||
$data = $driver->getComposerInformation($identifier);
|
||||
if (null === $data) {
|
||||
if ($isVeryVerbose) {
|
||||
$this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
|
||||
}
|
||||
|
@ -367,7 +368,8 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
|||
}
|
||||
|
||||
try {
|
||||
if (!$data = $driver->getComposerInformation($identifier)) {
|
||||
$data = $driver->getComposerInformation($identifier);
|
||||
if (null === $data) {
|
||||
if ($isVeryVerbose) {
|
||||
$this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class Event extends BaseEvent
|
|||
*
|
||||
* @return Composer
|
||||
*/
|
||||
public function getComposer()
|
||||
public function getComposer(): Composer
|
||||
{
|
||||
return $this->composer;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class Event extends BaseEvent
|
|||
*
|
||||
* @return IOInterface
|
||||
*/
|
||||
public function getIO()
|
||||
public function getIO(): IOInterface
|
||||
{
|
||||
return $this->io;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class Event extends BaseEvent
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDevMode()
|
||||
public function isDevMode(): bool
|
||||
{
|
||||
return $this->devMode;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class Git
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function runCommand(callable $commandCallable, string $url, ?string $cwd, bool $initialClone = false)
|
||||
public function runCommand(callable $commandCallable, string $url, ?string $cwd, bool $initialClone = false): void
|
||||
{
|
||||
// Ensure we are allowed to use this URL by config
|
||||
$this->config->prohibitUrlByConfig($url, $this->io);
|
||||
|
@ -272,7 +272,7 @@ class Git
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function syncMirror(string $url, string $dir)
|
||||
public function syncMirror(string $url, string $dir): bool
|
||||
{
|
||||
if (Platform::getEnv('COMPOSER_DISABLE_NETWORK') && Platform::getEnv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
|
||||
$this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
|
||||
|
@ -317,7 +317,7 @@ class Git
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function fetchRefOrSyncMirror(string $url, string $dir, string $ref)
|
||||
public function fetchRefOrSyncMirror(string $url, string $dir, string $ref): bool
|
||||
{
|
||||
if ($this->checkRefIsInMirror($dir, $ref)) {
|
||||
return true;
|
||||
|
@ -333,7 +333,7 @@ class Git
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getNoShowSignatureFlag(ProcessExecutor $process)
|
||||
public static function getNoShowSignatureFlag(ProcessExecutor $process): string
|
||||
{
|
||||
$gitVersion = self::getVersion($process);
|
||||
if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
|
||||
|
@ -395,7 +395,7 @@ class Git
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function cleanEnv()
|
||||
public static function cleanEnv(): void
|
||||
{
|
||||
// added in git 1.7.1, prevents prompting the user for username/password
|
||||
if (Platform::getEnv('GIT_ASKPASS') !== 'echo') {
|
||||
|
@ -458,7 +458,7 @@ class Git
|
|||
*
|
||||
* @return string|null The git version number, if present.
|
||||
*/
|
||||
public static function getVersion(ProcessExecutor $process)
|
||||
public static function getVersion(ProcessExecutor $process): ?string
|
||||
{
|
||||
if (false === self::$version) {
|
||||
self::$version = null;
|
||||
|
|
|
@ -85,7 +85,7 @@ class Perforce
|
|||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function create($repoConfig, string $port, string $path, ProcessExecutor $process, IOInterface $io)
|
||||
public static function create($repoConfig, string $port, string $path, ProcessExecutor $process, IOInterface $io): self
|
||||
{
|
||||
return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class Perforce
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkServerExists(string $url, ProcessExecutor $processExecutor)
|
||||
public static function checkServerExists(string $url, ProcessExecutor $processExecutor): bool
|
||||
{
|
||||
return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $ignoredOutput);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initialize($repoConfig)
|
||||
public function initialize($repoConfig): void
|
||||
{
|
||||
$this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
|
||||
if (!$repoConfig) {
|
||||
|
@ -138,7 +138,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initializeDepotAndBranch(?string $depot, ?string $branch)
|
||||
public function initializeDepotAndBranch(?string $depot, ?string $branch): void
|
||||
{
|
||||
if (isset($depot)) {
|
||||
$this->p4Depot = $depot;
|
||||
|
@ -159,7 +159,7 @@ class Perforce
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function cleanupClientSpec()
|
||||
public function cleanupClientSpec(): void
|
||||
{
|
||||
$client = $this->getClient();
|
||||
$task = 'client -d ' . ProcessExecutor::escape($client);
|
||||
|
@ -176,7 +176,7 @@ class Perforce
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function executeCommand($command)
|
||||
protected function executeCommand($command): int
|
||||
{
|
||||
$this->commandResult = '';
|
||||
|
||||
|
@ -186,7 +186,7 @@ class Perforce
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClient()
|
||||
public function getClient(): string
|
||||
{
|
||||
if (!isset($this->p4Client)) {
|
||||
$cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
|
||||
|
@ -199,7 +199,7 @@ class Perforce
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getPath()
|
||||
protected function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initializePath(string $path)
|
||||
public function initializePath(string $path): void
|
||||
{
|
||||
$this->path = $path;
|
||||
$fs = $this->getFilesystem();
|
||||
|
@ -219,7 +219,7 @@ class Perforce
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getPort()
|
||||
protected function getPort(): string
|
||||
{
|
||||
return $this->p4Port;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setStream(string $stream)
|
||||
public function setStream(string $stream): void
|
||||
{
|
||||
$this->p4Stream = $stream;
|
||||
$index = strrpos($stream, '/');
|
||||
|
@ -242,7 +242,7 @@ class Perforce
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isStream()
|
||||
public function isStream(): bool
|
||||
{
|
||||
return is_string($this->p4DepotType) && (strcmp($this->p4DepotType, 'stream') === 0);
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ class Perforce
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStream()
|
||||
public function getStream(): string
|
||||
{
|
||||
if (!isset($this->p4Stream)) {
|
||||
if ($this->isStream()) {
|
||||
|
@ -268,7 +268,7 @@ class Perforce
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStreamWithoutLabel(string $stream)
|
||||
public function getStreamWithoutLabel(string $stream): string
|
||||
{
|
||||
$index = strpos($stream, '@');
|
||||
if ($index === false) {
|
||||
|
@ -289,7 +289,7 @@ class Perforce
|
|||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUser()
|
||||
public function getUser(): ?string
|
||||
{
|
||||
return $this->p4User;
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUser(?string $user)
|
||||
public function setUser(?string $user): void
|
||||
{
|
||||
$this->p4User = $user;
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ class Perforce
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function queryP4User()
|
||||
public function queryP4User(): void
|
||||
{
|
||||
$this->getUser();
|
||||
if (strlen((string) $this->p4User) > 0) {
|
||||
|
@ -365,7 +365,7 @@ class Perforce
|
|||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function queryP4Password()
|
||||
public function queryP4Password(): ?string
|
||||
{
|
||||
if (isset($this->p4Password)) {
|
||||
return $this->p4Password;
|
||||
|
@ -400,7 +400,7 @@ class Perforce
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoggedIn()
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
$command = $this->generateP4Command('login -s', false);
|
||||
$exitCode = $this->executeCommand($command);
|
||||
|
@ -423,7 +423,7 @@ class Perforce
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function connectClient()
|
||||
public function connectClient(): void
|
||||
{
|
||||
$p4CreateClientCommand = $this->generateP4Command(
|
||||
'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
|
||||
|
@ -436,7 +436,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function syncCodeBase(?string $sourceReference)
|
||||
public function syncCodeBase(?string $sourceReference): void
|
||||
{
|
||||
$prevDir = Platform::getCwd();
|
||||
chdir($this->path);
|
||||
|
@ -453,7 +453,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function writeClientSpecToFile($spec)
|
||||
public function writeClientSpecToFile($spec): void
|
||||
{
|
||||
fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
|
||||
|
@ -479,7 +479,7 @@ class Perforce
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function writeP4ClientSpec()
|
||||
public function writeP4ClientSpec(): void
|
||||
{
|
||||
$clientSpec = $this->getP4ClientSpec();
|
||||
$spec = fopen($clientSpec, 'w');
|
||||
|
@ -498,7 +498,7 @@ class Perforce
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function read($pipe, $name)
|
||||
protected function read($pipe, $name): void
|
||||
{
|
||||
if (feof($pipe)) {
|
||||
return;
|
||||
|
@ -514,7 +514,7 @@ class Perforce
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function windowsLogin(?string $password)
|
||||
public function windowsLogin(?string $password): int
|
||||
{
|
||||
$command = $this->generateP4Command(' login -a');
|
||||
|
||||
|
@ -526,7 +526,7 @@ class Perforce
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function p4Login()
|
||||
public function p4Login(): void
|
||||
{
|
||||
$this->queryP4User();
|
||||
if (!$this->isLoggedIn()) {
|
||||
|
@ -546,14 +546,14 @@ class Perforce
|
|||
/**
|
||||
* @param string $identifier
|
||||
*
|
||||
* @return mixed|void
|
||||
* @return mixed[]|null
|
||||
*/
|
||||
public function getComposerInformation(string $identifier)
|
||||
public function getComposerInformation(string $identifier): ?array
|
||||
{
|
||||
$composerFileContent = $this->getFileContent('composer.json', $identifier);
|
||||
|
||||
if (!$composerFileContent) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
return json_decode($composerFileContent, true);
|
||||
|
@ -565,7 +565,7 @@ class Perforce
|
|||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFileContent(string $file, string $identifier)
|
||||
public function getFileContent(string $file, string $identifier): ?string
|
||||
{
|
||||
$path = $this->getFilePath($file, $identifier);
|
||||
|
||||
|
@ -586,7 +586,7 @@ class Perforce
|
|||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFilePath(string $file, string $identifier)
|
||||
public function getFilePath(string $file, string $identifier): ?string
|
||||
{
|
||||
$index = strpos($identifier, '@');
|
||||
if ($index === false) {
|
||||
|
@ -646,7 +646,7 @@ class Perforce
|
|||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getTags()
|
||||
public function getTags(): array
|
||||
{
|
||||
$command = $this->generateP4Command('labels');
|
||||
$this->executeCommand($command);
|
||||
|
@ -666,7 +666,7 @@ class Perforce
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkStream()
|
||||
public function checkStream(): bool
|
||||
{
|
||||
$command = $this->generateP4Command('depots', false);
|
||||
$this->executeCommand($command);
|
||||
|
@ -690,7 +690,7 @@ class Perforce
|
|||
* @param string $reference
|
||||
* @return mixed|null
|
||||
*/
|
||||
protected function getChangeList(string $reference)
|
||||
protected function getChangeList(string $reference): mixed
|
||||
{
|
||||
$index = strpos($reference, '@');
|
||||
if ($index === false) {
|
||||
|
@ -713,7 +713,7 @@ class Perforce
|
|||
* @param string $toReference
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getCommitLogs(string $fromReference, string $toReference)
|
||||
public function getCommitLogs(string $fromReference, string $toReference): mixed
|
||||
{
|
||||
$fromChangeList = $this->getChangeList($fromReference);
|
||||
if ($fromChangeList === null) {
|
||||
|
@ -734,7 +734,7 @@ class Perforce
|
|||
/**
|
||||
* @return Filesystem
|
||||
*/
|
||||
public function getFilesystem()
|
||||
public function getFilesystem(): Filesystem
|
||||
{
|
||||
if (null === $this->filesystem) {
|
||||
$this->filesystem = new Filesystem($this->process);
|
||||
|
@ -746,7 +746,7 @@ class Perforce
|
|||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setFilesystem(Filesystem $fs)
|
||||
public function setFilesystem(Filesystem $fs): void
|
||||
{
|
||||
$this->filesystem = $fs;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class ProcessExecutor
|
|||
* @param null|string $cwd the working directory
|
||||
* @return int statuscode
|
||||
*/
|
||||
public function execute($command, &$output = null, ?string $cwd = null)
|
||||
public function execute($command, &$output = null, ?string $cwd = null): int
|
||||
{
|
||||
if (func_num_args() > 1) {
|
||||
return $this->doExecute($command, $cwd, false, $output);
|
||||
|
@ -84,7 +84,7 @@ class ProcessExecutor
|
|||
* @param null|string $cwd the working directory
|
||||
* @return int statuscode
|
||||
*/
|
||||
public function executeTty($command, ?string $cwd = null)
|
||||
public function executeTty($command, ?string $cwd = null): int
|
||||
{
|
||||
if (Platform::isTty()) {
|
||||
return $this->doExecute($command, $cwd, true);
|
||||
|
@ -121,7 +121,10 @@ class ProcessExecutor
|
|||
}
|
||||
}
|
||||
|
||||
$callback = is_callable($output) ? $output : array($this, 'outputHandler');
|
||||
$callback = is_callable($output) ? $output : function (string $type, string $buffer): void {
|
||||
$this->outputHandler($type, $buffer);
|
||||
};
|
||||
|
||||
$process->run($callback);
|
||||
|
||||
if ($this->captureOutput && !is_callable($output)) {
|
||||
|
@ -140,7 +143,7 @@ class ProcessExecutor
|
|||
* @param string $cwd the working directory
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function executeAsync($command, ?string $cwd = null)
|
||||
public function executeAsync($command, ?string $cwd = null): PromiseInterface
|
||||
{
|
||||
if (!$this->allowAsync) {
|
||||
throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
|
||||
|
@ -206,6 +209,25 @@ class ProcessExecutor
|
|||
return $promise;
|
||||
}
|
||||
|
||||
protected function outputHandler(string $type, string $buffer): void
|
||||
{
|
||||
if ($this->captureOutput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null === $this->io) {
|
||||
echo $buffer;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Process::ERR === $type) {
|
||||
$this->io->writeErrorRaw($buffer, false);
|
||||
} else {
|
||||
$this->io->writeRaw($buffer, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return void
|
||||
|
@ -253,7 +275,7 @@ class ProcessExecutor
|
|||
* @param ?int $index job id
|
||||
* @return void
|
||||
*/
|
||||
public function wait($index = null)
|
||||
public function wait($index = null): void
|
||||
{
|
||||
while (true) {
|
||||
if (!$this->countActiveJobs($index)) {
|
||||
|
@ -324,7 +346,7 @@ class ProcessExecutor
|
|||
* @param null|string $output
|
||||
* @return string[]
|
||||
*/
|
||||
public function splitLines(?string $output)
|
||||
public function splitLines(?string $output): array
|
||||
{
|
||||
$output = trim((string) $output);
|
||||
|
||||
|
@ -336,42 +358,15 @@ class ProcessExecutor
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorOutput()
|
||||
public function getErrorOutput(): string
|
||||
{
|
||||
return $this->errorOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param Process::ERR|Process::OUT $type
|
||||
* @param string $buffer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function outputHandler($type, string $buffer)
|
||||
{
|
||||
if ($this->captureOutput) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null === $this->io) {
|
||||
echo $buffer;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Process::ERR === $type) {
|
||||
$this->io->writeErrorRaw($buffer, false);
|
||||
} else {
|
||||
$this->io->writeRaw($buffer, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int the timeout in seconds
|
||||
*/
|
||||
public static function getTimeout()
|
||||
public static function getTimeout(): int
|
||||
{
|
||||
return static::$timeout;
|
||||
}
|
||||
|
@ -380,7 +375,7 @@ class ProcessExecutor
|
|||
* @param int $timeout the timeout in seconds
|
||||
* @return void
|
||||
*/
|
||||
public static function setTimeout(int $timeout)
|
||||
public static function setTimeout(int $timeout): void
|
||||
{
|
||||
static::$timeout = $timeout;
|
||||
}
|
||||
|
@ -392,7 +387,7 @@ class ProcessExecutor
|
|||
*
|
||||
* @return string The escaped argument
|
||||
*/
|
||||
public static function escape($argument)
|
||||
public static function escape($argument): string
|
||||
{
|
||||
return self::escapeArgument($argument);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class InitCommandTest extends TestCase
|
|||
public function testParseValidAuthorString(): void
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$author = $command->parseAuthorString('John Smith <john@example.com>');
|
||||
$author = $this->callParseAuthorString($command, 'John Smith <john@example.com>');
|
||||
$this->assertEquals('John Smith', $author['name']);
|
||||
$this->assertEquals('john@example.com', $author['email']);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class InitCommandTest extends TestCase
|
|||
public function testParseValidAuthorStringWithoutEmail(): void
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$author = $command->parseAuthorString('John Smith');
|
||||
$author = $this->callParseAuthorString($command, 'John Smith');
|
||||
$this->assertEquals('John Smith', $author['name']);
|
||||
$this->assertNull($author['email']);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class InitCommandTest extends TestCase
|
|||
public function testParseValidUtf8AuthorString(): void
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$author = $command->parseAuthorString('Matti Meikäläinen <matti@example.com>');
|
||||
$author = $this->callParseAuthorString($command, 'Matti Meikäläinen <matti@example.com>');
|
||||
$this->assertEquals('Matti Meikäläinen', $author['name']);
|
||||
$this->assertEquals('matti@example.com', $author['email']);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class InitCommandTest extends TestCase
|
|||
// \xCC\x88 is UTF-8 for U+0308 diaeresis (umlaut) combining mark
|
||||
$utf8_expected = "Matti Meika\xCC\x88la\xCC\x88inen";
|
||||
$command = new InitCommand;
|
||||
$author = $command->parseAuthorString($utf8_expected." <matti@example.com>");
|
||||
$author = $this->callParseAuthorString($command, $utf8_expected." <matti@example.com>");
|
||||
$this->assertEquals($utf8_expected, $author['name']);
|
||||
$this->assertEquals('matti@example.com', $author['email']);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ class InitCommandTest extends TestCase
|
|||
public function testParseNumericAuthorString(): void
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$author = $command->parseAuthorString('h4x0r <h4x@example.com>');
|
||||
$author = $this->callParseAuthorString($command, 'h4x0r <h4x@example.com>');
|
||||
$this->assertEquals('h4x0r', $author['name']);
|
||||
$this->assertEquals('h4x@example.com', $author['email']);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class InitCommandTest extends TestCase
|
|||
public function testParseValidAlias1AuthorString(): void
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$author = $command->parseAuthorString(
|
||||
$author = $this->callParseAuthorString($command,
|
||||
'Johnathon "Johnny" Smith <john@example.com>'
|
||||
);
|
||||
$this->assertEquals('Johnathon "Johnny" Smith', $author['name']);
|
||||
|
@ -80,7 +80,7 @@ class InitCommandTest extends TestCase
|
|||
public function testParseValidAlias2AuthorString(): void
|
||||
{
|
||||
$command = new InitCommand;
|
||||
$author = $command->parseAuthorString(
|
||||
$author = $this->callParseAuthorString($command,
|
||||
'Johnathon (Johnny) Smith <john@example.com>'
|
||||
);
|
||||
$this->assertEquals('Johnathon (Johnny) Smith', $author['name']);
|
||||
|
@ -91,14 +91,14 @@ class InitCommandTest extends TestCase
|
|||
{
|
||||
$command = new InitCommand;
|
||||
self::expectException('InvalidArgumentException');
|
||||
$command->parseAuthorString('');
|
||||
$this->callParseAuthorString($command, '');
|
||||
}
|
||||
|
||||
public function testParseAuthorStringWithInvalidEmail(): void
|
||||
{
|
||||
$command = new InitCommand;
|
||||
self::expectException('InvalidArgumentException');
|
||||
$command->parseAuthorString('John Smith <john>');
|
||||
$this->callParseAuthorString($command, 'John Smith <john>');
|
||||
}
|
||||
|
||||
public function testNamespaceFromValidPackageName(): void
|
||||
|
@ -121,4 +121,15 @@ class InitCommandTest extends TestCase
|
|||
$namespace = $command->namespaceFromPackageName('');
|
||||
$this->assertNull($namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{name: string, email: string|null}
|
||||
*/
|
||||
private function callParseAuthorString(InitCommand $command, string $string): array
|
||||
{
|
||||
$reflMethod = new \ReflectionMethod($command, 'parseAuthorString');
|
||||
$reflMethod->setAccessible(true);
|
||||
|
||||
return $reflMethod->invoke($command, $string);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,7 +223,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -273,7 +274,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloaderSuccess
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -330,7 +332,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -366,7 +369,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -432,7 +436,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -469,7 +474,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -506,7 +512,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -567,7 +574,8 @@ class DownloadManagerTest extends TestCase
|
|||
$zipDownloader
|
||||
->expects($this->once())
|
||||
->method('update')
|
||||
->with($initial, $target, 'vendor/bundles/FOS/UserBundle');
|
||||
->with($initial, $target, 'vendor/bundles/FOS/UserBundle')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
$zipDownloader
|
||||
->expects($this->any())
|
||||
->method('getInstallationSource')
|
||||
|
@ -605,7 +613,8 @@ class DownloadManagerTest extends TestCase
|
|||
$xzDownloader
|
||||
->expects($this->once())
|
||||
->method('remove')
|
||||
->with($initial, 'vendor/bundles/FOS/UserBundle');
|
||||
->with($initial, 'vendor/bundles/FOS/UserBundle')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
$xzDownloader
|
||||
->expects($this->any())
|
||||
->method('getInstallationSource')
|
||||
|
@ -615,7 +624,8 @@ class DownloadManagerTest extends TestCase
|
|||
$zipDownloader
|
||||
->expects($this->once())
|
||||
->method('install')
|
||||
->with($target, 'vendor/bundles/FOS/UserBundle');
|
||||
->with($target, 'vendor/bundles/FOS/UserBundle')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
$zipDownloader
|
||||
->expects($this->any())
|
||||
->method('getInstallationSource')
|
||||
|
@ -775,7 +785,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -818,7 +829,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -864,7 +876,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -911,7 +924,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -958,7 +972,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -1005,7 +1020,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -1048,7 +1064,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
@ -1091,7 +1108,8 @@ class DownloadManagerTest extends TestCase
|
|||
$downloader
|
||||
->expects($this->once())
|
||||
->method('download')
|
||||
->with($package, 'target_dir');
|
||||
->with($package, 'target_dir')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$manager = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->setConstructorArgs(array($this->io, false, $this->filesystem))
|
||||
|
|
|
@ -335,7 +335,7 @@ class ZipDownloaderTest extends TestCase
|
|||
|
||||
class MockedZipDownloader extends ZipDownloader
|
||||
{
|
||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true): ?PromiseInterface
|
||||
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true): PromiseInterface
|
||||
{
|
||||
return \React\Promise\resolve();
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ class MockedZipDownloader extends ZipDownloader
|
|||
return \React\Promise\resolve();
|
||||
}
|
||||
|
||||
public function extract(PackageInterface $package, $file, $path): ?PromiseInterface
|
||||
public function extract(PackageInterface $package, $file, $path): PromiseInterface
|
||||
{
|
||||
return parent::extract($package, $file, $path);
|
||||
}
|
||||
|
|
|
@ -151,7 +151,8 @@ class LibraryInstallerTest extends TestCase
|
|||
$this->dm
|
||||
->expects($this->once())
|
||||
->method('install')
|
||||
->with($package, $this->vendorDir.'/some/package');
|
||||
->with($package, $this->vendorDir.'/some/package')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$this->repository
|
||||
->expects($this->once())
|
||||
|
@ -190,7 +191,8 @@ class LibraryInstallerTest extends TestCase
|
|||
$this->dm
|
||||
->expects($this->once())
|
||||
->method('update')
|
||||
->with($initial, $target, $this->vendorDir.'/vendor/package1/newtarget');
|
||||
->with($initial, $target, $this->vendorDir.'/vendor/package1/newtarget')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$this->repository
|
||||
->expects($this->once())
|
||||
|
@ -226,7 +228,8 @@ class LibraryInstallerTest extends TestCase
|
|||
$this->dm
|
||||
->expects($this->once())
|
||||
->method('remove')
|
||||
->with($package, $this->vendorDir.'/vendor/pkg');
|
||||
->with($package, $this->vendorDir.'/vendor/pkg')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$this->repository
|
||||
->expects($this->once())
|
||||
|
|
|
@ -135,7 +135,9 @@ class ProcessExecutorMock extends ProcessExecutor
|
|||
$this->captureOutput = func_num_args() > 3;
|
||||
$this->errorOutput = '';
|
||||
|
||||
$callback = is_callable($output) ? $output : array($this, 'outputHandler');
|
||||
$callback = is_callable($output) ? $output : function (string $type, string $buffer): void {
|
||||
$this->outputHandler($type, $buffer);
|
||||
};
|
||||
|
||||
$commandString = is_array($command) ? implode(' ', $command) : $command;
|
||||
$this->log[] = $commandString;
|
||||
|
|
|
@ -23,32 +23,21 @@ class ArrayDumperTest extends TestCase
|
|||
* @var ArrayDumper
|
||||
*/
|
||||
private $dumper;
|
||||
/**
|
||||
* @var \Composer\Package\CompletePackageInterface|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $package;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->dumper = new ArrayDumper();
|
||||
$this->package = $this->getMockBuilder('Composer\Package\CompletePackageInterface')->getMock();
|
||||
$this->packageExpects('getTransportOptions', array());
|
||||
}
|
||||
|
||||
public function testRequiredInformation(): void
|
||||
{
|
||||
$this
|
||||
->packageExpects('getPrettyName', 'foo')
|
||||
->packageExpects('getPrettyVersion', '1.0')
|
||||
->packageExpects('getVersion', '1.0.0.0')
|
||||
;
|
||||
|
||||
$config = $this->dumper->dump($this->package);
|
||||
$config = $this->dumper->dump($this->getPackage());
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'name' => 'foo',
|
||||
'version' => '1.0',
|
||||
'name' => 'dummy/pkg',
|
||||
'version' => '1.0.0',
|
||||
'version_normalized' => '1.0.0.0',
|
||||
'type' => 'library',
|
||||
),
|
||||
$config
|
||||
);
|
||||
|
@ -56,33 +45,27 @@ class ArrayDumperTest extends TestCase
|
|||
|
||||
public function testRootPackage(): void
|
||||
{
|
||||
$this->package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
|
||||
$package = $this->getRootPackage();
|
||||
$package->setMinimumStability('dev');
|
||||
|
||||
$this
|
||||
->packageExpects('getMinimumStability', 'dev')
|
||||
->packageExpects('getTransportOptions', array())
|
||||
;
|
||||
|
||||
$config = $this->dumper->dump($this->package);
|
||||
$config = $this->dumper->dump($package);
|
||||
$this->assertSame('dev', $config['minimum-stability']);
|
||||
}
|
||||
|
||||
public function testDumpAbandoned(): void
|
||||
{
|
||||
$this->packageExpects('isAbandoned', true);
|
||||
$this->packageExpects('getReplacementPackage', true);
|
||||
|
||||
$config = $this->dumper->dump($this->package);
|
||||
$package = $this->getPackage();
|
||||
$package->setAbandoned(true);
|
||||
$config = $this->dumper->dump($package);
|
||||
|
||||
$this->assertTrue($config['abandoned']);
|
||||
}
|
||||
|
||||
public function testDumpAbandonedReplacement(): void
|
||||
{
|
||||
$this->packageExpects('isAbandoned', true);
|
||||
$this->packageExpects('getReplacementPackage', 'foo/bar');
|
||||
|
||||
$config = $this->dumper->dump($this->package);
|
||||
$package = $this->getPackage();
|
||||
$package->setAbandoned('foo/bar');
|
||||
$config = $this->dumper->dump($package);
|
||||
|
||||
$this->assertSame('foo/bar', $config['abandoned']);
|
||||
}
|
||||
|
@ -97,16 +80,12 @@ class ArrayDumperTest extends TestCase
|
|||
*/
|
||||
public function testKeys(string $key, $value, string $method = null, $expectedValue = null): void
|
||||
{
|
||||
$this->package = $this->getMockBuilder('Composer\Package\RootPackageInterface')->getMock();
|
||||
$package = $this->getRootPackage();
|
||||
|
||||
$this->packageExpects('get'.ucfirst($method ?: $key), $value);
|
||||
$this->packageExpects('isAbandoned', $value);
|
||||
// @phpstan-ignore-next-line
|
||||
$package->{'set'.ucfirst($method ?: $key)}($value);
|
||||
|
||||
if ($method !== 'transportOptions') {
|
||||
$this->packageExpects('getTransportOptions', array());
|
||||
}
|
||||
|
||||
$config = $this->dumper->dump($this->package);
|
||||
$config = $this->dumper->dump($package);
|
||||
|
||||
$this->assertSame($expectedValue ?: $value, $config[$key]);
|
||||
}
|
||||
|
@ -177,13 +156,13 @@ class ArrayDumperTest extends TestCase
|
|||
),
|
||||
array(
|
||||
'require',
|
||||
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
|
||||
array('foo/bar' => new Link('dummy/pkg', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
|
||||
'requires',
|
||||
array('foo/bar' => '1.0.0'),
|
||||
),
|
||||
array(
|
||||
'require-dev',
|
||||
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_DEV_REQUIRE, '1.0.0')),
|
||||
array('foo/bar' => new Link('dummy/pkg', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_DEV_REQUIRE, '1.0.0')),
|
||||
'devRequires',
|
||||
array('foo/bar' => '1.0.0'),
|
||||
),
|
||||
|
@ -202,13 +181,19 @@ class ArrayDumperTest extends TestCase
|
|||
),
|
||||
array(
|
||||
'require',
|
||||
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
|
||||
array(
|
||||
'foo/bar' => new Link('dummy/pkg', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
'bar/baz' => new Link('dummy/pkg', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
),
|
||||
'requires',
|
||||
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
|
||||
),
|
||||
array(
|
||||
'require-dev',
|
||||
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
|
||||
array(
|
||||
'foo/bar' => new Link('dummy/pkg', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
'bar/baz' => new Link('dummy/pkg', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
),
|
||||
'devRequires',
|
||||
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
|
||||
),
|
||||
|
@ -220,19 +205,28 @@ class ArrayDumperTest extends TestCase
|
|||
),
|
||||
array(
|
||||
'provide',
|
||||
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
|
||||
array(
|
||||
'foo/bar' => new Link('dummy/pkg', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
'bar/baz' => new Link('dummy/pkg', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
),
|
||||
'provides',
|
||||
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
|
||||
),
|
||||
array(
|
||||
'replace',
|
||||
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
|
||||
array(
|
||||
'foo/bar' => new Link('dummy/pkg', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
'bar/baz' => new Link('dummy/pkg', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
),
|
||||
'replaces',
|
||||
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
|
||||
),
|
||||
array(
|
||||
'conflict',
|
||||
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
|
||||
array(
|
||||
'foo/bar' => new Link('dummy/pkg', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
'bar/baz' => new Link('dummy/pkg', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'),
|
||||
),
|
||||
'conflicts',
|
||||
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
|
||||
),
|
||||
|
@ -243,18 +237,4 @@ class ArrayDumperTest extends TestCase
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param mixed $value
|
||||
*/
|
||||
private function packageExpects(string $method, $value): ArrayDumperTest
|
||||
{
|
||||
$this->package
|
||||
->expects($this->any())
|
||||
->method($method)
|
||||
->will($this->returnValue($value));
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,41 +93,8 @@ class LockerTest extends TestCase
|
|||
$jsonContent = $this->getJsonContent() . ' ';
|
||||
$locker = new Locker(new NullIO, $json, $inst, $jsonContent);
|
||||
|
||||
$package1 = $this->createPackageMock();
|
||||
$package2 = $this->createPackageMock();
|
||||
|
||||
$package1
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getPrettyName')
|
||||
->will($this->returnValue('pkg1'));
|
||||
$package1
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getPrettyVersion')
|
||||
->will($this->returnValue('1.0.0-beta'));
|
||||
$package1
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getVersion')
|
||||
->will($this->returnValue('1.0.0.0-beta'));
|
||||
|
||||
$package2
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getPrettyName')
|
||||
->will($this->returnValue('pkg2'));
|
||||
$package2
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getPrettyVersion')
|
||||
->will($this->returnValue('0.1.10'));
|
||||
$package2
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getVersion')
|
||||
->will($this->returnValue('0.1.10.0'));
|
||||
|
||||
foreach (array($package1, $package2) as $package) {
|
||||
$package
|
||||
->expects($this->atLeastOnce())
|
||||
->method('getTransportOptions')
|
||||
->will($this->returnValue(array()));
|
||||
}
|
||||
$package1 = $this->getPackage('pkg1', '1.0.0-beta');
|
||||
$package2 = $this->getPackage('pkg2', '0.1.10');
|
||||
|
||||
$contentHash = md5(trim($jsonContent));
|
||||
|
||||
|
@ -140,8 +107,8 @@ class LockerTest extends TestCase
|
|||
'This file is @gener'.'ated automatically', ),
|
||||
'content-hash' => $contentHash,
|
||||
'packages' => array(
|
||||
array('name' => 'pkg1', 'version' => '1.0.0-beta'),
|
||||
array('name' => 'pkg2', 'version' => '0.1.10'),
|
||||
array('name' => 'pkg1', 'version' => '1.0.0-beta', 'type' => 'library'),
|
||||
array('name' => 'pkg2', 'version' => '0.1.10', 'type' => 'library'),
|
||||
),
|
||||
'packages-dev' => array(),
|
||||
'aliases' => array(),
|
||||
|
|
|
@ -83,6 +83,15 @@ class PluginInstallerTest extends TestCase
|
|||
$dm = $this->getMockBuilder('Composer\Downloader\DownloadManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$dm->expects($this->any())
|
||||
->method('install')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
$dm->expects($this->any())
|
||||
->method('update')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
$dm->expects($this->any())
|
||||
->method('remove')
|
||||
->will($this->returnValue(\React\Promise\resolve()));
|
||||
|
||||
$this->repository = $this->getMockBuilder('Composer\Repository\InstalledRepositoryInterface')->getMock();
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ class GitHubDriverTest extends TestCase
|
|||
|
||||
$data = $gitHubDriver->getComposerInformation($identifier);
|
||||
|
||||
$this->assertIsArray($data);
|
||||
$this->assertArrayNotHasKey('abandoned', $data);
|
||||
}
|
||||
|
||||
|
@ -230,6 +231,7 @@ class GitHubDriverTest extends TestCase
|
|||
|
||||
$data = $gitHubDriver->getComposerInformation($sha);
|
||||
|
||||
$this->assertIsArray($data);
|
||||
$this->assertTrue($data['abandoned']);
|
||||
}
|
||||
|
||||
|
|
|
@ -377,8 +377,7 @@ class AuthHelperTest extends TestCase
|
|||
|
||||
$configSource->expects($this->once())
|
||||
->method('addConfigSetting')
|
||||
->with('http-basic.'.$origin, $auth)
|
||||
->willReturn($configSource);
|
||||
->with('http-basic.'.$origin, $auth);
|
||||
|
||||
$this->authHelper->storeAuth($origin, $storeAuth);
|
||||
}
|
||||
|
@ -429,8 +428,7 @@ class AuthHelperTest extends TestCase
|
|||
|
||||
$configSource->expects($this->once())
|
||||
->method('addConfigSetting')
|
||||
->with('http-basic.'.$origin, $auth)
|
||||
->willReturn($configSource);
|
||||
->with('http-basic.'.$origin, $auth);
|
||||
|
||||
$this->authHelper->storeAuth($origin, $storeAuth);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue