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 * @return array<class-string, string> A class map array
* @throws \RuntimeException When the path is neither an existing file nor directory * @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; $basePath = $path;
if (is_string($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) * @param bool $inverted Whether to invert matching process (why-not vs why behaviour)
* @return int Exit code of the operation. * @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 // Emit command event on startup
$composer = $this->requireComposer(); $composer = $this->requireComposer();

View File

@ -187,7 +187,7 @@ EOT
* @return int * @return int
* @throws \Exception * @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(); $oldCwd = getcwd();
@ -350,7 +350,7 @@ EOT
* @return bool * @return bool
* @throws \Exception * @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) { if (!$secureHttp) {
$config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND); $config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -38,7 +38,7 @@ class MarkAliasInstalledOperation extends SolverOperation implements OperationIn
* *
* @return AliasPackage * @return AliasPackage
*/ */
public function getPackage() public function getPackage(): AliasPackage
{ {
return $this->package; return $this->package;
} }
@ -46,7 +46,7 @@ class MarkAliasInstalledOperation extends SolverOperation implements OperationIn
/** /**
* @inheritDoc * @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>)'; 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 * @return AliasPackage
*/ */
public function getPackage() public function getPackage(): AliasPackage
{ {
return $this->package; return $this->package;
} }
@ -46,7 +46,7 @@ class MarkAliasUninstalledOperation extends SolverOperation implements Operation
/** /**
* @inheritDoc * @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>)'; 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 * @return PackageInterface
*/ */
public function getPackage() public function getPackage(): PackageInterface
{ {
return $this->package; return $this->package;
} }
@ -46,7 +46,7 @@ class UninstallOperation extends SolverOperation implements OperationInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function show($lock) public function show($lock): string
{ {
return self::format($this->package, $lock); return self::format($this->package, $lock);
} }
@ -55,7 +55,7 @@ class UninstallOperation extends SolverOperation implements OperationInterface
* @param bool $lock * @param bool $lock
* @return string * @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>)'; return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
} }

View File

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

View File

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

View File

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

View File

@ -71,7 +71,7 @@ class PoolOptimizer
/** /**
* @return Pool * @return Pool
*/ */
public function optimize(Request $request, Pool $pool) public function optimize(Request $request, Pool $pool): Pool
{ {
$this->prepare($request, $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 * @param Rule $rule A rule which is a reason for this problem
* @return void * @return void
*/ */
public function addRule(Rule $rule) public function addRule(Rule $rule): void
{ {
$this->addReason(spl_object_hash($rule), $rule); $this->addReason(spl_object_hash($rule), $rule);
} }
@ -64,7 +64,7 @@ class Problem
* *
* @return array<int, array<int, Rule>> The problem's reasons * @return array<int, array<int, Rule>> The problem's reasons
*/ */
public function getReasons() public function getReasons(): array
{ {
return $this->reasons; return $this->reasons;
} }
@ -77,7 +77,7 @@ class Problem
* @param array<Rule[]> $learnedPool * @param array<Rule[]> $learnedPool
* @return string * @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? // 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)); $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
@ -165,7 +165,7 @@ class Problem
/** /**
* @return bool * @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 ($this->reasons as $sectionRules) {
foreach ($sectionRules as $rule) { foreach ($sectionRules as $rule) {
@ -185,7 +185,7 @@ class Problem
* @param Rule $reason The reason descriptor * @param Rule $reason The reason descriptor
* @return void * @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 // 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? // that is important to understand the issue?
@ -199,7 +199,7 @@ class Problem
/** /**
* @return void * @return void
*/ */
public function nextSection() public function nextSection(): void
{ {
$this->section++; $this->section++;
} }
@ -576,7 +576,7 @@ class Problem
* *
* @return string * @return string
*/ */
protected static function constraintToText(ConstraintInterface $constraint = null) protected static function constraintToText(ConstraintInterface $constraint = null): string
{ {
return $constraint ? ' '.$constraint->getPrettyString() : ''; return $constraint ? ' '.$constraint->getPrettyString() : '';
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -88,7 +88,7 @@ class RuleWatchGraph
* register decisions resulting from propagation * register decisions resulting from propagation
* @return Rule|null If a conflict is found the conflicting rule is returned * @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: // we invert the decided literal here, example:
// A was decided => (-A|B) now requires B to be true, so we look for // 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 * @return Rule
*/ */
public function getRule() public function getRule(): Rule
{ {
return $this->rule; return $this->rule;
} }
@ -91,7 +91,7 @@ class RuleWatchNode
* @param int $literal The watched literal that should not be returned * @param int $literal The watched literal that should not be returned
* @return int A literal * @return int A literal
*/ */
public function getOtherWatch($literal) public function getOtherWatch($literal): int
{ {
if ($this->watch1 == $literal) { if ($this->watch1 == $literal) {
return $this->watch2; return $this->watch2;

View File

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

View File

@ -46,7 +46,7 @@ class SolverProblemsException extends \RuntimeException
* @param bool $isDevExtraction * @param bool $isDevExtraction
* @return string * @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); $installedMap = $request->getPresentMap(true);
$missingExtensions = array(); $missingExtensions = array();
@ -100,7 +100,7 @@ class SolverProblemsException extends \RuntimeException
/** /**
* @return Problem[] * @return Problem[]
*/ */
public function getProblems() public function getProblems(): array
{ {
return $this->problems; return $this->problems;
} }

View File

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

View File

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

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Util\Platform; use Composer\Util\Platform;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
@ -23,7 +24,7 @@ use Composer\Util\ProcessExecutor;
*/ */
class GzipDownloader extends ArchiveDownloader 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); $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
$targetFilepath = $path . DIRECTORY_SEPARATOR . $filename; $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,6 +12,7 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
@ -23,7 +24,7 @@ use Composer\Util\ProcessExecutor;
*/ */
class XzDownloader extends ArchiveDownloader 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); $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,6 +12,7 @@
namespace Composer\Installer; namespace Composer\Installer;
use React\Promise\PromiseInterface;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Downloader\DownloadManager; use Composer\Downloader\DownloadManager;
use Composer\Repository\InstalledRepositoryInterface; use Composer\Repository\InstalledRepositoryInterface;
@ -48,7 +49,7 @@ class ProjectInstaller implements InstallerInterface
* @param string $packageType * @param string $packageType
* @return bool * @return bool
*/ */
public function supports($packageType) public function supports($packageType): bool
{ {
return true; return true;
} }
@ -56,7 +57,7 @@ class ProjectInstaller implements InstallerInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
{ {
return false; return false;
} }
@ -64,7 +65,7 @@ class ProjectInstaller implements InstallerInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function download(PackageInterface $package, PackageInterface $prevPackage = null) public function download(PackageInterface $package, PackageInterface $prevPackage = null): ?PromiseInterface
{ {
$installPath = $this->installPath; $installPath = $this->installPath;
if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) { if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
@ -80,7 +81,7 @@ class ProjectInstaller implements InstallerInterface
/** /**
* @inheritDoc * @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); return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
} }
@ -88,7 +89,7 @@ class ProjectInstaller implements InstallerInterface
/** /**
* @inheritDoc * @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); return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
} }
@ -96,7 +97,7 @@ class ProjectInstaller implements InstallerInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) public function install(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
{ {
return $this->downloadManager->install($package, $this->installPath); return $this->downloadManager->install($package, $this->installPath);
} }
@ -104,7 +105,7 @@ class ProjectInstaller implements InstallerInterface
/** /**
* @inheritDoc * @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"); throw new \InvalidArgumentException("not supported");
} }
@ -112,7 +113,7 @@ class ProjectInstaller implements InstallerInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
{ {
throw new \InvalidArgumentException("not supported"); throw new \InvalidArgumentException("not supported");
} }
@ -123,7 +124,7 @@ class ProjectInstaller implements InstallerInterface
* @param PackageInterface $package * @param PackageInterface $package
* @return string path * @return string path
*/ */
public function getInstallPath(PackageInterface $package) public function getInstallPath(PackageInterface $package): string
{ {
return $this->installPath; 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. * @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; return $this->suggestedPackages;
} }
@ -63,7 +63,7 @@ class SuggestedPackagesReporter
* @param string $reason Reason the target package to be suggested * @param string $reason Reason the target package to be suggested
* @return SuggestedPackagesReporter * @return SuggestedPackagesReporter
*/ */
public function addPackage($source, $target, $reason) public function addPackage($source, $target, $reason): SuggestedPackagesReporter
{ {
$this->suggestedPackages[] = array( $this->suggestedPackages[] = array(
'source' => $source, 'source' => $source,
@ -80,7 +80,7 @@ class SuggestedPackagesReporter
* @param PackageInterface $package * @param PackageInterface $package
* @return SuggestedPackagesReporter * @return SuggestedPackagesReporter
*/ */
public function addSuggestionsFromPackage(PackageInterface $package) public function addSuggestionsFromPackage(PackageInterface $package): SuggestedPackagesReporter
{ {
$source = $package->getPrettyName(); $source = $package->getPrettyName();
foreach ($package->getSuggests() as $target => $reason) { foreach ($package->getSuggests() as $target => $reason) {

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ interface ArchiverInterface
* *
* @return string The path to the written archive file * @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. * Format supported by the archiver.
@ -40,5 +40,5 @@ interface ArchiverInterface
* *
* @return bool true if the format is supported by the archiver * @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 * @return bool Whether the file should be excluded
*/ */
public function filter($relativePath, $exclude) public function filter($relativePath, $exclude): bool
{ {
foreach ($this->excludePatterns as $patternData) { foreach ($this->excludePatterns as $patternData) {
list($pattern, $negate, $stripLeadingSlash) = $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() * @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( return array_filter(
array_map( array_map(
@ -108,7 +108,7 @@ abstract class BaseExcludeFilter
* *
* @return array<int, array{0: non-empty-string, 1: bool, 2: bool}> Exclude patterns * @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(); $patterns = array();
foreach ($rules as $rule) { foreach ($rules as $rule) {
@ -125,7 +125,7 @@ abstract class BaseExcludeFilter
* *
* @return array{0: non-empty-string, 1: bool, 2: bool} An exclude pattern * @return array{0: non-empty-string, 1: bool, 2: bool} An exclude pattern
*/ */
protected function generatePattern($rule) protected function generatePattern($rule): array
{ {
$negate = false; $negate = false;
$pattern = ''; $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() * @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); $parts = Preg::split('#\s+#', $line);

View File

@ -36,7 +36,7 @@ class PharArchiver implements ArchiverInterface
/** /**
* @inheritDoc * @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); $sources = realpath($sources);
@ -97,7 +97,7 @@ class PharArchiver implements ArchiverInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function supports($format, $sourceType) public function supports($format, $sourceType): bool
{ {
return isset(static::$formats[$format]); return isset(static::$formats[$format]);
} }

View File

@ -28,7 +28,7 @@ class ZipArchiver implements ArchiverInterface
/** /**
* @inheritDoc * @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(); $fs = new Filesystem();
$sources = $fs->normalizePath($sources); $sources = $fs->normalizePath($sources);
@ -78,7 +78,7 @@ class ZipArchiver implements ArchiverInterface
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function supports($format, $sourceType) public function supports($format, $sourceType): bool
{ {
return isset(static::$formats[$format]) && $this->compressionAvailable(); return isset(static::$formats[$format]) && $this->compressionAvailable();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -78,7 +78,7 @@ class Locker
* *
* @return string * @return string
*/ */
public static function getContentHash($composerFileContents) public static function getContentHash($composerFileContents): string
{ {
$content = JsonFile::parseJson($composerFileContents, 'composer.json'); $content = JsonFile::parseJson($composerFileContents, 'composer.json');
@ -115,7 +115,7 @@ class Locker
* *
* @return bool * @return bool
*/ */
public function isLocked() public function isLocked(): bool
{ {
if (!$this->virtualFileWritten && !$this->lockFile->exists()) { if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
return false; return false;
@ -131,7 +131,7 @@ class Locker
* *
* @return bool * @return bool
*/ */
public function isFresh() public function isFresh(): bool
{ {
$lock = $this->lockFile->read(); $lock = $this->lockFile->read();
@ -156,7 +156,7 @@ class Locker
* @throws \RuntimeException * @throws \RuntimeException
* @return \Composer\Repository\LockArrayRepository * @return \Composer\Repository\LockArrayRepository
*/ */
public function getLockedRepository($withDevReqs = false) public function getLockedRepository($withDevReqs = false): \Composer\Repository\LockArrayRepository
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
$packages = new LockArrayRepository(); $packages = new LockArrayRepository();
@ -205,7 +205,7 @@ class Locker
/** /**
* @return string[] Names of dependencies installed through require-dev * @return string[] Names of dependencies installed through require-dev
*/ */
public function getDevPackageNames() public function getDevPackageNames(): array
{ {
$names = array(); $names = array();
$lockData = $this->getLockData(); $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 * @param bool $withDevReqs if true, the platform requirements from the require-dev block are also returned
* @return \Composer\Package\Link[] * @return \Composer\Package\Link[]
*/ */
public function getPlatformRequirements($withDevReqs = false) public function getPlatformRequirements($withDevReqs = false): array
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
$requirements = array(); $requirements = array();
@ -255,7 +255,7 @@ class Locker
/** /**
* @return string * @return string
*/ */
public function getMinimumStability() public function getMinimumStability(): string
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
@ -265,7 +265,7 @@ class Locker
/** /**
* @return array<string, string> * @return array<string, string>
*/ */
public function getStabilityFlags() public function getStabilityFlags(): array
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
@ -275,7 +275,7 @@ class Locker
/** /**
* @return bool|null * @return bool|null
*/ */
public function getPreferStable() public function getPreferStable(): ?bool
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
@ -287,7 +287,7 @@ class Locker
/** /**
* @return bool|null * @return bool|null
*/ */
public function getPreferLowest() public function getPreferLowest(): ?bool
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
@ -299,7 +299,7 @@ class Locker
/** /**
* @return array<string, string> * @return array<string, string>
*/ */
public function getPlatformOverrides() public function getPlatformOverrides(): array
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
@ -311,7 +311,7 @@ class Locker
* *
* @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}> * @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/ */
public function getAliases() public function getAliases(): array
{ {
$lockData = $this->getLockData(); $lockData = $this->getLockData();
@ -321,7 +321,7 @@ class Locker
/** /**
* @return array<string, mixed> * @return array<string, mixed>
*/ */
public function getLockData() public function getLockData(): array
{ {
if (null !== $this->lockDataCache) { if (null !== $this->lockDataCache) {
return $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 * @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 // 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 // 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 * @return RootPackage
*/ */
public function getAliasOf() public function getAliasOf(): RootPackage
{ {
return $this->aliasOf; return $this->aliasOf;
} }
@ -43,7 +43,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getAliases() public function getAliases(): array
{ {
return $this->aliasOf->getAliases(); return $this->aliasOf->getAliases();
} }
@ -51,7 +51,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getMinimumStability() public function getMinimumStability(): string
{ {
return $this->aliasOf->getMinimumStability(); return $this->aliasOf->getMinimumStability();
} }
@ -59,7 +59,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getStabilityFlags() public function getStabilityFlags(): array
{ {
return $this->aliasOf->getStabilityFlags(); return $this->aliasOf->getStabilityFlags();
} }
@ -67,7 +67,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getReferences() public function getReferences(): array
{ {
return $this->aliasOf->getReferences(); return $this->aliasOf->getReferences();
} }
@ -75,7 +75,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getPreferStable() public function getPreferStable(): bool
{ {
return $this->aliasOf->getPreferStable(); return $this->aliasOf->getPreferStable();
} }
@ -83,7 +83,7 @@ class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterf
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getConfig() public function getConfig(): array
{ {
return $this->aliasOf->getConfig(); return $this->aliasOf->getConfig();
} }

View File

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

View File

@ -30,7 +30,7 @@ class StabilityFilter
* @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev' * @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev'
* @return bool true if any package name is acceptable * @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) { foreach ($names as $name) {
// allow if package matches the package-specific stability flag // allow if package matches the package-specific stability flag

View File

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

View File

@ -172,7 +172,7 @@ class VersionSelector
* @param PackageInterface $package * @param PackageInterface $package
* @return string * @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 // 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 // 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 * @return string|null
*/ */
public function getVersion() public function getVersion(): ?string
{ {
if (null !== self::$hhvmVersion) { if (null !== self::$hhvmVersion) {
return self::$hhvmVersion ?: null; return self::$hhvmVersion ?: null;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,7 +21,7 @@ namespace Composer\Repository;
*/ */
class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
{ {
public function getRepoName() public function getRepoName(): string
{ {
return 'installed '.parent::getRepoName(); return 'installed '.parent::getRepoName();
} }
@ -29,7 +29,7 @@ class InstalledArrayRepository extends WritableArrayRepository implements Instal
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function isFresh() public function isFresh(): bool
{ {
// this is not a completely correct implementation but there is no way to // 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 // 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[] * @return BasePackage[]
*/ */
public function findPackagesWithReplacersAndProviders($name, $constraint = null) public function findPackagesWithReplacersAndProviders($name, $constraint = null): array
{ {
$name = strtolower($name); $name = strtolower($name);
@ -87,7 +87,7 @@ class InstalledRepository extends CompositeRepository
* @return array[] An associative array of arrays as described above. * @return array[] An associative array of arrays as described above.
* @phpstan-return array<array{0: PackageInterface, 1: Link, 2: mixed[]|bool}> * @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); $needles = array_map('strtolower', (array) $needle);
$results = array(); $results = array();
@ -249,7 +249,7 @@ class InstalledRepository extends CompositeRepository
return $results; return $results;
} }
public function getRepoName() public function getRepoName(): string
{ {
return 'installed repo ('.implode(', ', array_map(function ($repo) { return 'installed repo ('.implode(', ', array_map(function ($repo) {
return $repo->getRepoName(); return $repo->getRepoName();

View File

@ -21,7 +21,7 @@ namespace Composer\Repository;
*/ */
class LockArrayRepository extends ArrayRepository class LockArrayRepository extends ArrayRepository
{ {
public function getRepoName() public function getRepoName(): string
{ {
return 'lock repo'; 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()); return Preg::replace('{^array }', 'package ', parent::getRepoName());
} }

View File

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

View File

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

View File

@ -64,7 +64,7 @@ class RepositoryFactory
* @param bool $allowFilesystem * @param bool $allowFilesystem
* @return RepositoryInterface * @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); $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
@ -77,7 +77,7 @@ class RepositoryFactory
* @param array<string, mixed> $repoConfig * @param array<string, mixed> $repoConfig
* @return RepositoryInterface * @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) { if (!$rm) {
$rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config)); $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
@ -93,7 +93,7 @@ class RepositoryFactory
* @param RepositoryManager|null $rm * @param RepositoryManager|null $rm
* @return RepositoryInterface[] * @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) { if (!$config) {
$config = Factory::createConfig($io); $config = Factory::createConfig($io);
@ -118,7 +118,7 @@ class RepositoryFactory
* @param HttpDownloader $httpDownloader * @param HttpDownloader $httpDownloader
* @return RepositoryManager * @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 = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
$rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository'); $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
@ -178,9 +178,9 @@ class RepositoryFactory
* *
* @return string * @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])) { while (isset($existingRepos[$name])) {
$name .= '2'; $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 * @return ConstraintInterface[] an array of package name => constraint from the root package, platform requirements excluded
* @phpstan-return array<string, ConstraintInterface> * @phpstan-return array<string, ConstraintInterface>
*/ */
public function getRootRequires() public function getRootRequires(): array
{ {
return $this->rootRequires; 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 * @param int $flags any of the ALLOW_* constants from this class to tweak what is returned
* @return BasePackage[] * @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; $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
$loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 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' => '...') * @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}> * @phpstan-return array<string, array{name: string, description: string, type: string}>
*/ */
public function getProviders($packageName) public function getProviders($packageName): array
{ {
$providers = array(); $providers = array();
foreach ($this->repositories as $repository) { foreach ($this->repositories as $repository) {
@ -235,7 +235,7 @@ class RepositorySet
* @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev' * @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev'
* @return bool * @return bool
*/ */
public function isPackageAcceptable($names, $stability) public function isPackageAcceptable($names, $stability): bool
{ {
return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability); return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
} }
@ -245,7 +245,7 @@ class RepositorySet
* *
* @return Pool * @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); $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher, $poolOptimizer);
@ -265,7 +265,7 @@ class RepositorySet
* *
* @return Pool * @return Pool
*/ */
public function createPoolWithAllPackages() public function createPoolWithAllPackages(): Pool
{ {
foreach ($this->repositories as $repo) { foreach ($this->repositories as $repo) {
if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) { if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
@ -304,7 +304,7 @@ class RepositorySet
* *
* @return Pool * @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"? // TODO unify this with above in some simpler version without "request"?
return $this->createPoolForPackages(array($packageName), $lockedRepo); return $this->createPoolForPackages(array($packageName), $lockedRepo);
@ -315,7 +315,7 @@ class RepositorySet
* *
* @return Pool * @return Pool
*/ */
public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null) public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null): Pool
{ {
$request = new Request($lockedRepo); $request = new Request($lockedRepo);

View File

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

View File

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

View File

@ -144,7 +144,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getComposerInformation($identifier) public function getComposerInformation($identifier): array
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getComposerInformation($identifier); return $this->gitDriver->getComposerInformation($identifier);
@ -184,7 +184,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getFileContent($file, $identifier) public function getFileContent($file, $identifier): ?string
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getFileContent($file, $identifier); return $this->gitDriver->getFileContent($file, $identifier);
@ -216,7 +216,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getChangeDate($identifier) public function getChangeDate($identifier): ?\DateTime
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getChangeDate($identifier); return $this->gitDriver->getChangeDate($identifier);
@ -232,7 +232,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @return string * @return string
*/ */
public function getRepositoryUrl() public function getRepositoryUrl(): string
{ {
if ($this->protocol) { if ($this->protocol) {
return $this->project["{$this->protocol}_url_to_repo"]; return $this->project["{$this->protocol}_url_to_repo"];
@ -244,7 +244,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getUrl() public function getUrl(): string
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getUrl(); return $this->gitDriver->getUrl();
@ -256,7 +256,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getDist($identifier) public function getDist($identifier): ?array
{ {
$url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier; $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
@ -266,7 +266,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getSource($identifier) public function getSource($identifier): array
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getSource($identifier); return $this->gitDriver->getSource($identifier);
@ -278,7 +278,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getRootIdentifier() public function getRootIdentifier(): string
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getRootIdentifier(); return $this->gitDriver->getRootIdentifier();
@ -290,7 +290,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getBranches() public function getBranches(): array
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getBranches(); return $this->gitDriver->getBranches();
@ -306,7 +306,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getTags() public function getTags(): array
{ {
if ($this->gitDriver) { if ($this->gitDriver) {
return $this->gitDriver->getTags(); return $this->gitDriver->getTags();
@ -322,7 +322,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @return string Base URL for GitLab API v3 * @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); 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 * @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; $perPage = 100;
$resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage; $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
@ -402,7 +402,7 @@ class GitLabDriver extends VcsDriver
* @return true * @return true
* @throws \RuntimeException * @throws \RuntimeException
*/ */
protected function attemptCloneFallback() protected function attemptCloneFallback(): bool
{ {
if ($this->isPrivate === false) { if ($this->isPrivate === false) {
$url = $this->generatePublicUrl(); $url = $this->generatePublicUrl();
@ -430,7 +430,7 @@ class GitLabDriver extends VcsDriver
* *
* @return string * @return string
*/ */
protected function generateSshUrl() protected function generateSshUrl(): string
{ {
if ($this->hasNonstandardOrigin) { if ($this->hasNonstandardOrigin) {
return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git'; return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
@ -442,7 +442,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @return string * @return string
*/ */
protected function generatePublicUrl() protected function generatePublicUrl(): string
{ {
return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git'; return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
} }
@ -469,7 +469,7 @@ class GitLabDriver extends VcsDriver
* *
* @param bool $fetchingRepoData * @param bool $fetchingRepoData
*/ */
protected function getContents($url, $fetchingRepoData = false) protected function getContents($url, $fetchingRepoData = false): Response
{ {
try { try {
$response = parent::getContents($url); $response = parent::getContents($url);
@ -568,7 +568,7 @@ class GitLabDriver extends VcsDriver
* *
* @inheritDoc * @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)) { if (!Preg::isMatch(self::URL_REGEX, $url, $match)) {
return false; return false;
@ -594,7 +594,7 @@ class GitLabDriver extends VcsDriver
/** /**
* @return string|null * @return string|null
*/ */
protected function getNextPage(Response $response) protected function getNextPage(Response $response): ?string
{ {
$header = $response->getHeader('link'); $header = $response->getHeader('link');

View File

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

View File

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

View File

@ -41,7 +41,7 @@ class Versions
/** /**
* @return string * @return string
*/ */
public function getChannel() public function getChannel(): string
{ {
if ($this->channel) { if ($this->channel) {
return $this->channel; return $this->channel;
@ -79,7 +79,7 @@ class Versions
* *
* @return array{path: string, version: string, min-php: int} * @return array{path: string, version: string, min-php: int}
*/ */
public function getLatest($channel = null) public function getLatest($channel = null): array
{ {
$versions = $this->getVersionsData(); $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 * 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} * @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; $storeAuth = false;
@ -215,7 +215,7 @@ class AuthHelper
* *
* @return string[] updated headers array * @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)) { if ($this->io->hasAuthentication($origin)) {
$authenticationDisplayMessage = null; $authenticationDisplayMessage = null;
@ -272,7 +272,7 @@ class AuthHelper
* *
* @return bool Whether the given URL is a public BitBucket download which requires no authentication. * @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); $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
if (strpos($domain, 'bitbucket.org') === false) { if (strpos($domain, 'bitbucket.org') === false) {

View File

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

View File

@ -31,7 +31,7 @@ class ComposerMirror
* *
* @return string * @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) { if ($reference) {
$reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference); $reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
@ -56,7 +56,7 @@ class ComposerMirror
* *
* @return string * @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)) { if (Preg::isMatch('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
$url = 'gh-'.$match[1].'/'.$match[2]; $url = 'gh-'.$match[1].'/'.$match[2];
@ -81,7 +81,7 @@ class ComposerMirror
* *
* @return string * @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); 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 * @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(); $errors = array();
$publishErrors = array(); $publishErrors = array();

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