1
0
Fork 0

Add return types to all code which is not being extended by open source packages

pull/10547/head
Jordi Boggiano 2022-02-18 14:32:38 +01:00
parent 137ebddc25
commit eda9014bef
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
121 changed files with 606 additions and 603 deletions

View File

@ -61,7 +61,7 @@ class ClassMapGenerator
* @return array<class-string, string> A class map array
* @throws \RuntimeException When the path is neither an existing file nor directory
*/
public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array()): array
{
$basePath = $path;
if (is_string($path)) {

View File

@ -50,7 +50,7 @@ class BaseDependencyCommand extends BaseCommand
* @param bool $inverted Whether to invert matching process (why-not vs why behaviour)
* @return int Exit code of the operation.
*/
protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false): int
{
// Emit command event on startup
$composer = $this->requireComposer();

View File

@ -187,7 +187,7 @@ EOT
* @return int
* @throws \Exception
*/
public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName = null, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $noInstall = false, PlatformRequirementFilterInterface $platformRequirementFilter = null, $secureHttp = true, $addRepository = false)
public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName = null, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $noInstall = false, PlatformRequirementFilterInterface $platformRequirementFilter = null, $secureHttp = true, $addRepository = false): int
{
$oldCwd = getcwd();
@ -350,7 +350,7 @@ EOT
* @return bool
* @throws \Exception
*/
protected function installRootPackage(IOInterface $io, Config $config, $packageName, PlatformRequirementFilterInterface $platformRequirementFilter, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, array $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $secureHttp = true)
protected function installRootPackage(IOInterface $io, Config $config, $packageName, PlatformRequirementFilterInterface $platformRequirementFilter, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, array $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $secureHttp = true): bool
{
if (!$secureHttp) {
$config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);

View File

@ -121,7 +121,7 @@ EOT
/**
* @inheritDoc
*/
public function isProxyCommand()
public function isProxyCommand(): bool
{
return true;
}

View File

@ -191,7 +191,7 @@ EOT
* @param array<string, PackageInterface> $bucket the list to add packages to
* @return array<string, PackageInterface>
*/
public function appendPackages(array $packages, array $bucket)
public function appendPackages(array $packages, array $bucket): array
{
foreach ($packages as $package) {
$bucket[$package->getName()] = $package;

View File

@ -105,7 +105,7 @@ EOT
/**
* @inheritDoc
*/
public function isProxyCommand()
public function isProxyCommand(): bool
{
return true;
}

View File

@ -42,7 +42,7 @@ trait PackageDiscoveryTrait
/**
* @return CompositeRepository
*/
protected function getRepos()
protected function getRepos(): CompositeRepository
{
if (null === $this->repos) {
$this->repos = new CompositeRepository(array_merge(

View File

@ -112,7 +112,7 @@ EOT
/**
* @return int
*/
protected function listScripts(OutputInterface $output)
protected function listScripts(OutputInterface $output): int
{
$scripts = $this->requireComposer()->getPackage()->getScripts();

View File

@ -397,7 +397,7 @@ TAGSPUBKEY
* @return int
* @throws FilesystemException
*/
protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
protected function rollback(OutputInterface $output, $rollbackDir, $localFilename): int
{
$rollbackVersion = $this->getLastBackupVersion($rollbackDir);
if (!$rollbackVersion) {
@ -431,7 +431,7 @@ TAGSPUBKEY
* @throws FilesystemException If the file cannot be moved
* @return bool Whether the phar is valid and has been moved
*/
protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null): bool
{
$io = $this->getIO();
@chmod($newFilename, fileperms($localFilename));
@ -520,7 +520,7 @@ TAGSPUBKEY
* @param string $rollbackDir
* @return Finder
*/
protected function getOldInstallationFinder($rollbackDir)
protected function getOldInstallationFinder($rollbackDir): Finder
{
return Finder::create()
->depth(0)
@ -541,7 +541,7 @@ TAGSPUBKEY
* @throws \Exception
* @return bool If the operation succeeded
*/
protected function validatePhar($pharFile, &$error)
protected function validatePhar($pharFile, &$error): bool
{
if (ini_get('phar.readonly')) {
return true;
@ -569,7 +569,7 @@ TAGSPUBKEY
*
* @return bool
*/
protected function isWindowsNonAdminUser()
protected function isWindowsNonAdminUser(): bool
{
if (!Platform::isWindows()) {
return false;
@ -590,7 +590,7 @@ TAGSPUBKEY
* @param string $newFilename The downloaded or backup phar
* @return bool Whether composer.phar has been updated
*/
protected function tryAsWindowsAdmin($localFilename, $newFilename)
protected function tryAsWindowsAdmin($localFilename, $newFilename): bool
{
$io = $this->getIO();

View File

@ -71,7 +71,7 @@ class Composer
/**
* @return string
*/
public static function getVersion()
public static function getVersion(): string
{
// no replacement done, this must be a source checkout
if (self::VERSION === '@package_version'.'@') {
@ -92,7 +92,7 @@ class Composer
private $package;
/**
* @var ?Locker
* @var Locker|null
*/
private $locker = null;
@ -107,9 +107,9 @@ class Composer
private $repositoryManager;
/**
* @var Downloader\DownloadManager
* @var Downloader\DownloadManager|null
*/
private $downloadManager;
private $downloadManager = null;
/**
* @var Installer\InstallationManager
@ -117,9 +117,9 @@ class Composer
private $installationManager;
/**
* @var Plugin\PluginManager
* @var Plugin\PluginManager|null
*/
private $pluginManager;
private $pluginManager = null;
/**
* @var Config
@ -132,14 +132,14 @@ class Composer
private $eventDispatcher;
/**
* @var Autoload\AutoloadGenerator
* @var Autoload\AutoloadGenerator|null
*/
private $autoloadGenerator;
private $autoloadGenerator = null;
/**
* @var ArchiveManager
* @var ArchiveManager|null
*/
private $archiveManager;
private $archiveManager = null;
/**
* @return void
@ -152,7 +152,7 @@ class Composer
/**
* @return RootPackageInterface
*/
public function getPackage()
public function getPackage(): RootPackageInterface
{
return $this->package;
}
@ -168,7 +168,7 @@ class Composer
/**
* @return Config
*/
public function getConfig()
public function getConfig(): Config
{
return $this->config;
}
@ -184,7 +184,7 @@ class Composer
/**
* @return ?Locker
*/
public function getLocker()
public function getLocker(): ?Locker
{
return $this->locker;
}
@ -200,7 +200,7 @@ class Composer
/**
* @return Loop
*/
public function getLoop()
public function getLoop(): Loop
{
return $this->loop;
}
@ -216,7 +216,7 @@ class Composer
/**
* @return RepositoryManager
*/
public function getRepositoryManager()
public function getRepositoryManager(): RepositoryManager
{
return $this->repositoryManager;
}
@ -229,10 +229,7 @@ class Composer
$this->downloadManager = $manager;
}
/**
* @return DownloadManager
*/
public function getDownloadManager()
public function getDownloadManager(): ?DownloadManager
{
return $this->downloadManager;
}
@ -245,10 +242,7 @@ class Composer
$this->archiveManager = $manager;
}
/**
* @return ArchiveManager
*/
public function getArchiveManager()
public function getArchiveManager(): ?ArchiveManager
{
return $this->archiveManager;
}
@ -264,7 +258,7 @@ class Composer
/**
* @return InstallationManager
*/
public function getInstallationManager()
public function getInstallationManager(): InstallationManager
{
return $this->installationManager;
}
@ -277,10 +271,7 @@ class Composer
$this->pluginManager = $manager;
}
/**
* @return PluginManager
*/
public function getPluginManager()
public function getPluginManager(): ?PluginManager
{
return $this->pluginManager;
}
@ -296,7 +287,7 @@ class Composer
/**
* @return EventDispatcher
*/
public function getEventDispatcher()
public function getEventDispatcher(): EventDispatcher
{
return $this->eventDispatcher;
}
@ -309,10 +300,7 @@ class Composer
$this->autoloadGenerator = $autoloadGenerator;
}
/**
* @return AutoloadGenerator
*/
public function getAutoloadGenerator()
public function getAutoloadGenerator(): ?AutoloadGenerator
{
return $this->autoloadGenerator;
}

View File

@ -148,7 +148,7 @@ class Config
/**
* @return ConfigSourceInterface
*/
public function getConfigSource()
public function getConfigSource(): ConfigSourceInterface
{
return $this->configSource;
}
@ -164,7 +164,7 @@ class Config
/**
* @return ConfigSourceInterface
*/
public function getAuthConfigSource()
public function getAuthConfigSource(): ConfigSourceInterface
{
return $this->authConfigSource;
}
@ -263,7 +263,7 @@ class Config
/**
* @return array<int|string, mixed>
*/
public function getRepositories()
public function getRepositories(): array
{
return $this->repositories;
}
@ -441,7 +441,7 @@ class Config
*
* @return array<string, mixed[]>
*/
public function all($flags = 0)
public function all($flags = 0): array
{
$all = array(
'repositories' => $this->getRepositories(),
@ -457,7 +457,7 @@ class Config
* @param string $key
* @return string
*/
public function getSourceOfValue($key)
public function getSourceOfValue($key): string
{
$this->get($key);
@ -485,7 +485,7 @@ class Config
/**
* @return array<string, mixed[]>
*/
public function raw()
public function raw(): array
{
return array(
'repositories' => $this->getRepositories(),
@ -499,7 +499,7 @@ class Config
* @param string $key
* @return bool
*/
public function has($key)
public function has($key): bool
{
return array_key_exists($key, $this->config);
}

View File

@ -56,7 +56,7 @@ class Decisions implements \Iterator, \Countable
* @param int $literal
* @return bool
*/
public function satisfy($literal)
public function satisfy($literal): bool
{
$packageId = abs($literal);
@ -70,7 +70,7 @@ class Decisions implements \Iterator, \Countable
* @param int $literal
* @return bool
*/
public function conflict($literal)
public function conflict($literal): bool
{
$packageId = abs($literal);
@ -84,7 +84,7 @@ class Decisions implements \Iterator, \Countable
* @param int $literalOrPackageId
* @return bool
*/
public function decided($literalOrPackageId)
public function decided($literalOrPackageId): bool
{
return !empty($this->decisionMap[abs($literalOrPackageId)]);
}
@ -93,7 +93,7 @@ class Decisions implements \Iterator, \Countable
* @param int $literalOrPackageId
* @return bool
*/
public function undecided($literalOrPackageId)
public function undecided($literalOrPackageId): bool
{
return empty($this->decisionMap[abs($literalOrPackageId)]);
}
@ -102,7 +102,7 @@ class Decisions implements \Iterator, \Countable
* @param int $literalOrPackageId
* @return bool
*/
public function decidedInstall($literalOrPackageId)
public function decidedInstall($literalOrPackageId): bool
{
$packageId = abs($literalOrPackageId);
@ -113,7 +113,7 @@ class Decisions implements \Iterator, \Countable
* @param int $literalOrPackageId
* @return int
*/
public function decisionLevel($literalOrPackageId)
public function decisionLevel($literalOrPackageId): int
{
$packageId = abs($literalOrPackageId);
if (isset($this->decisionMap[$packageId])) {
@ -127,7 +127,7 @@ class Decisions implements \Iterator, \Countable
* @param int $literalOrPackageId
* @return Rule|null
*/
public function decisionRule($literalOrPackageId)
public function decisionRule($literalOrPackageId): ?Rule
{
$packageId = abs($literalOrPackageId);
@ -144,7 +144,7 @@ class Decisions implements \Iterator, \Countable
* @param int $queueOffset
* @return array{0: int, 1: Rule} a literal and decision reason
*/
public function atOffset($queueOffset)
public function atOffset($queueOffset): array
{
return $this->decisionQueue[$queueOffset];
}
@ -153,7 +153,7 @@ class Decisions implements \Iterator, \Countable
* @param int $queueOffset
* @return bool
*/
public function validOffset($queueOffset)
public function validOffset($queueOffset): bool
{
return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
}
@ -161,7 +161,7 @@ class Decisions implements \Iterator, \Countable
/**
* @return Rule
*/
public function lastReason()
public function lastReason(): Rule
{
return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
}
@ -169,7 +169,7 @@ class Decisions implements \Iterator, \Countable
/**
* @return int
*/
public function lastLiteral()
public function lastLiteral(): int
{
return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
}
@ -242,7 +242,7 @@ class Decisions implements \Iterator, \Countable
/**
* @return bool
*/
public function isEmpty()
public function isEmpty(): bool
{
return \count($this->decisionQueue) === 0;
}
@ -275,7 +275,7 @@ class Decisions implements \Iterator, \Countable
/**
* @return string
*/
public function toString(Pool $pool = null)
public function toString(Pool $pool = null): string
{
$decisionMap = $this->decisionMap;
ksort($decisionMap);

View File

@ -44,7 +44,7 @@ class DefaultPolicy implements PolicyInterface
*
* @phpstan-param Constraint::STR_OP_* $operator
*/
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator): bool
{
if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
@ -61,7 +61,7 @@ class DefaultPolicy implements PolicyInterface
* @param string $requiredPackage
* @return int[]
*/
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null): array
{
$packages = $this->groupLiteralsByName($pool, $literals);
@ -90,7 +90,7 @@ class DefaultPolicy implements PolicyInterface
* @param int[] $literals
* @return array<string, int[]>
*/
protected function groupLiteralsByName(Pool $pool, $literals)
protected function groupLiteralsByName(Pool $pool, $literals): array
{
$packages = array();
foreach ($literals as $literal) {
@ -111,7 +111,7 @@ class DefaultPolicy implements PolicyInterface
* @param bool $ignoreReplace
* @return int
*/
public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, $requiredPackage = null, $ignoreReplace = false)
public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, $requiredPackage = null, $ignoreReplace = false): int
{
// prefer aliases to the original package
if ($a->getName() === $b->getName()) {
@ -164,7 +164,7 @@ class DefaultPolicy implements PolicyInterface
*
* @return bool
*/
protected function replaces(BasePackage $source, BasePackage $target)
protected function replaces(BasePackage $source, BasePackage $target): bool
{
foreach ($source->getReplaces() as $link) {
if ($link->getTarget() === $target->getName()
@ -182,7 +182,7 @@ class DefaultPolicy implements PolicyInterface
* @param int[] $literals
* @return int[]
*/
protected function pruneToBestVersion(Pool $pool, $literals)
protected function pruneToBestVersion(Pool $pool, $literals): array
{
$operator = $this->preferLowest ? '<' : '>';
$bestLiterals = array($literals[0]);
@ -213,7 +213,7 @@ class DefaultPolicy implements PolicyInterface
* @param int[] $literals
* @return int[]
*/
protected function pruneRemoteAliases(Pool $pool, array $literals)
protected function pruneRemoteAliases(Pool $pool, array $literals): array
{
$hasLocalAlias = false;

View File

@ -36,7 +36,7 @@ class GenericRule extends Rule
/**
* @return int[]
*/
public function getLiterals()
public function getLiterals(): array
{
return $this->literals;
}
@ -59,7 +59,7 @@ class GenericRule extends Rule
* @param Rule $rule The rule to check against
* @return bool Whether the rules are equal
*/
public function equals(Rule $rule)
public function equals(Rule $rule): bool
{
return $this->literals === $rule->getLiterals();
}
@ -67,7 +67,7 @@ class GenericRule extends Rule
/**
* @return bool
*/
public function isAssertion()
public function isAssertion(): bool
{
return 1 === \count($this->literals);
}

View File

@ -42,7 +42,7 @@ class MultiConflictRule extends Rule
/**
* @return int[]
*/
public function getLiterals()
public function getLiterals(): array
{
return $this->literals;
}
@ -65,7 +65,7 @@ class MultiConflictRule extends Rule
* @param Rule $rule The rule to check against
* @return bool Whether the rules are equal
*/
public function equals(Rule $rule)
public function equals(Rule $rule): bool
{
if ($rule instanceof MultiConflictRule) {
return $this->literals === $rule->getLiterals();
@ -77,7 +77,7 @@ class MultiConflictRule extends Rule
/**
* @return bool
*/
public function isAssertion()
public function isAssertion(): bool
{
return false;
}

View File

@ -38,7 +38,7 @@ class MarkAliasInstalledOperation extends SolverOperation implements OperationIn
*
* @return AliasPackage
*/
public function getPackage()
public function getPackage(): AliasPackage
{
return $this->package;
}
@ -46,7 +46,7 @@ class MarkAliasInstalledOperation extends SolverOperation implements OperationIn
/**
* @inheritDoc
*/
public function show($lock)
public function show($lock): string
{
return 'Marking <info>'.$this->package->getPrettyName().'</info> (<comment>'.$this->package->getFullPrettyVersion().'</comment>) as installed, alias of <info>'.$this->package->getAliasOf()->getPrettyName().'</info> (<comment>'.$this->package->getAliasOf()->getFullPrettyVersion().'</comment>)';
}

View File

@ -38,7 +38,7 @@ class MarkAliasUninstalledOperation extends SolverOperation implements Operation
*
* @return AliasPackage
*/
public function getPackage()
public function getPackage(): AliasPackage
{
return $this->package;
}
@ -46,7 +46,7 @@ class MarkAliasUninstalledOperation extends SolverOperation implements Operation
/**
* @inheritDoc
*/
public function show($lock)
public function show($lock): string
{
return 'Marking <info>'.$this->package->getPrettyName().'</info> (<comment>'.$this->package->getFullPrettyVersion().'</comment>) as uninstalled, alias of <info>'.$this->package->getAliasOf()->getPrettyName().'</info> (<comment>'.$this->package->getAliasOf()->getFullPrettyVersion().'</comment>)';
}

View File

@ -38,7 +38,7 @@ class UninstallOperation extends SolverOperation implements OperationInterface
*
* @return PackageInterface
*/
public function getPackage()
public function getPackage(): PackageInterface
{
return $this->package;
}
@ -46,7 +46,7 @@ class UninstallOperation 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 UninstallOperation extends SolverOperation implements OperationInterface
* @param bool $lock
* @return string
*/
public static function format(PackageInterface $package, $lock = false)
public static function format(PackageInterface $package, $lock = false): string
{
return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
}

View File

@ -49,7 +49,7 @@ class UpdateOperation extends SolverOperation implements OperationInterface
*
* @return PackageInterface
*/
public function getInitialPackage()
public function getInitialPackage(): PackageInterface
{
return $this->initialPackage;
}
@ -59,7 +59,7 @@ class UpdateOperation extends SolverOperation implements OperationInterface
*
* @return PackageInterface
*/
public function getTargetPackage()
public function getTargetPackage(): PackageInterface
{
return $this->targetPackage;
}
@ -67,7 +67,7 @@ class UpdateOperation extends SolverOperation implements OperationInterface
/**
* @inheritDoc
*/
public function show($lock)
public function show($lock): string
{
return self::format($this->initialPackage, $this->targetPackage, $lock);
}
@ -76,7 +76,7 @@ class UpdateOperation extends SolverOperation implements OperationInterface
* @param bool $lock
* @return string
*/
public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false): string
{
$fromVersion = $initialPackage->getFullPrettyVersion();
$toVersion = $targetPackage->getFullPrettyVersion();

View File

@ -26,12 +26,12 @@ interface PolicyInterface
*
* @phpstan-param Constraint::STR_OP_* $operator
*/
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator): bool;
/**
* @param int[] $literals
* @param ?string $requiredPackage
* @return int[]
*/
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null): array;
}

View File

@ -60,7 +60,7 @@ class Pool implements \Countable
* @param string $name
* @return array<string, string>
*/
public function getRemovedVersions($name, ConstraintInterface $constraint)
public function getRemovedVersions($name, ConstraintInterface $constraint): array
{
if (!isset($this->removedVersions[$name])) {
return array();
@ -80,7 +80,7 @@ class Pool implements \Countable
* @param string $objectHash
* @return array<string, string>
*/
public function getRemovedVersionsByPackage($objectHash)
public function getRemovedVersionsByPackage($objectHash): array
{
if (!isset($this->removedVersionsByPackage[$objectHash])) {
return array();
@ -111,7 +111,7 @@ class Pool implements \Countable
/**
* @return BasePackage[]
*/
public function getPackages()
public function getPackages(): array
{
return $this->packages;
}
@ -122,7 +122,7 @@ class Pool implements \Countable
* @param int $id
* @return BasePackage
*/
public function packageById($id)
public function packageById($id): BasePackage
{
return $this->packages[$id - 1];
}
@ -143,7 +143,7 @@ class Pool implements \Countable
* packages must match or null to return all
* @return BasePackage[] A set of packages
*/
public function whatProvides($name, ConstraintInterface $constraint = null)
public function whatProvides($name, ConstraintInterface $constraint = null): array
{
$key = (string) $constraint;
if (isset($this->providerCache[$name][$key])) {
@ -180,7 +180,7 @@ class Pool implements \Countable
* @param int $literal
* @return BasePackage
*/
public function literalToPackage($literal)
public function literalToPackage($literal): BasePackage
{
$packageId = abs($literal);
@ -192,7 +192,7 @@ class Pool implements \Countable
* @param array<int, BasePackage> $installedMap
* @return string
*/
public function literalToPrettyString($literal, $installedMap)
public function literalToPrettyString($literal, $installedMap): string
{
$package = $this->literalToPackage($literal);
@ -212,7 +212,7 @@ class Pool implements \Countable
* @param string $name Name of the package to be matched
* @return bool
*/
public function match(BasePackage $candidate, $name, ConstraintInterface $constraint = null)
public function match(BasePackage $candidate, $name, ConstraintInterface $constraint = null): bool
{
$candidateName = $candidate->getName();
$candidateVersion = $candidate->getVersion();
@ -255,7 +255,7 @@ class Pool implements \Countable
/**
* @return bool
*/
public function isUnacceptableFixedOrLockedPackage(BasePackage $package)
public function isUnacceptableFixedOrLockedPackage(BasePackage $package): bool
{
return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
}
@ -263,7 +263,7 @@ class Pool implements \Countable
/**
* @return BasePackage[]
*/
public function getUnacceptableFixedOrLockedPackages()
public function getUnacceptableFixedOrLockedPackages(): array
{
return $this->unacceptableFixedOrLockedPackages;
}

View File

@ -158,7 +158,7 @@ class PoolBuilder
* @param RepositoryInterface[] $repositories
* @return Pool
*/
public function buildPool(array $repositories, Request $request)
public function buildPool(array $repositories, Request $request): Pool
{
if ($request->getUpdateAllowList()) {
$this->updateAllowList = $request->getUpdateAllowList();

View File

@ -71,7 +71,7 @@ class PoolOptimizer
/**
* @return Pool
*/
public function optimize(Request $request, Pool $pool)
public function optimize(Request $request, Pool $pool): Pool
{
$this->prepare($request, $pool);

View File

@ -54,7 +54,7 @@ class Problem
* @param Rule $rule A rule which is a reason for this problem
* @return void
*/
public function addRule(Rule $rule)
public function addRule(Rule $rule): void
{
$this->addReason(spl_object_hash($rule), $rule);
}
@ -64,7 +64,7 @@ class Problem
*
* @return array<int, array<int, Rule>> The problem's reasons
*/
public function getReasons()
public function getReasons(): array
{
return $this->reasons;
}
@ -77,7 +77,7 @@ class Problem
* @param array<Rule[]> $learnedPool
* @return string
*/
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
{
// TODO doesn't this entirely defeat the purpose of the problem sections? what's the point of sections?
$reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
@ -165,7 +165,7 @@ class Problem
/**
* @return bool
*/
public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
{
foreach ($this->reasons as $sectionRules) {
foreach ($sectionRules as $rule) {
@ -185,7 +185,7 @@ class Problem
* @param Rule $reason The reason descriptor
* @return void
*/
protected function addReason($id, Rule $reason)
protected function addReason($id, Rule $reason): void
{
// TODO: if a rule is part of a problem description in two sections, isn't this going to remove a message
// that is important to understand the issue?
@ -199,7 +199,7 @@ class Problem
/**
* @return void
*/
public function nextSection()
public function nextSection(): void
{
$this->section++;
}
@ -576,7 +576,7 @@ class Problem
*
* @return string
*/
protected static function constraintToText(ConstraintInterface $constraint = null)
protected static function constraintToText(ConstraintInterface $constraint = null): string
{
return $constraint ? ' '.$constraint->getPrettyString() : '';
}

View File

@ -144,7 +144,7 @@ class Request
/**
* @return string[]
*/
public function getUpdateAllowList()
public function getUpdateAllowList(): array
{
return $this->updateAllowList;
}
@ -152,7 +152,7 @@ class Request
/**
* @return bool
*/
public function getUpdateAllowTransitiveDependencies()
public function getUpdateAllowTransitiveDependencies(): bool
{
return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
}
@ -160,7 +160,7 @@ class Request
/**
* @return bool
*/
public function getUpdateAllowTransitiveRootDependencies()
public function getUpdateAllowTransitiveRootDependencies(): bool
{
return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
}
@ -168,7 +168,7 @@ class Request
/**
* @return array<string, ConstraintInterface>
*/
public function getRequires()
public function getRequires(): array
{
return $this->requires;
}
@ -176,7 +176,7 @@ class Request
/**
* @return array<string, BasePackage>
*/
public function getFixedPackages()
public function getFixedPackages(): array
{
return $this->fixedPackages;
}
@ -184,7 +184,7 @@ class Request
/**
* @return bool
*/
public function isFixedPackage(BasePackage $package)
public function isFixedPackage(BasePackage $package): bool
{
return isset($this->fixedPackages[spl_object_hash($package)]);
}
@ -192,7 +192,7 @@ class Request
/**
* @return array<string, BasePackage>
*/
public function getLockedPackages()
public function getLockedPackages(): array
{
return $this->lockedPackages;
}
@ -200,7 +200,7 @@ class Request
/**
* @return bool
*/
public function isLockedPackage(PackageInterface $package)
public function isLockedPackage(PackageInterface $package): bool
{
return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
}
@ -208,7 +208,7 @@ class Request
/**
* @return array<string, BasePackage>
*/
public function getFixedOrLockedPackages()
public function getFixedOrLockedPackages(): array
{
return array_merge($this->fixedPackages, $this->lockedPackages);
}
@ -222,7 +222,7 @@ class Request
* Some locked packages may not be in the pool,
* so they have a package->id of -1
*/
public function getPresentMap($packageIds = false)
public function getPresentMap($packageIds = false): array
{
$presentMap = array();
@ -242,7 +242,7 @@ class Request
/**
* @return BasePackage[]
*/
public function getFixedPackagesMap()
public function getFixedPackagesMap(): array
{
$fixedPackagesMap = array();
@ -256,7 +256,7 @@ class Request
/**
* @return ?LockArrayRepository
*/
public function getLockedRepository()
public function getLockedRepository(): ?LockArrayRepository
{
return $this->lockedRepository;
}

View File

@ -71,7 +71,7 @@ abstract class Rule
/**
* @return int[]
*/
abstract public function getLiterals();
abstract public function getLiterals(): array;
/**
* @return int|string
@ -84,12 +84,12 @@ abstract class Rule
* @param Rule $rule
* @return bool
*/
abstract public function equals(Rule $rule);
abstract public function equals(Rule $rule): bool;
/**
* @return int
*/
public function getReason()
public function getReason(): int
{
return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
}
@ -105,7 +105,7 @@ abstract class Rule
/**
* @return string|null
*/
public function getRequiredPackage()
public function getRequiredPackage(): ?string
{
$reason = $this->getReason();
@ -136,7 +136,7 @@ abstract class Rule
/**
* @return int
*/
public function getType()
public function getType(): int
{
return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
}
@ -160,7 +160,7 @@ abstract class Rule
/**
* @return bool
*/
public function isDisabled()
public function isDisabled(): bool
{
return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
}
@ -168,7 +168,7 @@ abstract class Rule
/**
* @return bool
*/
public function isEnabled()
public function isEnabled(): bool
{
return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
}
@ -176,12 +176,12 @@ abstract class Rule
/**
* @return bool
*/
abstract public function isAssertion();
abstract public function isAssertion(): bool;
/**
* @return bool
*/
public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
{
if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
@ -267,7 +267,7 @@ abstract class Rule
* @param array<Rule[]> $learnedPool
* @return string
*/
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
{
$literals = $this->getLiterals();
@ -484,7 +484,7 @@ abstract class Rule
* @param bool $useRemovedVersionGroup
* @return string
*/
protected function formatPackagesUnique(Pool $pool, array $packages, $isVerbose, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false)
protected function formatPackagesUnique(Pool $pool, array $packages, $isVerbose, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false): string
{
foreach ($packages as $index => $package) {
if (!\is_object($package)) {

View File

@ -45,7 +45,7 @@ class Rule2Literals extends Rule
}
/** @return int[] */
public function getLiterals()
public function getLiterals(): array
{
return array($this->literal1, $this->literal2);
}
@ -66,7 +66,7 @@ class Rule2Literals extends Rule
* @param Rule $rule The rule to check against
* @return bool Whether the rules are equal
*/
public function equals(Rule $rule)
public function equals(Rule $rule): bool
{
// specialized fast-case
if ($rule instanceof self) {
@ -98,7 +98,7 @@ class Rule2Literals extends Rule
}
/** @return false */
public function isAssertion()
public function isAssertion(): bool
{
return false;
}

View File

@ -112,13 +112,13 @@ class RuleSet implements \IteratorAggregate, \Countable
* @param int $id
* @return Rule
*/
public function ruleById($id)
public function ruleById($id): Rule
{
return $this->ruleById[$id];
}
/** @return array<self::TYPE_*, Rule[]> */
public function getRules()
public function getRules(): array
{
return $this->rules;
}
@ -132,7 +132,7 @@ class RuleSet implements \IteratorAggregate, \Countable
* @param self::TYPE_*|array<self::TYPE_*> $types
* @return RuleSetIterator
*/
public function getIteratorFor($types)
public function getIteratorFor($types): RuleSetIterator
{
if (!\is_array($types)) {
$types = array($types);
@ -154,7 +154,7 @@ class RuleSet implements \IteratorAggregate, \Countable
* @param array<self::TYPE_*>|self::TYPE_* $types
* @return RuleSetIterator
*/
public function getIteratorWithout($types)
public function getIteratorWithout($types): RuleSetIterator
{
if (!\is_array($types)) {
$types = array($types);
@ -170,7 +170,7 @@ class RuleSet implements \IteratorAggregate, \Countable
}
/** @return array{0: 0, 1: 1, 2: 4} */
public function getTypes()
public function getTypes(): array
{
$types = self::$types;
@ -181,7 +181,7 @@ class RuleSet implements \IteratorAggregate, \Countable
* @param bool $isVerbose
* @return string
*/
public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false): string
{
$string = "\n";
foreach ($this->rules as $type => $rules) {

View File

@ -56,7 +56,7 @@ class RuleSetGenerator
*
* @phpstan-param ReasonData $reasonData
*/
protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData = null)
protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData = null): ?Rule
{
$literals = array(-$package->id);
@ -85,7 +85,7 @@ class RuleSetGenerator
*
* @phpstan-param ReasonData $reasonData
*/
protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
protected function createInstallOneOfRule(array $packages, $reason, $reasonData): Rule
{
$literals = array();
foreach ($packages as $package) {
@ -109,7 +109,7 @@ class RuleSetGenerator
*
* @phpstan-param ReasonData $reasonData
*/
protected function createRule2Literals(BasePackage $issuer, BasePackage $provider, $reason, $reasonData = null)
protected function createRule2Literals(BasePackage $issuer, BasePackage $provider, $reason, $reasonData = null): ?Rule
{
// ignore self conflict
if ($issuer === $provider) {
@ -127,7 +127,7 @@ class RuleSetGenerator
*
* @phpstan-param ReasonData $reasonData
*/
protected function createMultiConflictRule(array $packages, $reason, $reasonData)
protected function createMultiConflictRule(array $packages, $reason, $reasonData): Rule
{
$literals = array();
foreach ($packages as $package) {
@ -323,7 +323,7 @@ class RuleSetGenerator
/**
* @return RuleSet
*/
public function getRulesFor(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null)
public function getRulesFor(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null): RuleSet
{
$platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();

View File

@ -88,7 +88,7 @@ class RuleWatchGraph
* register decisions resulting from propagation
* @return Rule|null If a conflict is found the conflicting rule is returned
*/
public function propagateLiteral($decidedLiteral, $level, Decisions $decisions)
public function propagateLiteral($decidedLiteral, $level, Decisions $decisions): ?Rule
{
// we invert the decided literal here, example:
// A was decided => (-A|B) now requires B to be true, so we look for

View File

@ -80,7 +80,7 @@ class RuleWatchNode
*
* @return Rule
*/
public function getRule()
public function getRule(): Rule
{
return $this->rule;
}
@ -91,7 +91,7 @@ class RuleWatchNode
* @param int $literal The watched literal that should not be returned
* @return int A literal
*/
public function getOtherWatch($literal)
public function getOtherWatch($literal): int
{
if ($this->watch1 == $literal) {
return $this->watch2;

View File

@ -68,7 +68,7 @@ class Solver
/**
* @return int
*/
public function getRuleSetSize()
public function getRuleSetSize(): int
{
return \count($this->rules);
}
@ -76,7 +76,7 @@ class Solver
/**
* @return Pool
*/
public function getPool()
public function getPool(): Pool
{
return $this->pool;
}
@ -190,7 +190,7 @@ class Solver
/**
* @return LockTransaction
*/
public function solve(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null)
public function solve(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null): LockTransaction
{
$platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
@ -233,7 +233,7 @@ class Solver
* @param int $level
* @return Rule|null A rule on conflict, otherwise null.
*/
protected function propagate($level)
protected function propagate($level): ?Rule
{
while ($this->decisions->validOffset($this->propagateIndex)) {
$decision = $this->decisions->atOffset($this->propagateIndex);
@ -370,7 +370,7 @@ class Solver
* @param int $level
* @return array{int, int, GenericRule, int}
*/
protected function analyze($level, Rule $rule)
protected function analyze($level, Rule $rule): array
{
$analyzedRule = $rule;
$ruleLevel = 1;

View File

@ -46,7 +46,7 @@ class SolverProblemsException extends \RuntimeException
* @param bool $isDevExtraction
* @return string
*/
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false): string
{
$installedMap = $request->getPresentMap(true);
$missingExtensions = array();
@ -100,7 +100,7 @@ class SolverProblemsException extends \RuntimeException
/**
* @return Problem[]
*/
public function getProblems()
public function getProblems(): array
{
return $this->problems;
}

View File

@ -59,7 +59,7 @@ class DownloadManager
* @param bool $preferSource prefer downloading from source
* @return DownloadManager
*/
public function setPreferSource($preferSource)
public function setPreferSource($preferSource): DownloadManager
{
$this->preferSource = $preferSource;
@ -72,7 +72,7 @@ class DownloadManager
* @param bool $preferDist prefer downloading from dist
* @return DownloadManager
*/
public function setPreferDist($preferDist)
public function setPreferDist($preferDist): DownloadManager
{
$this->preferDist = $preferDist;
@ -86,7 +86,7 @@ class DownloadManager
*
* @return DownloadManager
*/
public function setPreferences(array $preferences)
public function setPreferences(array $preferences): DownloadManager
{
$this->packagePreferences = $preferences;
@ -100,7 +100,7 @@ class DownloadManager
* @param DownloaderInterface $downloader downloader instance
* @return DownloadManager
*/
public function setDownloader($type, DownloaderInterface $downloader)
public function setDownloader($type, DownloaderInterface $downloader): DownloadManager
{
$type = strtolower($type);
$this->downloaders[$type] = $downloader;
@ -115,7 +115,7 @@ class DownloadManager
* @throws \InvalidArgumentException if downloader for provided type is not registered
* @return DownloaderInterface
*/
public function getDownloader($type)
public function getDownloader($type): DownloaderInterface
{
$type = strtolower($type);
if (!isset($this->downloaders[$type])) {
@ -134,7 +134,7 @@ class DownloadManager
* wrong type
* @return DownloaderInterface|null
*/
public function getDownloaderForPackage(PackageInterface $package)
public function getDownloaderForPackage(PackageInterface $package): ?DownloaderInterface
{
$installationSource = $package->getInstallationSource();
@ -168,7 +168,7 @@ class DownloadManager
/**
* @return string
*/
public function getDownloaderType(DownloaderInterface $downloader)
public function getDownloaderType(DownloaderInterface $downloader): string
{
return array_search($downloader, $this->downloaders);
}
@ -184,7 +184,7 @@ class DownloadManager
* @throws \RuntimeException
* @return PromiseInterface
*/
public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null): PromiseInterface
{
$targetDir = $this->normalizeTargetDir($targetDir);
$this->filesystem->ensureDirectoryExists(dirname($targetDir));
@ -253,7 +253,7 @@ class DownloadManager
*
* @return PromiseInterface|null
*/
public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
{
$targetDir = $this->normalizeTargetDir($targetDir);
$downloader = $this->getDownloaderForPackage($package);
@ -274,7 +274,7 @@ class DownloadManager
* @throws \RuntimeException
* @return PromiseInterface|null
*/
public function install(PackageInterface $package, $targetDir)
public function install(PackageInterface $package, $targetDir): ?PromiseInterface
{
$targetDir = $this->normalizeTargetDir($targetDir);
$downloader = $this->getDownloaderForPackage($package);
@ -295,7 +295,7 @@ class DownloadManager
* @throws \InvalidArgumentException if initial package is not installed
* @return PromiseInterface|null
*/
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
public function update(PackageInterface $initial, PackageInterface $target, $targetDir): ?PromiseInterface
{
$targetDir = $this->normalizeTargetDir($targetDir);
$downloader = $this->getDownloaderForPackage($target);
@ -347,7 +347,7 @@ class DownloadManager
*
* @return PromiseInterface|null
*/
public function remove(PackageInterface $package, $targetDir)
public function remove(PackageInterface $package, $targetDir): ?PromiseInterface
{
$targetDir = $this->normalizeTargetDir($targetDir);
$downloader = $this->getDownloaderForPackage($package);
@ -368,7 +368,7 @@ class DownloadManager
*
* @return PromiseInterface|null
*/
public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null): ?PromiseInterface
{
$targetDir = $this->normalizeTargetDir($targetDir);
$downloader = $this->getDownloaderForPackage($package);
@ -386,7 +386,7 @@ class DownloadManager
*
* @return string
*/
protected function resolvePackageInstallPreference(PackageInterface $package)
protected function resolvePackageInstallPreference(PackageInterface $package): string
{
foreach ($this->packagePreferences as $pattern => $preference) {
$pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface;
use Composer\Pcre\Preg;
use Composer\Util\ProcessExecutor;
@ -24,7 +25,7 @@ class FossilDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null): ?PromiseInterface
{
return \React\Promise\resolve();
}
@ -32,7 +33,7 @@ class FossilDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doInstall(PackageInterface $package, $path, $url)
protected function doInstall(PackageInterface $package, $path, $url): ?PromiseInterface
{
// Ensure we are allowed to use this URL by config
$this->config->prohibitUrlByConfig($url, $this->io);
@ -60,7 +61,7 @@ class FossilDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url): ?PromiseInterface
{
// Ensure we are allowed to use this URL by config
$this->config->prohibitUrlByConfig($url, $this->io);
@ -83,7 +84,7 @@ class FossilDownloader extends VcsDownloader
/**
* @inheritDoc
*/
public function getLocalChanges(PackageInterface $package, $path)
public function getLocalChanges(PackageInterface $package, $path): ?string
{
if (!$this->hasMetadataRepository($path)) {
return null;
@ -97,7 +98,7 @@ class FossilDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function getCommitLogs($fromReference, $toReference, $path)
protected function getCommitLogs($fromReference, $toReference, $path): string
{
$command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
@ -121,7 +122,7 @@ class FossilDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function hasMetadataRepository($path)
protected function hasMetadataRepository($path): bool
{
return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
}

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface;
use Composer\Util\Platform;
use Composer\Util\ProcessExecutor;
@ -23,7 +24,7 @@ use Composer\Util\ProcessExecutor;
*/
class GzipDownloader extends ArchiveDownloader
{
protected function extract(PackageInterface $package, $file, $path)
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
{
$filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
$targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface;
use Composer\Util\ProcessExecutor;
use Composer\Util\Hg as HgUtils;
@ -24,7 +25,7 @@ class HgDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null): ?PromiseInterface
{
if (null === HgUtils::getVersion($this->process)) {
throw new \RuntimeException('hg was not found in your PATH, skipping source download');
@ -36,7 +37,7 @@ class HgDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doInstall(PackageInterface $package, $path, $url)
protected function doInstall(PackageInterface $package, $path, $url): ?PromiseInterface
{
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
@ -58,7 +59,7 @@ class HgDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url): ?PromiseInterface
{
$hgUtils = new HgUtils($this->io, $this->config, $this->process);
@ -81,7 +82,7 @@ class HgDownloader extends VcsDownloader
/**
* @inheritDoc
*/
public function getLocalChanges(PackageInterface $package, $path)
public function getLocalChanges(PackageInterface $package, $path): ?string
{
if (!is_dir($path.'/.hg')) {
return null;
@ -95,7 +96,7 @@ class HgDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function getCommitLogs($fromReference, $toReference, $path)
protected function getCommitLogs($fromReference, $toReference, $path): string
{
$command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
@ -109,7 +110,7 @@ class HgDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function hasMetadataRepository($path)
protected function hasMetadataRepository($path): bool
{
return is_dir($path . '/.hg');
}

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\Archiver\ArchivableFilesFinder;
use Composer\Package\Dumper\ArrayDumper;
use Composer\Package\PackageInterface;
@ -38,7 +39,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
/**
* @inheritDoc
*/
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true): ?PromiseInterface
{
$path = Filesystem::trimTrailingSlash($path);
$url = $package->getDistUrl();
@ -74,7 +75,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
/**
* @inheritDoc
*/
public function install(PackageInterface $package, $path, $output = true)
public function install(PackageInterface $package, $path, $output = true): ?PromiseInterface
{
$path = Filesystem::trimTrailingSlash($path);
$url = $package->getDistUrl();
@ -160,7 +161,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
/**
* @inheritDoc
*/
public function remove(PackageInterface $package, $path, $output = true)
public function remove(PackageInterface $package, $path, $output = true): ?PromiseInterface
{
$path = Filesystem::trimTrailingSlash($path);
/**
@ -205,7 +206,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
/**
* @inheritDoc
*/
public function getVcsReference(PackageInterface $package, $path)
public function getVcsReference(PackageInterface $package, $path): ?string
{
$path = Filesystem::trimTrailingSlash($path);
$parser = new VersionParser;
@ -223,7 +224,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
/**
* @inheritDoc
*/
protected function getInstallOperationAppendix(PackageInterface $package, $path)
protected function getInstallOperationAppendix(PackageInterface $package, $path): string
{
$realUrl = realpath($package->getDistUrl());

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface;
use Composer\Repository\VcsRepository;
use Composer\Util\Perforce;
@ -27,7 +28,7 @@ class PerforceDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null): ?PromiseInterface
{
return \React\Promise\resolve();
}
@ -35,7 +36,7 @@ class PerforceDownloader extends VcsDownloader
/**
* @inheritDoc
*/
public function doInstall(PackageInterface $package, $path, $url)
public function doInstall(PackageInterface $package, $path, $url): ?PromiseInterface
{
$ref = $package->getSourceReference();
$label = $this->getLabelFromSourceReference((string) $ref);
@ -100,7 +101,7 @@ class PerforceDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url): ?PromiseInterface
{
return $this->doInstall($target, $path, $url);
}
@ -108,7 +109,7 @@ class PerforceDownloader extends VcsDownloader
/**
* @inheritDoc
*/
public function getLocalChanges(PackageInterface $package, $path)
public function getLocalChanges(PackageInterface $package, $path): ?string
{
$this->io->writeError('Perforce driver does not check for local changes before overriding');
@ -118,7 +119,7 @@ class PerforceDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function getCommitLogs($fromReference, $toReference, $path)
protected function getCommitLogs($fromReference, $toReference, $path): string
{
return $this->perforce->getCommitLogs($fromReference, $toReference);
}
@ -134,7 +135,7 @@ class PerforceDownloader extends VcsDownloader
/**
* @inheritDoc
*/
protected function hasMetadataRepository($path)
protected function hasMetadataRepository($path): bool
{
return true;
}

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface;
/**
@ -24,7 +25,7 @@ class PharDownloader extends ArchiveDownloader
/**
* @inheritDoc
*/
protected function extract(PackageInterface $package, $file, $path)
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
{
// Can throw an UnexpectedValueException
$archive = new \Phar($file);

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Util\IniHelper;
use Composer\Util\Platform;
use Composer\Util\ProcessExecutor;
@ -27,7 +28,7 @@ use RarArchive;
*/
class RarDownloader extends ArchiveDownloader
{
protected function extract(PackageInterface $package, $file, $path)
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
{
$processError = null;

View File

@ -39,7 +39,7 @@ class TransportException extends \RuntimeException
/**
* @return ?array<string>
*/
public function getHeaders()
public function getHeaders(): ?array
{
return $this->headers;
}
@ -57,7 +57,7 @@ class TransportException extends \RuntimeException
/**
* @return ?string
*/
public function getResponse()
public function getResponse(): ?string
{
return $this->response;
}
@ -75,7 +75,7 @@ class TransportException extends \RuntimeException
/**
* @return ?int
*/
public function getStatusCode()
public function getStatusCode(): ?int
{
return $this->statusCode;
}
@ -83,7 +83,7 @@ class TransportException extends \RuntimeException
/**
* @return array<mixed>
*/
public function getResponseInfo()
public function getResponseInfo(): array
{
return $this->responseInfo;
}

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface;
use Composer\Util\ProcessExecutor;
@ -23,7 +24,7 @@ use Composer\Util\ProcessExecutor;
*/
class XzDownloader extends ArchiveDownloader
{
protected function extract(PackageInterface $package, $file, $path)
protected function extract(PackageInterface $package, $file, $path): ?PromiseInterface
{
$command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);

View File

@ -18,5 +18,5 @@ interface PlatformRequirementFilterInterface
* @param string $req
* @return bool
*/
public function isIgnored($req);
public function isIgnored($req): bool;
}

View File

@ -50,7 +50,7 @@ class BufferIO extends ConsoleIO
/**
* @return string output
*/
public function getOutput()
public function getOutput(): string
{
fseek($this->output->getStream(), 0);

View File

@ -22,7 +22,7 @@ class NullIO extends BaseIO
/**
* @inheritDoc
*/
public function isInteractive()
public function isInteractive(): bool
{
return false;
}
@ -30,7 +30,7 @@ class NullIO extends BaseIO
/**
* @inheritDoc
*/
public function isVerbose()
public function isVerbose(): bool
{
return false;
}
@ -38,7 +38,7 @@ class NullIO extends BaseIO
/**
* @inheritDoc
*/
public function isVeryVerbose()
public function isVeryVerbose(): bool
{
return false;
}
@ -46,7 +46,7 @@ class NullIO extends BaseIO
/**
* @inheritDoc
*/
public function isDebug()
public function isDebug(): bool
{
return false;
}
@ -54,7 +54,7 @@ class NullIO extends BaseIO
/**
* @inheritDoc
*/
public function isDecorated()
public function isDecorated(): bool
{
return false;
}
@ -98,7 +98,7 @@ class NullIO extends BaseIO
/**
* @inheritDoc
*/
public function askConfirmation($question, $default = true)
public function askConfirmation($question, $default = true): bool
{
return $default;
}
@ -114,7 +114,7 @@ class NullIO extends BaseIO
/**
* @inheritDoc
*/
public function askAndHideAnswer($question)
public function askAndHideAnswer($question): ?string
{
return null;
}

View File

@ -226,7 +226,7 @@ class Installer
* @return int 0 on success or a positive error code on failure
* @phpstan-return self::ERROR_*
*/
public function run()
public function run(): int
{
// Disable GC to save CPU cycles, as the dependency solver can create hundreds of thousands
// of PHP objects, the GC can spend quite some time walking the tree of references looking
@ -386,7 +386,7 @@ class Installer
* @return int
* @phpstan-return self::ERROR_*
*/
protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall): int
{
$platformRepo = $this->createPlatformRepo(true);
$aliases = $this->getRootAliases(true);
@ -597,7 +597,7 @@ class Installer
* @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
* @phpstan-return self::ERROR_*
*/
protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null)
protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null): int
{
if (!$this->package->getDevRequires()) {
return 0;
@ -648,7 +648,7 @@ class Installer
* @return int exit code
* @phpstan-return self::ERROR_*
*/
protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false)
protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false): int
{
$this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
@ -769,7 +769,7 @@ class Installer
*
* @return PlatformRepository
*/
protected function createPlatformRepo($forUpdate)
protected function createPlatformRepo($forUpdate): PlatformRepository
{
if ($forUpdate) {
$platformOverrides = $this->config->get('platform') ?: array();
@ -1030,7 +1030,7 @@ class Installer
* @param Composer $composer
* @return Installer
*/
public static function create(IOInterface $io, Composer $composer)
public static function create(IOInterface $io, Composer $composer): Installer
{
return new static(
$io,
@ -1062,7 +1062,7 @@ class Installer
* @param bool $dryRun
* @return Installer
*/
public function setDryRun($dryRun = true)
public function setDryRun($dryRun = true): Installer
{
$this->dryRun = (bool) $dryRun;
@ -1074,7 +1074,7 @@ class Installer
*
* @return bool
*/
public function isDryRun()
public function isDryRun(): bool
{
return $this->dryRun;
}
@ -1085,7 +1085,7 @@ class Installer
* @param bool $preferSource
* @return Installer
*/
public function setPreferSource($preferSource = true)
public function setPreferSource($preferSource = true): Installer
{
$this->preferSource = (bool) $preferSource;
@ -1098,7 +1098,7 @@ class Installer
* @param bool $preferDist
* @return Installer
*/
public function setPreferDist($preferDist = true)
public function setPreferDist($preferDist = true): Installer
{
$this->preferDist = (bool) $preferDist;
@ -1111,7 +1111,7 @@ class Installer
* @param bool $optimizeAutoloader
* @return Installer
*/
public function setOptimizeAutoloader($optimizeAutoloader)
public function setOptimizeAutoloader($optimizeAutoloader): Installer
{
$this->optimizeAutoloader = (bool) $optimizeAutoloader;
if (!$this->optimizeAutoloader) {
@ -1130,7 +1130,7 @@ class Installer
* @param bool $classMapAuthoritative
* @return Installer
*/
public function setClassMapAuthoritative($classMapAuthoritative)
public function setClassMapAuthoritative($classMapAuthoritative): Installer
{
$this->classMapAuthoritative = (bool) $classMapAuthoritative;
if ($this->classMapAuthoritative) {
@ -1148,7 +1148,7 @@ class Installer
* @param string|null $apcuAutoloaderPrefix
* @return Installer
*/
public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null): Installer
{
$this->apcuAutoloader = $apcuAutoloader;
$this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
@ -1162,7 +1162,7 @@ class Installer
* @param bool $update
* @return Installer
*/
public function setUpdate($update)
public function setUpdate($update): Installer
{
$this->update = (bool) $update;
@ -1175,7 +1175,7 @@ class Installer
* @param bool $install
* @return Installer
*/
public function setInstall($install)
public function setInstall($install): Installer
{
$this->install = (bool) $install;
@ -1188,7 +1188,7 @@ class Installer
* @param bool $devMode
* @return Installer
*/
public function setDevMode($devMode = true)
public function setDevMode($devMode = true): Installer
{
$this->devMode = (bool) $devMode;
@ -1203,7 +1203,7 @@ class Installer
* @param bool $dumpAutoloader
* @return Installer
*/
public function setDumpAutoloader($dumpAutoloader = true)
public function setDumpAutoloader($dumpAutoloader = true): Installer
{
$this->dumpAutoloader = (bool) $dumpAutoloader;
@ -1219,7 +1219,7 @@ class Installer
* @return Installer
* @deprecated Use setRunScripts(false) on the EventDispatcher instance being injected instead
*/
public function setRunScripts($runScripts = true)
public function setRunScripts($runScripts = true): Installer
{
$this->runScripts = (bool) $runScripts;
@ -1232,7 +1232,7 @@ class Installer
* @param Config $config
* @return Installer
*/
public function setConfig(Config $config)
public function setConfig(Config $config): Installer
{
$this->config = $config;
@ -1245,7 +1245,7 @@ class Installer
* @param bool $verbose
* @return Installer
*/
public function setVerbose($verbose = true)
public function setVerbose($verbose = true): Installer
{
$this->verbose = (bool) $verbose;
@ -1257,7 +1257,7 @@ class Installer
*
* @return bool
*/
public function isVerbose()
public function isVerbose(): bool
{
return $this->verbose;
}
@ -1275,7 +1275,7 @@ class Installer
*
* @deprecated use setPlatformRequirementFilter instead
*/
public function setIgnorePlatformRequirements($ignorePlatformReqs)
public function setIgnorePlatformRequirements($ignorePlatformReqs): Installer
{
trigger_error('Installer::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
@ -1286,7 +1286,7 @@ class Installer
* @param PlatformRequirementFilterInterface $platformRequirementFilter
* @return Installer
*/
public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter)
public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter): Installer
{
$this->platformRequirementFilter = $platformRequirementFilter;
@ -1299,7 +1299,7 @@ class Installer
* @param bool $updateMirrors
* @return Installer
*/
public function setUpdateMirrors($updateMirrors)
public function setUpdateMirrors($updateMirrors): Installer
{
$this->updateMirrors = $updateMirrors;
@ -1314,7 +1314,7 @@ class Installer
*
* @return Installer
*/
public function setUpdateAllowList(array $packages)
public function setUpdateAllowList(array $packages): Installer
{
$this->updateAllowList = array_flip(array_map('strtolower', $packages));
@ -1330,7 +1330,7 @@ class Installer
* @param int $updateAllowTransitiveDependencies One of the UPDATE_ constants on the Request class
* @return Installer
*/
public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies): Installer
{
if (!in_array($updateAllowTransitiveDependencies, array(Request::UPDATE_ONLY_LISTED, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS), true)) {
throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
@ -1347,7 +1347,7 @@ class Installer
* @param bool $preferStable
* @return Installer
*/
public function setPreferStable($preferStable = true)
public function setPreferStable($preferStable = true): Installer
{
$this->preferStable = (bool) $preferStable;
@ -1360,7 +1360,7 @@ class Installer
* @param bool $preferLowest
* @return Installer
*/
public function setPreferLowest($preferLowest = true)
public function setPreferLowest($preferLowest = true): Installer
{
$this->preferLowest = (bool) $preferLowest;
@ -1375,7 +1375,7 @@ class Installer
* @param bool $writeLock
* @return Installer
*/
public function setWriteLock($writeLock = true)
public function setWriteLock($writeLock = true): Installer
{
$this->writeLock = (bool) $writeLock;
@ -1390,7 +1390,7 @@ class Installer
* @param bool $executeOperations
* @return Installer
*/
public function setExecuteOperations($executeOperations = true)
public function setExecuteOperations($executeOperations = true): Installer
{
$this->executeOperations = (bool) $executeOperations;
@ -1406,7 +1406,7 @@ class Installer
*
* @return Installer
*/
public function disablePlugins()
public function disablePlugins(): Installer
{
$this->installationManager->disablePlugins();
@ -1417,7 +1417,7 @@ class Installer
* @param SuggestedPackagesReporter $suggestedPackagesReporter
* @return Installer
*/
public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter): Installer
{
$this->suggestedPackagesReporter = $suggestedPackagesReporter;

View File

@ -149,7 +149,7 @@ class BinaryInstaller
*
* @return string
*/
public static function determineBinaryCaller($bin)
public static function determineBinaryCaller($bin): string
{
if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
return 'call';
@ -168,7 +168,7 @@ class BinaryInstaller
/**
* @return string[]
*/
protected function getBinaries(PackageInterface $package)
protected function getBinaries(PackageInterface $package): array
{
return $package->getBinaries();
}
@ -223,7 +223,7 @@ class BinaryInstaller
*
* @return string
*/
protected function generateWindowsProxyCode($bin, $link)
protected function generateWindowsProxyCode($bin, $link): string
{
$binPath = $this->filesystem->findShortestPath($link, $bin);
$caller = self::determineBinaryCaller($bin);
@ -252,7 +252,7 @@ class BinaryInstaller
*
* @return string
*/
protected function generateUnixyProxyCode($bin, $link)
protected function generateUnixyProxyCode($bin, $link): string
{
$binPath = $this->filesystem->findShortestPath($link, $bin);

View File

@ -12,6 +12,7 @@
namespace Composer\Installer;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface;
use Composer\Downloader\DownloadManager;
use Composer\Repository\InstalledRepositoryInterface;
@ -48,7 +49,7 @@ class ProjectInstaller implements InstallerInterface
* @param string $packageType
* @return bool
*/
public function supports($packageType)
public function supports($packageType): bool
{
return true;
}
@ -56,7 +57,7 @@ class ProjectInstaller implements InstallerInterface
/**
* @inheritDoc
*/
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
{
return false;
}
@ -64,7 +65,7 @@ class ProjectInstaller implements InstallerInterface
/**
* @inheritDoc
*/
public function download(PackageInterface $package, PackageInterface $prevPackage = null)
public function download(PackageInterface $package, PackageInterface $prevPackage = null): ?PromiseInterface
{
$installPath = $this->installPath;
if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
@ -80,7 +81,7 @@ class ProjectInstaller implements InstallerInterface
/**
* @inheritDoc
*/
public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null): ?PromiseInterface
{
return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
}
@ -88,7 +89,7 @@ class ProjectInstaller implements InstallerInterface
/**
* @inheritDoc
*/
public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null): ?PromiseInterface
{
return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
}
@ -96,7 +97,7 @@ class ProjectInstaller implements InstallerInterface
/**
* @inheritDoc
*/
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
public function install(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
{
return $this->downloadManager->install($package, $this->installPath);
}
@ -104,7 +105,7 @@ class ProjectInstaller implements InstallerInterface
/**
* @inheritDoc
*/
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target): ?PromiseInterface
{
throw new \InvalidArgumentException("not supported");
}
@ -112,7 +113,7 @@ class ProjectInstaller implements InstallerInterface
/**
* @inheritDoc
*/
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
{
throw new \InvalidArgumentException("not supported");
}
@ -123,7 +124,7 @@ class ProjectInstaller implements InstallerInterface
* @param PackageInterface $package
* @return string path
*/
public function getInstallPath(PackageInterface $package)
public function getInstallPath(PackageInterface $package): string
{
return $this->installPath;
}

View File

@ -47,7 +47,7 @@ class SuggestedPackagesReporter
/**
* @return array<array{source: string, target: string, reason: string}> Suggested packages with source, target and reason keys.
*/
public function getPackages()
public function getPackages(): array
{
return $this->suggestedPackages;
}
@ -63,7 +63,7 @@ class SuggestedPackagesReporter
* @param string $reason Reason the target package to be suggested
* @return SuggestedPackagesReporter
*/
public function addPackage($source, $target, $reason)
public function addPackage($source, $target, $reason): SuggestedPackagesReporter
{
$this->suggestedPackages[] = array(
'source' => $source,
@ -80,7 +80,7 @@ class SuggestedPackagesReporter
* @param PackageInterface $package
* @return SuggestedPackagesReporter
*/
public function addSuggestionsFromPackage(PackageInterface $package)
public function addSuggestionsFromPackage(PackageInterface $package): SuggestedPackagesReporter
{
$source = $package->getPrettyName();
foreach ($package->getSuggests() as $target => $reason) {

View File

@ -38,7 +38,7 @@ class JsonFormatter
* @param bool $unescapeSlashes Un escape slashes
* @return string
*/
public static function format($json, $unescapeUnicode, $unescapeSlashes)
public static function format($json, $unescapeUnicode, $unescapeSlashes): string
{
$result = '';
$pos = 0;

View File

@ -28,7 +28,7 @@ class JsonValidationException extends Exception
* @param string $message
* @param string[] $errors
*/
public function __construct($message, $errors = array(), Exception $previous = null)
public function __construct($message, array $errors = array(), Exception $previous = null)
{
$this->errors = $errors;
parent::__construct((string) $message, 0, $previous);
@ -37,7 +37,7 @@ class JsonValidationException extends Exception
/**
* @return string[]
*/
public function getErrors()
public function getErrors(): array
{
return $this->errors;
}

View File

@ -75,7 +75,7 @@ class AliasPackage extends BasePackage
/**
* @return BasePackage
*/
public function getAliasOf()
public function getAliasOf(): BasePackage
{
return $this->aliasOf;
}
@ -83,7 +83,7 @@ class AliasPackage extends BasePackage
/**
* @inheritDoc
*/
public function getVersion()
public function getVersion(): string
{
return $this->version;
}
@ -91,7 +91,7 @@ class AliasPackage extends BasePackage
/**
* @inheritDoc
*/
public function getStability()
public function getStability(): string
{
return $this->stability;
}
@ -99,7 +99,7 @@ class AliasPackage extends BasePackage
/**
* @inheritDoc
*/
public function getPrettyVersion()
public function getPrettyVersion(): string
{
return $this->prettyVersion;
}
@ -107,7 +107,7 @@ class AliasPackage extends BasePackage
/**
* @inheritDoc
*/
public function isDev()
public function isDev(): bool
{
return $this->dev;
}
@ -115,7 +115,7 @@ class AliasPackage extends BasePackage
/**
* @inheritDoc
*/
public function getRequires()
public function getRequires(): array
{
return $this->requires;
}
@ -124,7 +124,7 @@ class AliasPackage extends BasePackage
* @inheritDoc
* @return array<string|int, Link>
*/
public function getConflicts()
public function getConflicts(): array
{
return $this->conflicts;
}
@ -133,7 +133,7 @@ class AliasPackage extends BasePackage
* @inheritDoc
* @return array<string|int, Link>
*/
public function getProvides()
public function getProvides(): array
{
return $this->provides;
}
@ -142,7 +142,7 @@ class AliasPackage extends BasePackage
* @inheritDoc
* @return array<string|int, Link>
*/
public function getReplaces()
public function getReplaces(): array
{
return $this->replaces;
}
@ -150,7 +150,7 @@ class AliasPackage extends BasePackage
/**
* @inheritDoc
*/
public function getDevRequires()
public function getDevRequires(): array
{
return $this->devRequires;
}
@ -173,7 +173,7 @@ class AliasPackage extends BasePackage
* @see setRootPackageAlias
* @return bool
*/
public function isRootPackageAlias()
public function isRootPackageAlias(): bool
{
return $this->rootPackageAlias;
}
@ -184,7 +184,7 @@ class AliasPackage extends BasePackage
*
* @return Link[]
*/
protected function replaceSelfVersionDependencies(array $links, $linkType)
protected function replaceSelfVersionDependencies(array $links, $linkType): array
{
// for self.version requirements, we use the original package's branch name instead, to avoid leaking the magic dev-master-alias to users
$prettyVersion = $this->prettyVersion;
@ -220,7 +220,7 @@ class AliasPackage extends BasePackage
/**
* @return bool
*/
public function hasSelfVersionRequires()
public function hasSelfVersionRequires(): bool
{
return $this->hasSelfVersionRequires;
}
@ -234,17 +234,17 @@ class AliasPackage extends BasePackage
* Wrappers around the aliased package *
***************************************/
public function getType()
public function getType(): string
{
return $this->aliasOf->getType();
}
public function getTargetDir()
public function getTargetDir(): ?string
{
return $this->aliasOf->getTargetDir();
}
public function getExtra()
public function getExtra(): array
{
return $this->aliasOf->getExtra();
}
@ -254,27 +254,27 @@ class AliasPackage extends BasePackage
$this->aliasOf->setInstallationSource($type);
}
public function getInstallationSource()
public function getInstallationSource(): ?string
{
return $this->aliasOf->getInstallationSource();
}
public function getSourceType()
public function getSourceType(): ?string
{
return $this->aliasOf->getSourceType();
}
public function getSourceUrl()
public function getSourceUrl(): ?string
{
return $this->aliasOf->getSourceUrl();
}
public function getSourceUrls()
public function getSourceUrls(): array
{
return $this->aliasOf->getSourceUrls();
}
public function getSourceReference()
public function getSourceReference(): ?string
{
return $this->aliasOf->getSourceReference();
}
@ -289,27 +289,27 @@ class AliasPackage extends BasePackage
$this->aliasOf->setSourceMirrors($mirrors);
}
public function getSourceMirrors()
public function getSourceMirrors(): ?array
{
return $this->aliasOf->getSourceMirrors();
}
public function getDistType()
public function getDistType(): ?string
{
return $this->aliasOf->getDistType();
}
public function getDistUrl()
public function getDistUrl(): ?string
{
return $this->aliasOf->getDistUrl();
}
public function getDistUrls()
public function getDistUrls(): array
{
return $this->aliasOf->getDistUrls();
}
public function getDistReference()
public function getDistReference(): ?string
{
return $this->aliasOf->getDistReference();
}
@ -319,7 +319,7 @@ class AliasPackage extends BasePackage
$this->aliasOf->setDistReference($reference);
}
public function getDistSha1Checksum()
public function getDistSha1Checksum(): ?string
{
return $this->aliasOf->getDistSha1Checksum();
}
@ -329,7 +329,7 @@ class AliasPackage extends BasePackage
$this->aliasOf->setTransportOptions($options);
}
public function getTransportOptions()
public function getTransportOptions(): array
{
return $this->aliasOf->getTransportOptions();
}
@ -339,47 +339,47 @@ class AliasPackage extends BasePackage
$this->aliasOf->setDistMirrors($mirrors);
}
public function getDistMirrors()
public function getDistMirrors(): ?array
{
return $this->aliasOf->getDistMirrors();
}
public function getAutoload()
public function getAutoload(): array
{
return $this->aliasOf->getAutoload();
}
public function getDevAutoload()
public function getDevAutoload(): array
{
return $this->aliasOf->getDevAutoload();
}
public function getIncludePaths()
public function getIncludePaths(): array
{
return $this->aliasOf->getIncludePaths();
}
public function getReleaseDate()
public function getReleaseDate(): ?\DateTime
{
return $this->aliasOf->getReleaseDate();
}
public function getBinaries()
public function getBinaries(): array
{
return $this->aliasOf->getBinaries();
}
public function getSuggests()
public function getSuggests(): array
{
return $this->aliasOf->getSuggests();
}
public function getNotificationUrl()
public function getNotificationUrl(): ?string
{
return $this->aliasOf->getNotificationUrl();
}
public function isDefaultBranch()
public function isDefaultBranch(): bool
{
return $this->aliasOf->isDefaultBranch();
}

View File

@ -82,7 +82,7 @@ class ArchiveManager
*
* @return string A filename without an extension
*/
public function getPackageFilename(CompletePackageInterface $package)
public function getPackageFilename(CompletePackageInterface $package): string
{
if ($package->getArchiveName()) {
$baseName = $package->getArchiveName();
@ -121,7 +121,7 @@ class ArchiveManager
* @throws \RuntimeException
* @return string The path of the created archive
*/
public function archive(CompletePackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
public function archive(CompletePackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false): string
{
if (empty($format)) {
throw new \InvalidArgumentException('Format must be specified');

View File

@ -30,7 +30,7 @@ interface ArchiverInterface
*
* @return string The path to the written archive file
*/
public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false): string;
/**
* Format supported by the archiver.
@ -40,5 +40,5 @@ interface ArchiverInterface
*
* @return bool true if the format is supported by the archiver
*/
public function supports($format, $sourceType);
public function supports($format, $sourceType): bool;
}

View File

@ -49,7 +49,7 @@ abstract class BaseExcludeFilter
*
* @return bool Whether the file should be excluded
*/
public function filter($relativePath, $exclude)
public function filter($relativePath, $exclude): bool
{
foreach ($this->excludePatterns as $patternData) {
list($pattern, $negate, $stripLeadingSlash) = $patternData;
@ -80,7 +80,7 @@ abstract class BaseExcludeFilter
*
* @return array<array{0: non-empty-string, 1: bool, 2: bool}> Exclude patterns to be used in filter()
*/
protected function parseLines(array $lines, $lineParser)
protected function parseLines(array $lines, $lineParser): array
{
return array_filter(
array_map(
@ -108,7 +108,7 @@ abstract class BaseExcludeFilter
*
* @return array<int, array{0: non-empty-string, 1: bool, 2: bool}> Exclude patterns
*/
protected function generatePatterns($rules)
protected function generatePatterns($rules): array
{
$patterns = array();
foreach ($rules as $rule) {
@ -125,7 +125,7 @@ abstract class BaseExcludeFilter
*
* @return array{0: non-empty-string, 1: bool, 2: bool} An exclude pattern
*/
protected function generatePattern($rule)
protected function generatePattern($rule): array
{
$negate = false;
$pattern = '';

View File

@ -50,7 +50,7 @@ class GitExcludeFilter extends BaseExcludeFilter
*
* @return array{0: string, 1: bool, 2: bool}|null An exclude pattern for filter()
*/
public function parseGitAttributesLine($line)
public function parseGitAttributesLine($line): ?array
{
$parts = Preg::split('#\s+#', $line);

View File

@ -36,7 +36,7 @@ class PharArchiver implements ArchiverInterface
/**
* @inheritDoc
*/
public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false): string
{
$sources = realpath($sources);
@ -97,7 +97,7 @@ class PharArchiver implements ArchiverInterface
/**
* @inheritDoc
*/
public function supports($format, $sourceType)
public function supports($format, $sourceType): bool
{
return isset(static::$formats[$format]);
}

View File

@ -28,7 +28,7 @@ class ZipArchiver implements ArchiverInterface
/**
* @inheritDoc
*/
public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false): string
{
$fs = new Filesystem();
$sources = $fs->normalizePath($sources);
@ -78,7 +78,7 @@ class ZipArchiver implements ArchiverInterface
/**
* @inheritDoc
*/
public function supports($format, $sourceType)
public function supports($format, $sourceType): bool
{
return isset(static::$formats[$format]) && $this->compressionAvailable();
}

View File

@ -35,12 +35,12 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
/**
* @return CompletePackage
*/
public function getAliasOf()
public function getAliasOf(): CompletePackage
{
return $this->aliasOf;
}
public function getScripts()
public function getScripts(): array
{
return $this->aliasOf->getScripts();
}
@ -50,7 +50,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setScripts($scripts);
}
public function getRepositories()
public function getRepositories(): array
{
return $this->aliasOf->getRepositories();
}
@ -60,7 +60,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setRepositories($repositories);
}
public function getLicense()
public function getLicense(): array
{
return $this->aliasOf->getLicense();
}
@ -70,7 +70,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setLicense($license);
}
public function getKeywords()
public function getKeywords(): array
{
return $this->aliasOf->getKeywords();
}
@ -80,7 +80,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setKeywords($keywords);
}
public function getDescription()
public function getDescription(): ?string
{
return $this->aliasOf->getDescription();
}
@ -90,7 +90,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setDescription($description);
}
public function getHomepage()
public function getHomepage(): ?string
{
return $this->aliasOf->getHomepage();
}
@ -100,7 +100,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setHomepage($homepage);
}
public function getAuthors()
public function getAuthors(): array
{
return $this->aliasOf->getAuthors();
}
@ -110,7 +110,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setAuthors($authors);
}
public function getSupport()
public function getSupport(): array
{
return $this->aliasOf->getSupport();
}
@ -120,7 +120,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setSupport($support);
}
public function getFunding()
public function getFunding(): array
{
return $this->aliasOf->getFunding();
}
@ -130,12 +130,12 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setFunding($funding);
}
public function isAbandoned()
public function isAbandoned(): bool
{
return $this->aliasOf->isAbandoned();
}
public function getReplacementPackage()
public function getReplacementPackage(): ?string
{
return $this->aliasOf->getReplacementPackage();
}
@ -145,7 +145,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setAbandoned($abandoned);
}
public function getArchiveName()
public function getArchiveName(): ?string
{
return $this->aliasOf->getArchiveName();
}
@ -155,7 +155,7 @@ class CompleteAliasPackage extends AliasPackage implements CompletePackageInterf
$this->aliasOf->setArchiveName($name);
}
public function getArchiveExcludes()
public function getArchiveExcludes(): array
{
return $this->aliasOf->getArchiveExcludes();
}

View File

@ -26,7 +26,7 @@ class ArrayDumper
/**
* @return array<string, mixed>
*/
public function dump(PackageInterface $package)
public function dump(PackageInterface $package): array
{
$keys = array(
'binaries' => 'bin',

View File

@ -105,7 +105,7 @@ class Link
/**
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}
@ -113,7 +113,7 @@ class Link
/**
* @return string
*/
public function getSource()
public function getSource(): string
{
return $this->source;
}
@ -121,7 +121,7 @@ class Link
/**
* @return string
*/
public function getTarget()
public function getTarget(): string
{
return $this->target;
}
@ -129,7 +129,7 @@ class Link
/**
* @return ConstraintInterface
*/
public function getConstraint()
public function getConstraint(): ConstraintInterface
{
return $this->constraint;
}
@ -138,7 +138,7 @@ class Link
* @throws \UnexpectedValueException If no pretty constraint was provided
* @return string
*/
public function getPrettyConstraint()
public function getPrettyConstraint(): string
{
if (null === $this->prettyConstraint) {
throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
@ -159,7 +159,7 @@ class Link
* @param PackageInterface $sourcePackage
* @return string
*/
public function getPrettyString(PackageInterface $sourcePackage)
public function getPrettyString(PackageInterface $sourcePackage): string
{
return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.' '.$this->constraint->getPrettyString();
}

View File

@ -40,7 +40,7 @@ class InvalidPackageException extends \Exception
/**
* @return mixed[]
*/
public function getData()
public function getData(): array
{
return $this->data;
}
@ -48,7 +48,7 @@ class InvalidPackageException extends \Exception
/**
* @return string[]
*/
public function getErrors()
public function getErrors(): array
{
return $this->errors;
}
@ -56,7 +56,7 @@ class InvalidPackageException extends \Exception
/**
* @return string[]
*/
public function getWarnings()
public function getWarnings(): array
{
return $this->warnings;
}

View File

@ -431,7 +431,7 @@ class ValidatingArrayLoader implements LoaderInterface
/**
* @return string[]
*/
public function getWarnings()
public function getWarnings(): array
{
return $this->warnings;
}
@ -439,7 +439,7 @@ class ValidatingArrayLoader implements LoaderInterface
/**
* @return string[]
*/
public function getErrors()
public function getErrors(): array
{
return $this->errors;
}
@ -450,7 +450,7 @@ class ValidatingArrayLoader implements LoaderInterface
*
* @return string|null
*/
public static function hasPackageNamingError($name, $isLink = false)
public static function hasPackageNamingError($name, $isLink = false): ?string
{
if (PlatformRepository::isPlatformPackage($name)) {
return null;

View File

@ -78,7 +78,7 @@ class Locker
*
* @return string
*/
public static function getContentHash($composerFileContents)
public static function getContentHash($composerFileContents): string
{
$content = JsonFile::parseJson($composerFileContents, 'composer.json');
@ -115,7 +115,7 @@ class Locker
*
* @return bool
*/
public function isLocked()
public function isLocked(): bool
{
if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
return false;
@ -131,7 +131,7 @@ class Locker
*
* @return bool
*/
public function isFresh()
public function isFresh(): bool
{
$lock = $this->lockFile->read();
@ -156,7 +156,7 @@ class Locker
* @throws \RuntimeException
* @return \Composer\Repository\LockArrayRepository
*/
public function getLockedRepository($withDevReqs = false)
public function getLockedRepository($withDevReqs = false): \Composer\Repository\LockArrayRepository
{
$lockData = $this->getLockData();
$packages = new LockArrayRepository();
@ -205,7 +205,7 @@ class Locker
/**
* @return string[] Names of dependencies installed through require-dev
*/
public function getDevPackageNames()
public function getDevPackageNames(): array
{
$names = array();
$lockData = $this->getLockData();
@ -224,7 +224,7 @@ class Locker
* @param bool $withDevReqs if true, the platform requirements from the require-dev block are also returned
* @return \Composer\Package\Link[]
*/
public function getPlatformRequirements($withDevReqs = false)
public function getPlatformRequirements($withDevReqs = false): array
{
$lockData = $this->getLockData();
$requirements = array();
@ -255,7 +255,7 @@ class Locker
/**
* @return string
*/
public function getMinimumStability()
public function getMinimumStability(): string
{
$lockData = $this->getLockData();
@ -265,7 +265,7 @@ class Locker
/**
* @return array<string, string>
*/
public function getStabilityFlags()
public function getStabilityFlags(): array
{
$lockData = $this->getLockData();
@ -275,7 +275,7 @@ class Locker
/**
* @return bool|null
*/
public function getPreferStable()
public function getPreferStable(): ?bool
{
$lockData = $this->getLockData();
@ -287,7 +287,7 @@ class Locker
/**
* @return bool|null
*/
public function getPreferLowest()
public function getPreferLowest(): ?bool
{
$lockData = $this->getLockData();
@ -299,7 +299,7 @@ class Locker
/**
* @return array<string, string>
*/
public function getPlatformOverrides()
public function getPlatformOverrides(): array
{
$lockData = $this->getLockData();
@ -311,7 +311,7 @@ class Locker
*
* @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/
public function getAliases()
public function getAliases(): array
{
$lockData = $this->getLockData();
@ -321,7 +321,7 @@ class Locker
/**
* @return array<string, mixed>
*/
public function getLockData()
public function getLockData(): array
{
if (null !== $this->lockDataCache) {
return $this->lockDataCache;
@ -353,7 +353,7 @@ class Locker
*
* @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
*/
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true): bool
{
// keep old default branch names normalized to DEFAULT_BRANCH_ALIAS for BC as that is how Composer 1 outputs the lock file
// when loading the lock file the version is anyway ignored in Composer 2, so it has no adverse effect

View File

@ -35,7 +35,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/**
* @return RootPackage
*/
public function getAliasOf()
public function getAliasOf(): RootPackage
{
return $this->aliasOf;
}
@ -43,7 +43,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/**
* @inheritDoc
*/
public function getAliases()
public function getAliases(): array
{
return $this->aliasOf->getAliases();
}
@ -51,7 +51,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/**
* @inheritDoc
*/
public function getMinimumStability()
public function getMinimumStability(): string
{
return $this->aliasOf->getMinimumStability();
}
@ -59,7 +59,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/**
* @inheritDoc
*/
public function getStabilityFlags()
public function getStabilityFlags(): array
{
return $this->aliasOf->getStabilityFlags();
}
@ -67,7 +67,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/**
* @inheritDoc
*/
public function getReferences()
public function getReferences(): array
{
return $this->aliasOf->getReferences();
}
@ -75,7 +75,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/**
* @inheritDoc
*/
public function getPreferStable()
public function getPreferStable(): bool
{
return $this->aliasOf->getPreferStable();
}
@ -83,7 +83,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/**
* @inheritDoc
*/
public function getConfig()
public function getConfig(): array
{
return $this->aliasOf->getConfig();
}

View File

@ -45,7 +45,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface
/**
* @inheritDoc
*/
public function getMinimumStability()
public function getMinimumStability(): string
{
return $this->minimumStability;
}
@ -61,7 +61,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface
/**
* @inheritDoc
*/
public function getStabilityFlags()
public function getStabilityFlags(): array
{
return $this->stabilityFlags;
}
@ -77,7 +77,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface
/**
* @inheritDoc
*/
public function getPreferStable()
public function getPreferStable(): bool
{
return $this->preferStable;
}
@ -93,7 +93,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface
/**
* @inheritDoc
*/
public function getConfig()
public function getConfig(): array
{
return $this->config;
}
@ -109,7 +109,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface
/**
* @inheritDoc
*/
public function getReferences()
public function getReferences(): array
{
return $this->references;
}
@ -125,7 +125,7 @@ class RootPackage extends CompletePackage implements RootPackageInterface
/**
* @inheritDoc
*/
public function getAliases()
public function getAliases(): array
{
return $this->aliases;
}

View File

@ -30,7 +30,7 @@ class StabilityFilter
* @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev'
* @return bool true if any package name is acceptable
*/
public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, $stability)
public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, $stability): bool
{
foreach ($names as $name) {
// allow if package matches the package-specific stability flag

View File

@ -66,7 +66,7 @@ class VersionGuesser
* @return array|null
* @phpstan-return Version|null
*/
public function guessVersion(array $packageConfig, $path)
public function guessVersion(array $packageConfig, $path): ?array
{
if (!function_exists('proc_open')) {
return null;

View File

@ -172,7 +172,7 @@ class VersionSelector
* @param PackageInterface $package
* @return string
*/
public function findRecommendedRequireVersion(PackageInterface $package)
public function findRecommendedRequireVersion(PackageInterface $package): string
{
// Extensions which are versioned in sync with PHP should rather be required as "*" to simplify
// the requires and have only one required version to change when bumping the php requirement

View File

@ -0,0 +1,8 @@
<?php
namespace Composer;
class PartialComposer
{
}

View File

@ -42,7 +42,7 @@ class HhvmDetector
/**
* @return string|null
*/
public function getVersion()
public function getVersion(): ?string
{
if (null !== self::$hhvmVersion) {
return self::$hhvmVersion ?: null;

View File

@ -20,7 +20,7 @@ class Runtime
*
* @return bool
*/
public function hasConstant($constant, $class = null)
public function hasConstant($constant, $class = null): bool
{
return defined(ltrim($class.'::'.$constant, ':'));
}
@ -41,7 +41,7 @@ class Runtime
*
* @return bool
*/
public function hasFunction($fn)
public function hasFunction($fn): bool
{
return function_exists($fn);
}
@ -62,7 +62,7 @@ class Runtime
*
* @return bool
*/
public function hasClass($class)
public function hasClass($class): bool
{
return class_exists($class, false);
}
@ -74,7 +74,7 @@ class Runtime
* @return object
* @throws \ReflectionException
*/
public function construct($class, array $arguments = array())
public function construct($class, array $arguments = array()): object
{
if (empty($arguments)) {
return new $class;
@ -86,7 +86,7 @@ class Runtime
}
/** @return string[] */
public function getExtensions()
public function getExtensions(): array
{
return get_loaded_extensions();
}
@ -96,7 +96,7 @@ class Runtime
*
* @return string
*/
public function getExtensionVersion($extension)
public function getExtensionVersion($extension): string
{
return phpversion($extension);
}
@ -107,7 +107,7 @@ class Runtime
* @return string
* @throws \ReflectionException
*/
public function getExtensionInfo($extension)
public function getExtensionInfo($extension): string
{
$reflector = new \ReflectionExtension($extension);

View File

@ -24,7 +24,7 @@ class Version
* @param bool $isFips
* @return string|null
*/
public static function parseOpenssl($opensslVersion, &$isFips)
public static function parseOpenssl($opensslVersion, &$isFips): ?string
{
$isFips = false;
@ -43,7 +43,7 @@ class Version
* @param string $libjpegVersion
* @return string|null
*/
public static function parseLibjpeg($libjpegVersion)
public static function parseLibjpeg($libjpegVersion): ?string
{
if (!Preg::isMatch('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
return null;
@ -56,7 +56,7 @@ class Version
* @param string $zoneinfoVersion
* @return string|null
*/
public static function parseZoneinfoVersion($zoneinfoVersion)
public static function parseZoneinfoVersion($zoneinfoVersion): ?string
{
if (!Preg::isMatch('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
return null;
@ -80,7 +80,7 @@ class Version
* @param int $versionId
* @return string
*/
public static function convertLibxpmVersionId($versionId)
public static function convertLibxpmVersionId($versionId): string
{
return self::convertVersionId($versionId, 100);
}
@ -89,7 +89,7 @@ class Version
* @param int $versionId
* @return string
*/
public static function convertOpenldapVersionId($versionId)
public static function convertOpenldapVersionId($versionId): string
{
return self::convertVersionId($versionId, 100);
}

View File

@ -61,7 +61,7 @@ class CommandEvent extends Event
*
* @return InputInterface
*/
public function getInput()
public function getInput(): InputInterface
{
return $this->input;
}
@ -71,7 +71,7 @@ class CommandEvent extends Event
*
* @return OutputInterface
*/
public function getOutput()
public function getOutput(): OutputInterface
{
return $this->output;
}
@ -81,7 +81,7 @@ class CommandEvent extends Event
*
* @return string
*/
public function getCommandName()
public function getCommandName(): string
{
return $this->commandName;
}

View File

@ -130,7 +130,7 @@ class PluginManager
*
* @return array<PluginInterface> plugins
*/
public function getPlugins()
public function getPlugins(): array
{
return $this->plugins;
}
@ -140,7 +140,7 @@ class PluginManager
*
* @return Composer|null
*/
public function getGlobalComposer()
public function getGlobalComposer(): ?Composer
{
return $this->globalComposer;
}
@ -374,7 +374,7 @@ class PluginManager
*
* @return string
*/
protected function getPluginApiVersion()
protected function getPluginApiVersion(): string
{
return PluginInterface::PLUGIN_API_VERSION;
}
@ -567,7 +567,7 @@ class PluginManager
* @throws \RuntimeException On empty or non-string implementation class name value
* @return null|string The fully qualified class of the implementation or null if Plugin is not of Capable type or does not provide it
*/
protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability): ?string
{
if (!($plugin instanceof Capable)) {
return null;
@ -600,7 +600,7 @@ class PluginManager
* @phpstan-param class-string<CapabilityClass> $capabilityClassName
* @phpstan-return null|CapabilityClass
*/
public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array()): ?Capability
{
if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
if (!class_exists($capabilityClass)) {
@ -631,7 +631,7 @@ class PluginManager
* Keeping it an array will allow future values to be passed w\o changing the signature.
* @return CapabilityClass[]
*/
public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array()): array
{
$capabilities = array();
foreach ($this->getPlugins() as $plugin) {

View File

@ -81,7 +81,7 @@ class PostFileDownloadEvent extends Event
*
* @return string|null
*/
public function getFileName()
public function getFileName(): ?string
{
return $this->fileName;
}
@ -91,7 +91,7 @@ class PostFileDownloadEvent extends Event
*
* @return string|null
*/
public function getChecksum()
public function getChecksum(): ?string
{
return $this->checksum;
}
@ -101,7 +101,7 @@ class PostFileDownloadEvent extends Event
*
* @return string
*/
public function getUrl()
public function getUrl(): string
{
return $this->url;
}
@ -127,7 +127,7 @@ class PostFileDownloadEvent extends Event
* @return \Composer\Package\PackageInterface|null The package.
* @deprecated Use getContext instead
*/
public function getPackage()
public function getPackage(): ?\Composer\Package\PackageInterface
{
trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
$context = $this->getContext();
@ -140,7 +140,7 @@ class PostFileDownloadEvent extends Event
*
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}

View File

@ -51,7 +51,7 @@ class PreCommandRunEvent extends Event
*
* @return InputInterface
*/
public function getInput()
public function getInput(): InputInterface
{
return $this->input;
}
@ -61,7 +61,7 @@ class PreCommandRunEvent extends Event
*
* @return string
*/
public function getCommand()
public function getCommand(): string
{
return $this->command;
}

View File

@ -73,7 +73,7 @@ class PreFileDownloadEvent extends Event
/**
* @return HttpDownloader
*/
public function getHttpDownloader()
public function getHttpDownloader(): HttpDownloader
{
return $this->httpDownloader;
}
@ -83,7 +83,7 @@ class PreFileDownloadEvent extends Event
*
* @return string
*/
public function getProcessedUrl()
public function getProcessedUrl(): string
{
return $this->processedUrl;
}
@ -105,7 +105,7 @@ class PreFileDownloadEvent extends Event
*
* @return string|null
*/
public function getCustomCacheKey()
public function getCustomCacheKey(): ?string
{
return $this->customCacheKey;
}
@ -127,7 +127,7 @@ class PreFileDownloadEvent extends Event
*
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}
@ -152,7 +152,7 @@ class PreFileDownloadEvent extends Event
*
* @return mixed[]
*/
public function getTransportOptions()
public function getTransportOptions(): array
{
return $this->transportOptions;
}

View File

@ -93,7 +93,7 @@ class PrePoolCreateEvent extends Event
/**
* @return RepositoryInterface[]
*/
public function getRepositories()
public function getRepositories(): array
{
return $this->repositories;
}
@ -101,7 +101,7 @@ class PrePoolCreateEvent extends Event
/**
* @return Request
*/
public function getRequest()
public function getRequest(): Request
{
return $this->request;
}
@ -110,7 +110,7 @@ class PrePoolCreateEvent extends Event
* @return int[] array of stability => BasePackage::STABILITY_* value
* @phpstan-return array<string, BasePackage::STABILITY_*>
*/
public function getAcceptableStabilities()
public function getAcceptableStabilities(): array
{
return $this->acceptableStabilities;
}
@ -119,7 +119,7 @@ class PrePoolCreateEvent extends Event
* @return int[] array of package name => BasePackage::STABILITY_* value
* @phpstan-return array<string, BasePackage::STABILITY_*>
*/
public function getStabilityFlags()
public function getStabilityFlags(): array
{
return $this->stabilityFlags;
}
@ -128,7 +128,7 @@ class PrePoolCreateEvent extends Event
* @return array[] of package => version => [alias, alias_normalized]
* @phpstan-return array<string, array<string, array{alias: string, alias_normalized: string}>>
*/
public function getRootAliases()
public function getRootAliases(): array
{
return $this->rootAliases;
}
@ -137,7 +137,7 @@ class PrePoolCreateEvent extends Event
* @return string[]
* @phpstan-return array<string, string>
*/
public function getRootReferences()
public function getRootReferences(): array
{
return $this->rootReferences;
}
@ -145,7 +145,7 @@ class PrePoolCreateEvent extends Event
/**
* @return BasePackage[]
*/
public function getPackages()
public function getPackages(): array
{
return $this->packages;
}
@ -153,7 +153,7 @@ class PrePoolCreateEvent extends Event
/**
* @return BasePackage[]
*/
public function getUnacceptableFixedPackages()
public function getUnacceptableFixedPackages(): array
{
return $this->unacceptableFixedPackages;
}

View File

@ -12,6 +12,7 @@
namespace Composer\Repository;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
/**
@ -39,7 +40,7 @@ class CompositeRepository implements RepositoryInterface
}
}
public function getRepoName()
public function getRepoName(): string
{
return 'composite repo ('.implode(', ', array_map(function ($repo) {
return $repo->getRepoName();
@ -51,7 +52,7 @@ class CompositeRepository implements RepositoryInterface
*
* @return RepositoryInterface[]
*/
public function getRepositories()
public function getRepositories(): array
{
return $this->repositories;
}
@ -59,7 +60,7 @@ class CompositeRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function hasPackage(PackageInterface $package)
public function hasPackage(PackageInterface $package): bool
{
foreach ($this->repositories as $repository) {
/* @var $repository RepositoryInterface */
@ -74,7 +75,7 @@ class CompositeRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function findPackage($name, $constraint)
public function findPackage($name, $constraint): ?BasePackage
{
foreach ($this->repositories as $repository) {
/* @var $repository RepositoryInterface */
@ -90,7 +91,7 @@ class CompositeRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function findPackages($name, $constraint = null)
public function findPackages($name, $constraint = null): array
{
$packages = array();
foreach ($this->repositories as $repository) {
@ -104,7 +105,7 @@ class CompositeRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array()): array
{
$packages = array();
$namesFound = array();
@ -124,7 +125,7 @@ class CompositeRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function search($query, $mode = 0, $type = null)
public function search($query, $mode = 0, $type = null): array
{
$matches = array();
foreach ($this->repositories as $repository) {
@ -138,7 +139,7 @@ class CompositeRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function getPackages()
public function getPackages(): array
{
$packages = array();
foreach ($this->repositories as $repository) {
@ -152,7 +153,7 @@ class CompositeRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function getProviders($packageName)
public function getProviders($packageName): array
{
$results = array();
foreach ($this->repositories as $repository) {

View File

@ -62,7 +62,7 @@ class FilterRepository implements RepositoryInterface
$this->repo = $repo;
}
public function getRepoName()
public function getRepoName(): string
{
return $this->repo->getRepoName();
}
@ -72,7 +72,7 @@ class FilterRepository implements RepositoryInterface
*
* @return RepositoryInterface
*/
public function getRepository()
public function getRepository(): RepositoryInterface
{
return $this->repo;
}
@ -80,7 +80,7 @@ class FilterRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function hasPackage(PackageInterface $package)
public function hasPackage(PackageInterface $package): bool
{
return $this->repo->hasPackage($package);
}
@ -88,7 +88,7 @@ class FilterRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function findPackage($name, $constraint)
public function findPackage($name, $constraint): ?BasePackage
{
if (!$this->isAllowed($name)) {
return null;
@ -100,7 +100,7 @@ class FilterRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function findPackages($name, $constraint = null)
public function findPackages($name, $constraint = null): array
{
if (!$this->isAllowed($name)) {
return array();
@ -112,7 +112,7 @@ class FilterRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array()): array
{
foreach ($packageMap as $name => $constraint) {
if (!$this->isAllowed($name)) {
@ -135,7 +135,7 @@ class FilterRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function search($query, $mode = 0, $type = null)
public function search($query, $mode = 0, $type = null): array
{
$result = array();
@ -151,7 +151,7 @@ class FilterRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function getPackages()
public function getPackages(): array
{
$result = array();
foreach ($this->repo->getPackages() as $package) {
@ -166,7 +166,7 @@ class FilterRepository implements RepositoryInterface
/**
* @inheritDoc
*/
public function getProviders($packageName)
public function getProviders($packageName): array
{
$result = array();
foreach ($this->repo->getProviders($packageName) as $name => $provider) {

View File

@ -21,7 +21,7 @@ namespace Composer\Repository;
*/
class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
{
public function getRepoName()
public function getRepoName(): string
{
return 'installed '.parent::getRepoName();
}
@ -29,7 +29,7 @@ class InstalledArrayRepository extends WritableArrayRepository implements Instal
/**
* @inheritDoc
*/
public function isFresh()
public function isFresh(): bool
{
// this is not a completely correct implementation but there is no way to
// distinguish an empty repo and a newly created one given this is all in-memory

View File

@ -38,7 +38,7 @@ class InstalledRepository extends CompositeRepository
*
* @return BasePackage[]
*/
public function findPackagesWithReplacersAndProviders($name, $constraint = null)
public function findPackagesWithReplacersAndProviders($name, $constraint = null): array
{
$name = strtolower($name);
@ -87,7 +87,7 @@ class InstalledRepository extends CompositeRepository
* @return array[] An associative array of arrays as described above.
* @phpstan-return array<array{0: PackageInterface, 1: Link, 2: mixed[]|bool}>
*/
public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null): array
{
$needles = array_map('strtolower', (array) $needle);
$results = array();
@ -249,7 +249,7 @@ class InstalledRepository extends CompositeRepository
return $results;
}
public function getRepoName()
public function getRepoName(): string
{
return 'installed repo ('.implode(', ', array_map(function ($repo) {
return $repo->getRepoName();

View File

@ -21,7 +21,7 @@ namespace Composer\Repository;
*/
class LockArrayRepository extends ArrayRepository
{
public function getRepoName()
public function getRepoName(): string
{
return 'lock repo';
}

View File

@ -61,7 +61,7 @@ class PackageRepository extends ArrayRepository
}
}
public function getRepoName()
public function getRepoName(): string
{
return Preg::replace('{^array }', 'package ', parent::getRepoName());
}

View File

@ -129,12 +129,12 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
parent::__construct();
}
public function getRepoName()
public function getRepoName(): string
{
return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
}
public function getRepoConfig()
public function getRepoConfig(): array
{
return $this->repoConfig;
}

View File

@ -84,7 +84,7 @@ class PlatformRepository extends ArrayRepository
parent::__construct($packages);
}
public function getRepoName()
public function getRepoName(): string
{
return 'platform repo';
}
@ -93,7 +93,7 @@ class PlatformRepository extends ArrayRepository
* @param string $name
* @return bool
*/
public function isPlatformPackageDisabled($name)
public function isPlatformPackageDisabled($name): bool
{
return isset($this->disabledPackages[$name]);
}
@ -101,7 +101,7 @@ class PlatformRepository extends ArrayRepository
/**
* @return array<string, CompletePackageInterface>
*/
public function getDisabledPackages()
public function getDisabledPackages(): array
{
return $this->disabledPackages;
}
@ -704,7 +704,7 @@ class PlatformRepository extends ArrayRepository
* @param string $name
* @return bool
*/
public static function isPlatformPackage($name)
public static function isPlatformPackage($name): bool
{
static $cache = array();
@ -730,7 +730,7 @@ class PlatformRepository extends ArrayRepository
return self::$lastSeenPlatformPhp;
}
public function search($query, $mode = 0, $type = null)
public function search($query, $mode = 0, $type = null): array
{
// suppress vendor search as there are no vendors to match in platform packages
if ($mode === self::SEARCH_VENDOR) {

View File

@ -64,7 +64,7 @@ class RepositoryFactory
* @param bool $allowFilesystem
* @return RepositoryInterface
*/
public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null): RepositoryInterface
{
$repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
@ -77,7 +77,7 @@ class RepositoryFactory
* @param array<string, mixed> $repoConfig
* @return RepositoryInterface
*/
public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null): RepositoryInterface
{
if (!$rm) {
$rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
@ -93,7 +93,7 @@ class RepositoryFactory
* @param RepositoryManager|null $rm
* @return RepositoryInterface[]
*/
public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null): array
{
if (!$config) {
$config = Factory::createConfig($io);
@ -118,7 +118,7 @@ class RepositoryFactory
* @param HttpDownloader $httpDownloader
* @return RepositoryManager
*/
public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null): RepositoryManager
{
$rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
@ -178,9 +178,9 @@ class RepositoryFactory
*
* @return string
*/
public static function generateRepositoryName($index, array $repo, array $existingRepos)
public static function generateRepositoryName($index, array $repo, array $existingRepos): string
{
$name = is_int($index) && isset($repo['url']) ? Preg::replace('{^https?://}i', '', $repo['url']) : $index;
$name = is_int($index) && isset($repo['url']) ? Preg::replace('{^https?://}i', '', $repo['url']) : (string) $index;
while (isset($existingRepos[$name])) {
$name .= '2';
}

View File

@ -127,7 +127,7 @@ class RepositorySet
* @return ConstraintInterface[] an array of package name => constraint from the root package, platform requirements excluded
* @phpstan-return array<string, ConstraintInterface>
*/
public function getRootRequires()
public function getRootRequires(): array
{
return $this->rootRequires;
}
@ -169,7 +169,7 @@ class RepositorySet
* @param int $flags any of the ALLOW_* constants from this class to tweak what is returned
* @return BasePackage[]
*/
public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0): array
{
$ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
$loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
@ -216,7 +216,7 @@ class RepositorySet
* @return array[] an array with the provider name as key and value of array('name' => '...', 'description' => '...', 'type' => '...')
* @phpstan-return array<string, array{name: string, description: string, type: string}>
*/
public function getProviders($packageName)
public function getProviders($packageName): array
{
$providers = array();
foreach ($this->repositories as $repository) {
@ -235,7 +235,7 @@ class RepositorySet
* @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev'
* @return bool
*/
public function isPackageAcceptable($names, $stability)
public function isPackageAcceptable($names, $stability): bool
{
return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
}
@ -245,7 +245,7 @@ class RepositorySet
*
* @return Pool
*/
public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null, PoolOptimizer $poolOptimizer = null)
public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null, PoolOptimizer $poolOptimizer = null): Pool
{
$poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher, $poolOptimizer);
@ -265,7 +265,7 @@ class RepositorySet
*
* @return Pool
*/
public function createPoolWithAllPackages()
public function createPoolWithAllPackages(): Pool
{
foreach ($this->repositories as $repo) {
if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
@ -304,7 +304,7 @@ class RepositorySet
*
* @return Pool
*/
public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null): Pool
{
// TODO unify this with above in some simpler version without "request"?
return $this->createPoolForPackages(array($packageName), $lockedRepo);
@ -315,7 +315,7 @@ class RepositorySet
*
* @return Pool
*/
public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null): Pool
{
$request = new Request($lockedRepo);

View File

@ -28,7 +28,7 @@ class RootPackageRepository extends ArrayRepository
parent::__construct(array($package));
}
public function getRepoName()
public function getRepoName(): string
{
return 'root package repo';
}

View File

@ -121,7 +121,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getRootIdentifier()
public function getRootIdentifier(): string
{
if (null === $this->rootIdentifier) {
$this->rootIdentifier = 'trunk';
@ -133,7 +133,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getUrl()
public function getUrl(): string
{
return $this->url;
}
@ -141,7 +141,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getSource($identifier)
public function getSource($identifier): array
{
return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
}
@ -149,7 +149,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getDist($identifier)
public function getDist($identifier): ?array
{
return null;
}
@ -157,7 +157,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getFileContent($file, $identifier)
public function getFileContent($file, $identifier): ?string
{
$command = sprintf('fossil cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
$this->process->execute($command, $content, $this->checkoutDir);
@ -172,7 +172,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getChangeDate($identifier)
public function getChangeDate($identifier): ?\DateTime
{
$this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
list(, $date) = explode(' ', trim($output), 3);
@ -183,7 +183,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getTags()
public function getTags(): array
{
if (null === $this->tags) {
$tags = array();
@ -202,7 +202,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getBranches()
public function getBranches(): array
{
if (null === $this->branches) {
$branches = array();
@ -222,7 +222,7 @@ class FossilDriver extends VcsDriver
/**
* @inheritDoc
*/
public static function supports(IOInterface $io, Config $config, $url, $deep = false)
public static function supports(IOInterface $io, Config $config, $url, $deep = false): bool
{
if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
return true;

View File

@ -144,7 +144,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getComposerInformation($identifier)
public function getComposerInformation($identifier): array
{
if ($this->gitDriver) {
return $this->gitDriver->getComposerInformation($identifier);
@ -184,7 +184,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getFileContent($file, $identifier)
public function getFileContent($file, $identifier): ?string
{
if ($this->gitDriver) {
return $this->gitDriver->getFileContent($file, $identifier);
@ -216,7 +216,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getChangeDate($identifier)
public function getChangeDate($identifier): ?\DateTime
{
if ($this->gitDriver) {
return $this->gitDriver->getChangeDate($identifier);
@ -232,7 +232,7 @@ class GitLabDriver extends VcsDriver
/**
* @return string
*/
public function getRepositoryUrl()
public function getRepositoryUrl(): string
{
if ($this->protocol) {
return $this->project["{$this->protocol}_url_to_repo"];
@ -244,7 +244,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getUrl()
public function getUrl(): string
{
if ($this->gitDriver) {
return $this->gitDriver->getUrl();
@ -256,7 +256,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getDist($identifier)
public function getDist($identifier): ?array
{
$url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
@ -266,7 +266,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getSource($identifier)
public function getSource($identifier): array
{
if ($this->gitDriver) {
return $this->gitDriver->getSource($identifier);
@ -278,7 +278,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getRootIdentifier()
public function getRootIdentifier(): string
{
if ($this->gitDriver) {
return $this->gitDriver->getRootIdentifier();
@ -290,7 +290,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getBranches()
public function getBranches(): array
{
if ($this->gitDriver) {
return $this->gitDriver->getBranches();
@ -306,7 +306,7 @@ class GitLabDriver extends VcsDriver
/**
* @inheritDoc
*/
public function getTags()
public function getTags(): array
{
if ($this->gitDriver) {
return $this->gitDriver->getTags();
@ -322,7 +322,7 @@ class GitLabDriver extends VcsDriver
/**
* @return string Base URL for GitLab API v3
*/
public function getApiUrl()
public function getApiUrl(): string
{
return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
}
@ -352,7 +352,7 @@ class GitLabDriver extends VcsDriver
*
* @return string[] where keys are named references like tags or branches and the value a sha
*/
protected function getReferences($type)
protected function getReferences($type): array
{
$perPage = 100;
$resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
@ -402,7 +402,7 @@ class GitLabDriver extends VcsDriver
* @return true
* @throws \RuntimeException
*/
protected function attemptCloneFallback()
protected function attemptCloneFallback(): bool
{
if ($this->isPrivate === false) {
$url = $this->generatePublicUrl();
@ -430,7 +430,7 @@ class GitLabDriver extends VcsDriver
*
* @return string
*/
protected function generateSshUrl()
protected function generateSshUrl(): string
{
if ($this->hasNonstandardOrigin) {
return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
@ -442,7 +442,7 @@ class GitLabDriver extends VcsDriver
/**
* @return string
*/
protected function generatePublicUrl()
protected function generatePublicUrl(): string
{
return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
}
@ -469,7 +469,7 @@ class GitLabDriver extends VcsDriver
*
* @param bool $fetchingRepoData
*/
protected function getContents($url, $fetchingRepoData = false)
protected function getContents($url, $fetchingRepoData = false): Response
{
try {
$response = parent::getContents($url);
@ -568,7 +568,7 @@ class GitLabDriver extends VcsDriver
*
* @inheritDoc
*/
public static function supports(IOInterface $io, Config $config, $url, $deep = false)
public static function supports(IOInterface $io, Config $config, $url, $deep = false): bool
{
if (!Preg::isMatch(self::URL_REGEX, $url, $match)) {
return false;
@ -594,7 +594,7 @@ class GitLabDriver extends VcsDriver
/**
* @return string|null
*/
protected function getNextPage(Response $response)
protected function getNextPage(Response $response): ?string
{
$header = $response->getHeader('link');

View File

@ -12,6 +12,7 @@
namespace Composer\Repository;
use Composer\Package\PackageInterface;
use Composer\Package\AliasPackage;
use Composer\Installer\InstallationManager;

View File

@ -24,7 +24,7 @@ class Keys
*
* @return string
*/
public static function fingerprint($path)
public static function fingerprint($path): string
{
$hash = strtoupper(hash('sha256', Preg::replace('{\s}', '', file_get_contents($path))));

View File

@ -41,7 +41,7 @@ class Versions
/**
* @return string
*/
public function getChannel()
public function getChannel(): string
{
if ($this->channel) {
return $this->channel;
@ -79,7 +79,7 @@ class Versions
*
* @return array{path: string, version: string, min-php: int}
*/
public function getLatest($channel = null)
public function getLatest($channel = null): array
{
$versions = $this->getVersionsData();

View File

@ -83,7 +83,7 @@ class AuthHelper
* retried, if storeAuth is true then on a successful retry the authentication should be persisted to auth.json
* @phpstan-return ?array{retry: bool, storeAuth: string|bool}
*/
public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array()): ?array
{
$storeAuth = false;
@ -215,7 +215,7 @@ class AuthHelper
*
* @return string[] updated headers array
*/
public function addAuthenticationHeader(array $headers, $origin, $url)
public function addAuthenticationHeader(array $headers, $origin, $url): array
{
if ($this->io->hasAuthentication($origin)) {
$authenticationDisplayMessage = null;
@ -272,7 +272,7 @@ class AuthHelper
*
* @return bool Whether the given URL is a public BitBucket download which requires no authentication.
*/
public function isPublicBitBucketDownload($urlToBitBucketFile)
public function isPublicBitBucketDownload($urlToBitBucketFile): bool
{
$domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
if (strpos($domain, 'bitbucket.org') === false) {

View File

@ -58,7 +58,7 @@ class Bitbucket
/**
* @return string
*/
public function getToken()
public function getToken(): string
{
if (!isset($this->token['access_token'])) {
return '';
@ -73,7 +73,7 @@ class Bitbucket
* @param string $originUrl The host this Bitbucket instance is located at
* @return bool true on success
*/
public function authorizeOAuth($originUrl)
public function authorizeOAuth($originUrl): bool
{
if ($originUrl !== 'bitbucket.org') {
return false;
@ -140,7 +140,7 @@ class Bitbucket
* @throws TransportException|\Exception
* @return bool true on success
*/
public function authorizeOAuthInteractively($originUrl, $message = null)
public function authorizeOAuthInteractively($originUrl, $message = null): bool
{
if ($message) {
$this->io->writeError($message);
@ -194,7 +194,7 @@ class Bitbucket
* @param string $consumerSecret
* @return string
*/
public function requestToken($originUrl, $consumerKey, $consumerSecret)
public function requestToken($originUrl, $consumerKey, $consumerSecret): string
{
if ($this->token !== null || $this->getTokenFromConfig($originUrl)) {
return $this->token['access_token'];

View File

@ -31,7 +31,7 @@ class ComposerMirror
*
* @return string
*/
public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type, $prettyVersion = null)
public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type, $prettyVersion = null): string
{
if ($reference) {
$reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
@ -56,7 +56,7 @@ class ComposerMirror
*
* @return string
*/
public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
public static function processGitUrl($mirrorUrl, $packageName, $url, $type): string
{
if (Preg::isMatch('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
$url = 'gh-'.$match[1].'/'.$match[2];
@ -81,7 +81,7 @@ class ComposerMirror
*
* @return string
*/
public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
public static function processHgUrl($mirrorUrl, $packageName, $url, $type): string
{
return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
}

View File

@ -48,7 +48,7 @@ class ConfigValidator
*
* @return array{list<string>, list<string>, list<string>} a triple containing the errors, publishable errors, and warnings
*/
public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION): array
{
$errors = array();
$publishErrors = array();

Some files were not shown because too many files have changed in this diff Show More