1
0
Fork 0

Add return types to private/internal methods

pull/10547/head
Jordi Boggiano 2022-02-18 11:22:01 +01:00
parent abdc6893a6
commit a16ed3d0ed
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
134 changed files with 365 additions and 359 deletions

View File

@ -441,7 +441,7 @@ EOF;
* @param array<string, true> $scannedFiles
* @return array<class-string, string>
*/
private function addClassMapCode(Filesystem $filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles)
private function addClassMapCode(Filesystem $filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles): array
{
foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
$pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
@ -464,7 +464,7 @@ EOF;
* @param array<string, true> $scannedFiles
* @return array<class-string, string>
*/
private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles)
private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles): array
{
if ($excluded) {
// filter excluded patterns here to only use those matching $dir

View File

@ -157,7 +157,7 @@ class ClassMapGenerator
* @param ?IOInterface $io IO object
* @return array<int, class-string> valid classes
*/
private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io)
private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io): array
{
$validClasses = array();
$rejectedClasses = array();
@ -215,7 +215,7 @@ class ClassMapGenerator
* @throws \RuntimeException
* @return array<int, class-string> The found classes
*/
private static function findClasses($path)
private static function findClasses($path): array
{
$extraTypes = self::getExtraTypes();
@ -296,7 +296,7 @@ class ClassMapGenerator
/**
* @return string
*/
private static function getExtraTypes()
private static function getExtraTypes(): string
{
static $extraTypes = null;

View File

@ -78,7 +78,7 @@ class PhpFileCleaner
/**
* @return string
*/
public function clean()
public function clean(): string
{
$clean = '';
@ -260,7 +260,7 @@ class PhpFileCleaner
* @param string $char
* @return bool
*/
private function peek($char)
private function peek($char): bool
{
return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
}
@ -270,7 +270,7 @@ class PhpFileCleaner
* @param ?array<int, string> $match
* @return bool
*/
private function match($regex, array &$match = null)
private function match($regex, array &$match = null): bool
{
return Preg::isMatch($regex, $this->contents, $match, 0, $this->index);
}

View File

@ -260,7 +260,8 @@ EOT
try {
$this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
} catch (TransportException $e) {
if ($hints = HttpDownloader::getExceptionHints($e)) {
$hints = HttpDownloader::getExceptionHints($e);
if (null !== $hints && count($hints) > 0) {
foreach ($hints as $hint) {
$result[] = $hint;
}
@ -436,7 +437,7 @@ EOT
/**
* @return string
*/
private function getCurlVersion()
private function getCurlVersion(): string
{
if (extension_loaded('curl')) {
if (!HttpDownloader::isCurlEnabled()) {
@ -458,7 +459,7 @@ EOT
*
* @return void
*/
private function outputResult($result)
private function outputResult($result): void
{
$io = $this->getIO();
if (true === $result) {

View File

@ -134,7 +134,7 @@ class FundCommand extends BaseCommand
* @param mixed[] $fundings
* @return mixed[]
*/
private function insertFundingData(array $fundings, CompletePackageInterface $package)
private function insertFundingData(array $fundings, CompletePackageInterface $package): array
{
foreach ($package->getFunding() as $fundingOption) {
list($vendor, $packageName) = explode('/', $package->getPrettyName());

View File

@ -101,7 +101,7 @@ EOT
* @param bool $showOnly
* @return bool
*/
private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly): bool
{
$support = $package->getSupport();
$url = $support['source'] ?? $package->getSourceUrl();
@ -158,7 +158,7 @@ EOT
*
* @return RepositoryInterface[]
*/
private function initializeRepos()
private function initializeRepos(): array
{
$composer = $this->tryComposer();

View File

@ -623,7 +623,7 @@ EOT
/**
* @return void
*/
private function updateDependencies(OutputInterface $output)
private function updateDependencies(OutputInterface $output): void
{
try {
$updateCommand = $this->getApplication()->find('update');
@ -637,7 +637,7 @@ EOT
/**
* @return void
*/
private function runDumpAutoloadCommand(OutputInterface $output)
private function runDumpAutoloadCommand(OutputInterface $output): void
{
try {
$command = $this->getApplication()->find('dump-autoload');
@ -652,7 +652,7 @@ EOT
* @param array<string, string|array<string>> $options
* @return bool
*/
private function hasDependencies($options)
private function hasDependencies($options): bool
{
$requires = (array) $options['require'];
$devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();

View File

@ -163,7 +163,7 @@ EOT
* @param array<string, PackageInterface> $bucket
* @return array<string, PackageInterface>
*/
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array()): array
{
$requires = array_keys($package->getRequires());

View File

@ -296,7 +296,7 @@ EOT
* @param string $requireKey
* @return string[]
*/
private function getInconsistentRequireKeys(array $newRequirements, $requireKey)
private function getInconsistentRequireKeys(array $newRequirements, $requireKey): array
{
$requireKeys = $this->getPackagesByRequireKey();
$inconsistentRequirements = array();
@ -315,7 +315,7 @@ EOT
/**
* @return array<string, string>
*/
private function getPackagesByRequireKey()
private function getPackagesByRequireKey(): array
{
$composerDefinition = $this->json->read();
$require = array();
@ -351,7 +351,7 @@ EOT
* @return int
* @throws \Exception
*/
private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey): int
{
// Update packages
$this->resetComposer();
@ -449,7 +449,7 @@ EOT
* @param bool $sortPackages
* @return bool
*/
private function updateFileCleanly(JsonFile $json, array $new, $requireKey, $removeKey, $sortPackages)
private function updateFileCleanly(JsonFile $json, array $new, $requireKey, $removeKey, $sortPackages): bool
{
$contents = file_get_contents($json->getPath());

View File

@ -923,7 +923,7 @@ EOT
* @param array<string, string> $versions
* @return array<string, string|string[]|null>
*/
private function appendVersions($json, array $versions)
private function appendVersions($json, array $versions): array
{
uasort($versions, 'version_compare');
$versions = array_keys(array_reverse($versions));
@ -936,7 +936,7 @@ EOT
* @param array<string, string|string[]|null> $json
* @return array<string, string|string[]|null>
*/
private function appendLicenses($json, CompletePackageInterface $package)
private function appendLicenses($json, CompletePackageInterface $package): array
{
if ($licenses = $package->getLicense()) {
$spdxLicenses = new SpdxLicenses();
@ -963,7 +963,7 @@ EOT
* @param array<string, string|string[]|null> $json
* @return array<string, string|string[]|null>
*/
private function appendAutoload($json, CompletePackageInterface $package)
private function appendAutoload($json, CompletePackageInterface $package): array
{
if ($package->getAutoload()) {
$autoload = array();
@ -996,7 +996,7 @@ EOT
* @param array<string, string|string[]|null> $json
* @return array<string, string|string[]|null>
*/
private function appendLinks($json, CompletePackageInterface $package)
private function appendLinks($json, CompletePackageInterface $package): array
{
foreach (Link::$TYPES as $linkType) {
$json = $this->appendLink($json, $package, $linkType);
@ -1010,7 +1010,7 @@ EOT
* @param string $linkType
* @return array<string, string|string[]|null>
*/
private function appendLink($json, CompletePackageInterface $package, $linkType)
private function appendLink($json, CompletePackageInterface $package, $linkType): array
{
$links = $package->{'get' . ucfirst($linkType)}();
@ -1240,7 +1240,7 @@ EOT
* @param string $updateStatus
* @return string
*/
private function updateStatusToVersionStyle($updateStatus)
private function updateStatusToVersionStyle($updateStatus): string
{
// 'up-to-date' is printed green
// 'semver-safe-update' is printed red
@ -1251,7 +1251,7 @@ EOT
/**
* @return string
*/
private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package): string
{
if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
return 'up-to-date';
@ -1275,7 +1275,7 @@ EOT
*
* @return void
*/
private function writeTreeLine($line)
private function writeTreeLine($line): void
{
$io = $this->getIO();
if (!$io->isDecorated()) {
@ -1326,7 +1326,7 @@ EOT
/**
* @return RepositorySet
*/
private function getRepositorySet(Composer $composer)
private function getRepositorySet(Composer $composer): RepositorySet
{
if (!$this->repositorySet) {
$this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
@ -1342,7 +1342,7 @@ EOT
* @param array<PackageInterface> $bucket
* @return array<PackageInterface>
*/
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array()): array
{
$requires = $package->getRequires();

View File

@ -80,7 +80,7 @@ EOT
/**
* @return int
*/
private function doExecute(InputInterface $input)
private function doExecute(InputInterface $input): int
{
// init repos
$composer = $this->requireComposer();

View File

@ -245,7 +245,7 @@ EOT
* @param array<string> $packages
* @return array<string>
*/
private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages): array
{
if (!$input->isInteractive()) {
throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
@ -312,7 +312,7 @@ EOT
* @param string $constraint
* @return Link
*/
private function appendConstraintToLink(Link $link, $constraint)
private function appendConstraintToLink(Link $link, $constraint): Link
{
$parser = new VersionParser;
$oldPrettyString = $link->getConstraint()->getPrettyString();

View File

@ -201,7 +201,7 @@ class Compiler
* @param \SplFileInfo $file
* @return string
*/
private function getRelativeFilePath($file)
private function getRelativeFilePath($file): string
{
$realPath = $file->getRealPath();
$pathPrefix = dirname(__DIR__, 2).DIRECTORY_SEPARATOR;
@ -258,7 +258,7 @@ class Compiler
* @param string $source A PHP string
* @return string The PHP string with the whitespace removed
*/
private function stripWhitespace($source)
private function stripWhitespace($source): string
{
if (!function_exists('token_get_all')) {
return $source;
@ -289,7 +289,7 @@ class Compiler
/**
* @return string
*/
private function getStub()
private function getStub(): string
{
$stub = <<<'EOF'
#!/usr/bin/env php

View File

@ -531,7 +531,7 @@ class Config
* @param string $path
* @return string
*/
private function realpath($path)
private function realpath($path): string
{
if (Preg::isMatch('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
return $path;

View File

@ -214,7 +214,7 @@ class JsonConfigSource implements ConfigSourceInterface
*
* @return void
*/
private function manipulateJson($method, $fallback, ...$args)
private function manipulateJson($method, $fallback, ...$args): void
{
if ($this->file->exists()) {
if (!is_writable($this->file->getPath())) {
@ -297,7 +297,7 @@ class JsonConfigSource implements ConfigSourceInterface
* @param mixed $value
* @return int
*/
private function arrayUnshiftRef(&$array, &$value)
private function arrayUnshiftRef(&$array, &$value): int
{
$return = array_unshift($array, '');
$array[0] = &$value;

View File

@ -358,7 +358,7 @@ class Application extends BaseApplication
* @throws \RuntimeException
* @return string
*/
private function getNewWorkingDir(InputInterface $input)
private function getNewWorkingDir(InputInterface $input): string
{
$workingDir = $input->getParameterOption(array('--working-dir', '-d'));
if (false !== $workingDir && !is_dir($workingDir)) {
@ -371,7 +371,7 @@ class Application extends BaseApplication
/**
* @return void
*/
private function hintCommonErrors(\Exception $exception)
private function hintCommonErrors(\Exception $exception): void
{
$io = $this->getIO();
@ -408,7 +408,8 @@ class Application extends BaseApplication
$io->writeError('<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>', true, IOInterface::QUIET);
}
if ($hints = HttpDownloader::getExceptionHints($exception)) {
$hints = HttpDownloader::getExceptionHints($exception);
if (null !== $hints && count($hints) > 0) {
foreach ($hints as $hint) {
$io->writeError($hint, true, IOInterface::QUIET);
}
@ -553,7 +554,7 @@ class Application extends BaseApplication
/**
* @return Command\BaseCommand[]
*/
private function getPluginCommands()
private function getPluginCommands(): array
{
$commands = array();

View File

@ -55,7 +55,7 @@ final class GithubActionError
* @param string $data
* @return string
*/
private function escapeData($data)
private function escapeData($data): string
{
// see https://github.com/actions/toolkit/blob/4f7fb6513a355689f69f0849edeb369a4dc81729/packages/core/src/command.ts#L80-L85
$data = str_replace("%", '%25', $data);
@ -69,7 +69,7 @@ final class GithubActionError
* @param string $property
* @return string
*/
private function escapeProperty($property)
private function escapeProperty($property): string
{
// see https://github.com/actions/toolkit/blob/4f7fb6513a355689f69f0849edeb369a4dc81729/packages/core/src/command.ts#L87-L94
$property = str_replace("%", '%25', $property);

View File

@ -106,7 +106,7 @@ class LockTransaction extends Transaction
* @param bool $updateMirrors
* @return BasePackage[]
*/
public function getNewLockPackages($devMode, $updateMirrors = false)
public function getNewLockPackages($devMode, $updateMirrors = false): array
{
$packages = array();
foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
@ -137,7 +137,7 @@ class LockTransaction extends Transaction
* @param array<array{package: string, version: string, alias: string, alias_normalized: string}> $aliases
* @return array<array{package: string, version: string, alias: string, alias_normalized: string}>
*/
public function getAliases($aliases)
public function getAliases($aliases): array
{
$usedAliases = array();

View File

@ -159,7 +159,7 @@ class Pool implements \Countable
* packages must match or null to return all
* @return BasePackage[]
*/
private function computeWhatProvides($name, ConstraintInterface $constraint = null)
private function computeWhatProvides($name, ConstraintInterface $constraint = null): array
{
if (!isset($this->packageByName[$name])) {
return array();

View File

@ -499,7 +499,7 @@ class PoolBuilder
* @param string $name packageName
* @return bool
*/
private function isRootRequire(Request $request, $name)
private function isRootRequire(Request $request, $name): bool
{
$rootRequires = $request->getRequires();
@ -510,7 +510,7 @@ class PoolBuilder
* @param string $name
* @return string[]
*/
private function getSkippedRootRequires(Request $request, $name)
private function getSkippedRootRequires(Request $request, $name): array
{
if (!isset($this->skippedLoad[$name])) {
return array();
@ -553,7 +553,7 @@ class PoolBuilder
*
* @return bool
*/
private function isUpdateAllowed(BasePackage $package)
private function isUpdateAllowed(BasePackage $package): bool
{
foreach ($this->updateAllowList as $pattern => $void) {
$patternRegexp = BasePackage::packageNameToRegexp($pattern);
@ -684,7 +684,7 @@ class PoolBuilder
/**
* @return Pool
*/
private function runOptimizer(Request $request, Pool $pool)
private function runOptimizer(Request $request, Pool $pool): Pool
{
if (null === $this->poolOptimizer) {
return $pool;

View File

@ -173,7 +173,7 @@ class PoolOptimizer
/**
* @return Pool Optimized pool
*/
private function applyRemovalsToPool(Pool $pool)
private function applyRemovalsToPool(Pool $pool): Pool
{
$packages = array();
$removedVersions = array();
@ -278,7 +278,7 @@ class PoolOptimizer
/**
* @return string
*/
private function calculateDependencyHash(BasePackage $package)
private function calculateDependencyHash(BasePackage $package): string
{
$hash = '';

View File

@ -117,7 +117,7 @@ class Problem
* @return string
* @internal
*/
public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array()): string
{
$messages = array();
$templates = array();
@ -210,7 +210,7 @@ class Problem
* @param string $packageName
* @return array{0: string, 1: string}
*/
public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, ConstraintInterface $constraint = null)
public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, ConstraintInterface $constraint = null): array
{
if (PlatformRepository::isPlatformPackage($packageName)) {
// handle php/php-*/hhvm
@ -382,7 +382,7 @@ class Problem
* @param bool $useRemovedVersionGroup
* @return string
*/
public static function getPackageList(array $packages, $isVerbose, Pool $pool = null, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false)
public static function getPackageList(array $packages, $isVerbose, Pool $pool = null, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false): string
{
$prepared = array();
$hasDefaultBranch = array();
@ -427,7 +427,7 @@ class Problem
* @param string $version the effective runtime version of the platform package
* @return ?string a version string or null if it appears the package was artificially disabled
*/
private static function getPlatformPackageVersion(Pool $pool, $packageName, $version)
private static function getPlatformPackageVersion(Pool $pool, $packageName, $version): ?string
{
$available = $pool->whatProvides($packageName);
@ -471,7 +471,7 @@ class Problem
* @param int $maxDev
* @return list<string> a list of pretty versions and '...' where versions were removed
*/
private static function condenseVersionList(array $versions, $max, $maxDev = 16)
private static function condenseVersionList(array $versions, $max, $maxDev = 16): array
{
if (count($versions) <= $max) {
return $versions;
@ -505,7 +505,7 @@ class Problem
* @param PackageInterface[] $packages
* @return bool
*/
private static function hasMultipleNames(array $packages)
private static function hasMultipleNames(array $packages): bool
{
$name = null;
foreach ($packages as $package) {
@ -527,7 +527,7 @@ class Problem
* @param string $reason
* @return array{0: string, 1: string}
*/
private static function computeCheckForLowerPrioRepo(Pool $pool, $isVerbose, $packageName, array $higherRepoPackages, array $allReposPackages, $reason, ConstraintInterface $constraint = null)
private static function computeCheckForLowerPrioRepo(Pool $pool, $isVerbose, $packageName, array $higherRepoPackages, array $allReposPackages, $reason, ConstraintInterface $constraint = null): array
{
$nextRepoPackages = array();
$nextRepo = null;

View File

@ -232,7 +232,7 @@ abstract class Rule
* @internal
* @return BasePackage
*/
public function getSourcePackage(Pool $pool)
public function getSourcePackage(Pool $pool): BasePackage
{
$literals = $this->getLiterals();
@ -498,7 +498,7 @@ abstract class Rule
/**
* @return BasePackage
*/
private function deduplicateDefaultBranchAlias(BasePackage $package)
private function deduplicateDefaultBranchAlias(BasePackage $package): BasePackage
{
if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
$package = $package->getAliasOf();

View File

@ -302,7 +302,7 @@ class Solver
* @param string|int $literal
* @return int
*/
private function setPropagateLearn($level, $literal, Rule $rule)
private function setPropagateLearn($level, $literal, Rule $rule): int
{
$level++;
@ -351,7 +351,7 @@ class Solver
* @param int[] $decisionQueue
* @return int
*/
private function selectAndInstall($level, array $decisionQueue, Rule $rule)
private function selectAndInstall($level, array $decisionQueue, Rule $rule): int
{
// choose best package to install from decisionQueue
$literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
@ -548,7 +548,7 @@ class Solver
/**
* @return int
*/
private function analyzeUnsolvable(Rule $conflictRule)
private function analyzeUnsolvable(Rule $conflictRule): int
{
$problem = new Problem();
$problem->addRule($conflictRule);

View File

@ -109,7 +109,7 @@ class SolverProblemsException extends \RuntimeException
* @param string[] $missingExtensions
* @return string
*/
private function createExtensionHint(array $missingExtensions)
private function createExtensionHint(array $missingExtensions): string
{
$paths = IniHelper::getAll();
@ -133,7 +133,7 @@ class SolverProblemsException extends \RuntimeException
* @param Rule[][] $reasonSets
* @return string[]
*/
private function getExtensionProblems(array $reasonSets)
private function getExtensionProblems(array $reasonSets): array
{
$missingExtensions = array();
foreach ($reasonSets as $reasonSet) {

View File

@ -60,7 +60,7 @@ class Transaction
/**
* @return OperationInterface[]
*/
public function getOperations()
public function getOperations(): array
{
return $this->operations;
}
@ -101,7 +101,7 @@ class Transaction
/**
* @return OperationInterface[]
*/
protected function calculateOperations()
protected function calculateOperations(): array
{
$operations = array();
@ -218,7 +218,7 @@ class Transaction
*
* @return array<string, PackageInterface>
*/
protected function getRootPackages()
protected function getRootPackages(): array
{
$roots = $this->resultPackageMap;
@ -244,7 +244,7 @@ class Transaction
/**
* @return PackageInterface[]
*/
protected function getProvidersInResult(Link $link)
protected function getProvidersInResult(Link $link): array
{
if (!isset($this->resultPackagesByName[$link->getTarget()])) {
return array();
@ -266,7 +266,7 @@ class Transaction
* @param OperationInterface[] $operations
* @return OperationInterface[] reordered operation list
*/
private function movePluginsToFront(array $operations)
private function movePluginsToFront(array $operations): array
{
$dlModifyingPluginsNoDeps = array();
$dlModifyingPluginsWithDeps = array();
@ -343,7 +343,7 @@ class Transaction
* @param OperationInterface[] $operations
* @return OperationInterface[] reordered operation list
*/
private function moveUninstallsToFront(array $operations)
private function moveUninstallsToFront(array $operations): array
{
$uninstOps = array();
foreach ($operations as $idx => $op) {

View File

@ -406,7 +406,7 @@ class DownloadManager
* @return string[]
* @phpstan-return array<'dist'|'source'>&non-empty-array
*/
private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null): array
{
$sourceType = $package->getSourceType();
$distType = $package->getDistType();
@ -456,7 +456,7 @@ class DownloadManager
*
* @return string
*/
private function normalizeTargetDir($dir)
private function normalizeTargetDir($dir): string
{
if ($dir === '\\' || $dir === '/') {
return $dir;

View File

@ -295,7 +295,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter
*
* @return bool
*/
private function safeJunctions()
private function safeJunctions(): bool
{
// We need to call mklink, and rmdir on Windows 7 (version 6.1)
return function_exists('proc_open') &&

View File

@ -57,7 +57,7 @@ class PerforceDownloader extends VcsDownloader
*
* @return string|null
*/
private function getLabelFromSourceReference($ref)
private function getLabelFromSourceReference($ref): ?string
{
$pos = strpos($ref, '@');
if (false !== $pos) {
@ -92,7 +92,7 @@ class PerforceDownloader extends VcsDownloader
/**
* @return array<string, mixed>
*/
private function getRepoConfig(VcsRepository $repository)
private function getRepoConfig(VcsRepository $repository): array
{
return $repository->getRepoConfig();
}

View File

@ -346,7 +346,7 @@ abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterfa
*
* @return string[]
*/
private function prepareUrls(array $urls)
private function prepareUrls(array $urls): array
{
foreach ($urls as $index => $url) {
if (Filesystem::isLocalPath($url)) {

View File

@ -105,7 +105,7 @@ class ZipDownloader extends ArchiveDownloader
* @param string $path Path where to extract file
* @return PromiseInterface
*/
private function extractWithSystemUnzip(PackageInterface $package, $file, $path)
private function extractWithSystemUnzip(PackageInterface $package, $file, $path): PromiseInterface
{
// Force Exception throwing if the other alternative extraction method is not available
$isLastChance = !self::$hasZipArchive;
@ -172,7 +172,7 @@ class ZipDownloader extends ArchiveDownloader
* @param string $path Path where to extract file
* @return PromiseInterface
*/
private function extractWithZipArchive(PackageInterface $package, $file, $path)
private function extractWithZipArchive(PackageInterface $package, $file, $path): PromiseInterface
{
$processError = null;
$zipArchive = $this->zipArchiveObject ?: new ZipArchive();

View File

@ -556,7 +556,7 @@ class EventDispatcher
/**
* @return void
*/
private function ensureBinDirIsInPath()
private function ensureBinDirIsInPath(): void
{
$pathEnv = 'PATH';
if (false === Platform::getEnv('PATH') && false !== Platform::getEnv('Path')) {

View File

@ -696,7 +696,7 @@ class Factory
/**
* @return bool
*/
private static function useXdg()
private static function useXdg(): bool
{
foreach (array_keys($_SERVER) as $key) {
if (strpos($key, 'XDG_') === 0) {
@ -715,7 +715,7 @@ class Factory
* @throws \RuntimeException
* @return string
*/
private static function getUserDir()
private static function getUserDir(): string
{
$home = Platform::getEnv('HOME');
if (!$home) {

View File

@ -20,7 +20,7 @@ final class IgnoreAllPlatformRequirementFilter implements PlatformRequirementFil
* @param string $req
* @return bool
*/
public function isIgnored($req)
public function isIgnored($req): bool
{
return PlatformRepository::isPlatformPackage($req);
}

View File

@ -55,7 +55,7 @@ final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFi
* @param string $req
* @return bool
*/
public function isIgnored($req)
public function isIgnored($req): bool
{
if (!PlatformRepository::isPlatformPackage($req)) {
return false;
@ -68,7 +68,7 @@ final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFi
* @param string $req
* @return ConstraintInterface
*/
public function filterConstraint($req, ConstraintInterface $constraint)
public function filterConstraint($req, ConstraintInterface $constraint): ConstraintInterface
{
if (!PlatformRepository::isPlatformPackage($req)) {
return $constraint;

View File

@ -18,7 +18,7 @@ final class IgnoreNothingPlatformRequirementFilter implements PlatformRequiremen
* @param string $req
* @return false
*/
public function isIgnored($req)
public function isIgnored($req): bool
{
return false;
}

View File

@ -19,7 +19,7 @@ final class PlatformRequirementFilterFactory
*
* @return PlatformRequirementFilterInterface
*/
public static function fromBoolOrList($boolOrList)
public static function fromBoolOrList($boolOrList): PlatformRequirementFilterInterface
{
if (is_bool($boolOrList)) {
return $boolOrList ? self::ignoreAll() : self::ignoreNothing();
@ -40,7 +40,7 @@ final class PlatformRequirementFilterFactory
/**
* @return PlatformRequirementFilterInterface
*/
public static function ignoreAll()
public static function ignoreAll(): PlatformRequirementFilterInterface
{
return new IgnoreAllPlatformRequirementFilter();
}
@ -48,7 +48,7 @@ final class PlatformRequirementFilterFactory
/**
* @return PlatformRequirementFilterInterface
*/
public static function ignoreNothing()
public static function ignoreNothing(): PlatformRequirementFilterInterface
{
return new IgnoreNothingPlatformRequirementFilter();
}

View File

@ -157,7 +157,7 @@ class ConsoleIO extends BaseIO
*
* @return void
*/
private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false): void
{
$sfVerbosity = $this->verbosityMap[$verbosity];
if ($sfVerbosity > $this->output->getVerbosity()) {
@ -216,7 +216,7 @@ class ConsoleIO extends BaseIO
*
* @return void
*/
private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
private function doOverwrite($messages, $newline, $size, $stderr, $verbosity): void
{
// messages can be an array, let's convert it to string anyway
$messages = implode($newline ? "\n" : '', (array) $messages);
@ -345,7 +345,7 @@ class ConsoleIO extends BaseIO
/**
* @return OutputInterface
*/
private function getErrorOutput()
private function getErrorOutput(): OutputInterface
{
if ($this->output instanceof ConsoleOutputInterface) {
return $this->output->getErrorOutput();

View File

@ -789,7 +789,7 @@ class Installer
*
* @phpstan-param list<array{package: string, version: string, alias: string, alias_normalized: string}> $rootAliases
*/
private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null): RepositorySet
{
if ($forUpdate) {
$minimumStability = $this->package->getMinimumStability();
@ -858,7 +858,7 @@ class Installer
*
* @return DefaultPolicy
*/
private function createPolicy($forUpdate)
private function createPolicy($forUpdate): DefaultPolicy
{
$preferStable = null;
$preferLowest = null;
@ -882,7 +882,7 @@ class Installer
* @param RootPackageInterface&BasePackage $rootPackage
* @return Request
*/
private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null)
private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null): Request
{
$request = new Request($lockedRepository);
@ -953,7 +953,7 @@ class Installer
*
* @phpstan-return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/
private function getRootAliases($forUpdate)
private function getRootAliases($forUpdate): array
{
if ($forUpdate) {
$aliases = $this->package->getAliases();
@ -969,7 +969,7 @@ class Installer
*
* @return array<string, string>
*/
private function extractPlatformRequirements(array $links)
private function extractPlatformRequirements(array $links): array
{
$platformReqs = array();
foreach ($links as $link) {
@ -1009,7 +1009,7 @@ class Installer
/**
* @return PoolOptimizer|null
*/
private function createPoolOptimizer(PolicyInterface $policy)
private function createPoolOptimizer(PolicyInterface $policy): ?PoolOptimizer
{
// Not the best architectural decision here, would need to be able
// to configure from the outside of Installer but this is only

View File

@ -316,7 +316,7 @@ class InstallationManager
*
* @return void
*/
private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations): void
{
$promises = array();
@ -400,7 +400,7 @@ class InstallationManager
*
* @return void
*/
private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations): void
{
$promises = array();
$postExecCallbacks = array();
@ -481,7 +481,7 @@ class InstallationManager
*
* @return void
*/
private function waitOnPromises(array $promises)
private function waitOnPromises(array $promises): void
{
$progress = null;
if (
@ -700,7 +700,7 @@ class InstallationManager
/**
* @return void
*/
private function markForNotification(PackageInterface $package)
private function markForNotification(PackageInterface $package): void
{
if ($package->getNotificationUrl()) {
$this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;

View File

@ -183,7 +183,7 @@ class SuggestedPackagesReporter
* @param PackageInterface|null $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown
* @return mixed[]
*/
private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null): array
{
$suggestedPackages = $this->getPackages();
$installedNames = array();
@ -220,7 +220,7 @@ class SuggestedPackagesReporter
* @param string $string
* @return string
*/
private function escapeOutput($string)
private function escapeOutput($string): string
{
return OutputFormatter::escape(
$this->removeControlCharacters($string)
@ -231,7 +231,7 @@ class SuggestedPackagesReporter
* @param string $string
* @return string
*/
private function removeControlCharacters($string)
private function removeControlCharacters($string): string
{
return Preg::replace(
'/[[:cntrl:]]/',

View File

@ -256,7 +256,7 @@ class JsonFile
* @throws \RuntimeException
* @return void
*/
private static function throwEncodeError($code)
private static function throwEncodeError($code): void
{
switch ($code) {
case JSON_ERROR_DEPTH:

View File

@ -133,7 +133,7 @@ class JsonManipulator
* @param array<string> $packages
* @return void
*/
private function sortPackages(array &$packages = array())
private function sortPackages(array &$packages = array()): void
{
$prefix = function ($requirement) {
if (PlatformRepository::isPlatformPackage($requirement)) {

View File

@ -86,7 +86,7 @@ class ZipArchiver implements ArchiverInterface
/**
* @return bool
*/
private function compressionAvailable()
private function compressionAvailable(): bool
{
return class_exists('ZipArchive');
}

View File

@ -148,7 +148,7 @@ class ArrayDumper
*
* @return array<string, mixed>
*/
private function dumpValues(PackageInterface $package, array $keys, array $data)
private function dumpValues(PackageInterface $package, array $keys, array $data): array
{
foreach ($keys as $method => $key) {
if (is_numeric($method)) {

View File

@ -321,7 +321,7 @@ class ArrayLoader implements LoaderInterface
*
* @return void
*/
private function configureCachedLinks(&$linkCache, $package, array $config)
private function configureCachedLinks(&$linkCache, $package, array $config): void
{
$name = $package->getName();
$prettyVersion = $package->getPrettyVersion();
@ -385,7 +385,7 @@ class ArrayLoader implements LoaderInterface
* @param string $prettyConstraint constraint string
* @return Link
*/
private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint): Link
{
if (!\is_string($prettyConstraint)) {
throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');

View File

@ -194,7 +194,7 @@ class RootPackageLoader extends ArrayLoader
*
* @return list<array{package: string, version: string, alias: string, alias_normalized: string}>
*/
private function extractAliases(array $requires, array $aliases)
private function extractAliases(array $requires, array $aliases): array
{
foreach ($requires as $reqName => $reqVersion) {
if (Preg::isMatch('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
@ -224,7 +224,7 @@ class RootPackageLoader extends ArrayLoader
* @phpstan-param array<string, BasePackage::STABILITY_*> $stabilityFlags
* @phpstan-return array<string, BasePackage::STABILITY_*>
*/
public static function extractStabilityFlags(array $requires, $minimumStability, array $stabilityFlags)
public static function extractStabilityFlags(array $requires, $minimumStability, array $stabilityFlags): array
{
$stabilities = BasePackage::$stabilities;
/** @var int $minimumStability */
@ -286,7 +286,7 @@ class RootPackageLoader extends ArrayLoader
*
* @return array<string, string>
*/
public static function extractReferences(array $requires, array $references)
public static function extractReferences(array $requires, array $references): array
{
foreach ($requires as $reqName => $reqVersion) {
$reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);

View File

@ -494,7 +494,7 @@ class ValidatingArrayLoader implements LoaderInterface
* @phpstan-param non-empty-string $property
* @phpstan-param non-empty-string $regex
*/
private function validateRegex($property, $regex, $mandatory = false)
private function validateRegex($property, $regex, $mandatory = false): bool
{
if (!$this->validateString($property, $mandatory)) {
return false;
@ -523,7 +523,7 @@ class ValidatingArrayLoader implements LoaderInterface
*
* @phpstan-param non-empty-string $property
*/
private function validateString($property, $mandatory = false)
private function validateString($property, $mandatory = false): bool
{
if (isset($this->config[$property]) && !is_string($this->config[$property])) {
$this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
@ -552,7 +552,7 @@ class ValidatingArrayLoader implements LoaderInterface
*
* @phpstan-param non-empty-string $property
*/
private function validateArray($property, $mandatory = false)
private function validateArray($property, $mandatory = false): bool
{
if (isset($this->config[$property]) && !is_array($this->config[$property])) {
$this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
@ -583,7 +583,7 @@ class ValidatingArrayLoader implements LoaderInterface
* @phpstan-param non-empty-string $property
* @phpstan-param non-empty-string|null $regex
*/
private function validateFlatArray($property, $regex = null, $mandatory = false)
private function validateFlatArray($property, $regex = null, $mandatory = false): bool
{
if (!$this->validateArray($property, $mandatory)) {
return false;
@ -617,7 +617,7 @@ class ValidatingArrayLoader implements LoaderInterface
*
* @phpstan-param non-empty-string $property
*/
private function validateUrl($property, $mandatory = false)
private function validateUrl($property, $mandatory = false): bool
{
if (!$this->validateString($property, $mandatory)) {
return false;
@ -639,7 +639,7 @@ class ValidatingArrayLoader implements LoaderInterface
*
* @return bool
*/
private function filterUrl($value, array $schemes = array('http', 'https'))
private function filterUrl($value, array $schemes = array('http', 'https')): bool
{
if ($value === '') {
return true;

View File

@ -419,7 +419,7 @@ class Locker
*
* @phpstan-return list<array<string, mixed>>
*/
private function lockPackages(array $packages)
private function lockPackages(array $packages): array
{
$locked = array();
@ -477,7 +477,7 @@ class Locker
* @param PackageInterface $package The package to scan.
* @return string|null The formatted datetime or null if none was found.
*/
private function getPackageTime(PackageInterface $package)
private function getPackageTime(PackageInterface $package): ?string
{
if (!function_exists('proc_open')) {
return null;

View File

@ -788,7 +788,7 @@ class Package extends BasePackage
* @param string $source
* @return array<string, Link>
*/
private function convertLinksToMap(array $links, $source)
private function convertLinksToMap(array $links, $source): array
{
trigger_error('Package::'.$source.' must be called with a map of lowercased package name => Link object, got a indexed array, this is deprecated and you should fix your usage.');
$newLinks = array();

View File

@ -103,7 +103,7 @@ class VersionGuesser
* @return array
* @phpstan-return Version
*/
private function postprocess(array $versionData)
private function postprocess(array $versionData): array
{
if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
unset($versionData['feature_version'], $versionData['feature_pretty_version']);
@ -126,7 +126,7 @@ class VersionGuesser
*
* @return array{version: string|null, commit: string|null, pretty_version: string|null, feature_version?: string|null, feature_pretty_version?: string|null}
*/
private function guessGitVersion(array $packageConfig, $path)
private function guessGitVersion(array $packageConfig, $path): array
{
GitUtil::cleanEnv();
$commit = null;
@ -211,7 +211,7 @@ class VersionGuesser
*
* @return array{version: string, pretty_version: string}|null
*/
private function versionFromGitTags($path)
private function versionFromGitTags($path): ?array
{
// try to fetch current version from git tags
if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
@ -232,7 +232,7 @@ class VersionGuesser
*
* @return array{version: string|null, commit: ''|null, pretty_version: string|null, feature_version?: string|null, feature_pretty_version?: string|null}|null
*/
private function guessHgVersion(array $packageConfig, $path)
private function guessHgVersion(array $packageConfig, $path): ?array
{
// try to fetch current version from hg branch
if (0 === $this->process->execute('hg branch', $output, $path)) {
@ -276,7 +276,7 @@ class VersionGuesser
*
* @return array{version: string|null, pretty_version: string|null}
*/
private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path): array
{
$prettyVersion = $version;
@ -340,7 +340,7 @@ class VersionGuesser
*
* @return bool
*/
private function isFeatureBranch(array $packageConfig, $branchName)
private function isFeatureBranch(array $packageConfig, $branchName): bool
{
$nonFeatureBranches = '';
if (!empty($packageConfig['non-feature-branches'])) {
@ -355,7 +355,7 @@ class VersionGuesser
*
* @return array{version: string|null, commit: '', pretty_version: string|null}
*/
private function guessFossilVersion($path)
private function guessFossilVersion($path): array
{
$version = null;
$prettyVersion = null;
@ -385,7 +385,7 @@ class VersionGuesser
*
* @return array{version: string, commit: '', pretty_version: string}|null
*/
private function guessSvnVersion(array $packageConfig, $path)
private function guessSvnVersion(array $packageConfig, $path): ?array
{
SvnUtil::cleanEnv();

View File

@ -211,7 +211,7 @@ class VersionSelector
*
* @return string
*/
private function transformVersion($version, $prettyVersion, $stability)
private function transformVersion($version, $prettyVersion, $stability): string
{
// attempt to transform 2.1.1 to 2.1
// this allows you to upgrade through minor versions
@ -242,7 +242,7 @@ class VersionSelector
/**
* @return VersionParser
*/
private function getParser()
private function getParser(): VersionParser
{
if ($this->parser === null) {
$this->parser = new VersionParser();

View File

@ -71,7 +71,7 @@ class Version
* @param string $alpha
* @return int
*/
private static function convertAlphaVersionToIntVersion($alpha)
private static function convertAlphaVersionToIntVersion($alpha): int
{
return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
}
@ -100,7 +100,7 @@ class Version
*
* @return string
*/
private static function convertVersionId($versionId, $base)
private static function convertVersionId($versionId, $base): string
{
return sprintf(
'%d.%d.%d',

View File

@ -530,7 +530,7 @@ class PluginManager
*
* @return array<string, PackageInterface> Map of package names to packages
*/
private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package): array
{
foreach ($package->getRequires() as $requireLink) {
foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
@ -552,7 +552,7 @@ class PluginManager
*
* @return string Install path
*/
private function getInstallPath(PackageInterface $package, $global = false)
private function getInstallPath(PackageInterface $package, $global = false): string
{
if (!$global) {
return $this->composer->getInstallationManager()->getInstallPath($package);
@ -647,7 +647,7 @@ class PluginManager
* @param array<string, bool>|bool|null $allowPluginsConfig
* @return array<non-empty-string, bool>|null
*/
private function parseAllowedPlugins($allowPluginsConfig)
private function parseAllowedPlugins($allowPluginsConfig): ?array
{
if (null === $allowPluginsConfig) {
return null;
@ -674,7 +674,7 @@ class PluginManager
* @param bool $isGlobalPlugin
* @return bool
*/
private function isPluginAllowed($package, $isGlobalPlugin)
private function isPluginAllowed($package, $isGlobalPlugin): bool
{
static $warned = array();
$rules = $isGlobalPlugin ? $this->allowGlobalPluginRules : $this->allowPluginRules;

View File

@ -53,7 +53,7 @@ class StrictConfirmationQuestion extends Question
*
* @return callable
*/
private function getDefaultNormalizer()
private function getDefaultNormalizer(): callable
{
$default = $this->getDefault();
$trueRegex = $this->trueAnswerRegex;
@ -84,7 +84,7 @@ class StrictConfirmationQuestion extends Question
*
* @return callable
*/
private function getDefaultValidator()
private function getDefaultValidator(): callable
{
return function ($answer) {
if (!is_bool($answer)) {

View File

@ -73,7 +73,7 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
*
* @return void
*/
private function scanDirectory($path)
private function scanDirectory($path): void
{
$io = $this->io;
@ -102,7 +102,7 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
/**
* @return ?BasePackage
*/
private function getComposerInformation(\SplFileInfo $file)
private function getComposerInformation(\SplFileInfo $file): ?BasePackage
{
$json = null;
$fileType = null;

View File

@ -39,6 +39,7 @@ use Composer\Semver\Constraint\MatchAllConstraint;
use Composer\Util\Http\Response;
use Composer\MetadataMinifier\MetadataMinifier;
use Composer\Util\Url;
use React\Promise\PromiseInterface;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
@ -399,7 +400,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* @return list<string>
*/
private function getVendorNames()
private function getVendorNames(): array
{
$cacheKey = 'vendor-list.txt';
$cacheAge = $this->cache->getAge($cacheKey);
@ -430,7 +431,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
* @param string|null $packageFilter
* @return list<string>
*/
private function loadPackageList($packageFilter = null)
private function loadPackageList($packageFilter = null): array
{
if (null === $this->listUrl) {
throw new \LogicException('Make sure to call loadRootServerFile before loadPackageList');
@ -640,7 +641,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* @return string[]
*/
private function getProviderNames()
private function getProviderNames(): array
{
$this->loadRootServerFile();
@ -677,7 +678,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* @return bool
*/
private function hasProviders()
private function hasProviders(): bool
{
$this->loadRootServerFile();
@ -694,7 +695,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return array<string, BasePackage>
*/
private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array()): array
{
$packagesSource = null;
if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
@ -862,7 +863,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return array{namesFound: array<string, true>, packages: array<string, BasePackage>}
*/
private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array()): array
{
$this->loadRootServerFile();
@ -972,7 +973,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return bool
*/
private function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
private function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null): bool
{
$versions = array($versionData['version_normalized']);
@ -998,7 +999,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* @return string
*/
private function getPackagesJsonUrl()
private function getPackagesJsonUrl(): string
{
$jsonUrlParts = parse_url($this->url);
@ -1135,7 +1136,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return string
*/
private function canonicalizeUrl($url)
private function canonicalizeUrl($url): string
{
if ('/' === $url[0]) {
if (Preg::isMatch('{^[^:]++://[^/]*+}', $this->url, $matches)) {
@ -1151,7 +1152,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* @return mixed[]
*/
private function loadDataFromServer()
private function loadDataFromServer(): array
{
$data = $this->loadRootServerFile();
@ -1161,7 +1162,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
/**
* @return bool
*/
private function hasPartialPackages()
private function hasPartialPackages(): bool
{
if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
$this->initializePartialPackages();
@ -1175,7 +1176,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return void
*/
private function loadProviderListings($data)
private function loadProviderListings($data): void
{
if (isset($data['providers'])) {
if (!is_array($this->providerListing)) {
@ -1205,7 +1206,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return mixed[]
*/
private function loadIncludes($data)
private function loadIncludes($data): array
{
$packages = array();
@ -1250,7 +1251,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return list<CompletePackage|CompleteAliasPackage>
*/
private function createPackages(array $packages, $source = null)
private function createPackages(array $packages, $source = null): array
{
if (!$packages) {
return array();
@ -1457,10 +1458,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
* @param string $filename
* @param string $cacheKey
* @param string|null $lastModifiedTime
*
* @return \React\Promise\PromiseInterface
*/
private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null): PromiseInterface
{
if (isset($this->packagesNotFoundCache[$filename])) {
return \React\Promise\resolve(array('packages' => array()));
@ -1566,7 +1565,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*
* @return void
*/
private function initializePartialPackages()
private function initializePartialPackages(): void
{
$rootData = $this->loadRootServerFile();

View File

@ -173,7 +173,7 @@ class FilesystemRepository extends WritableArrayRepository
*
* @return string
*/
private function dumpToPhpCode(array $array = array(), $level = 0)
private function dumpToPhpCode(array $array = array(), $level = 0): string
{
$lines = "array(\n";
$level++;
@ -211,7 +211,7 @@ class FilesystemRepository extends WritableArrayRepository
*
* @return ?array<mixed>
*/
private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, $devMode, $repoDir)
private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, $devMode, $repoDir): ?array
{
if (!$this->dumpVersions) {
return null;

View File

@ -195,7 +195,7 @@ class FilterRepository implements RepositoryInterface
*
* @return bool
*/
private function isAllowed($name)
private function isAllowed($name): bool
{
if (!$this->only && !$this->exclude) {
return true;

View File

@ -240,7 +240,7 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
*
* @return string[]
*/
private function getUrlMatches()
private function getUrlMatches(): array
{
$flags = GLOB_MARK | GLOB_ONLYDIR;

View File

@ -586,7 +586,7 @@ class PlatformRepository extends ArrayRepository
*
* @return CompletePackage
*/
private function addOverriddenPackage(array $override, $name = null)
private function addOverriddenPackage(array $override, $name = null): CompletePackage
{
$version = $this->versionParser->normalize($override['version']);
$package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
@ -653,7 +653,7 @@ class PlatformRepository extends ArrayRepository
* @param string $name
* @return string
*/
private function buildPackageName($name)
private function buildPackageName($name): string
{
return 'ext-' . str_replace(' ', '-', strtolower($name));
}
@ -725,7 +725,7 @@ class PlatformRepository extends ArrayRepository
* @internal
* @return string|null
*/
public static function getPlatformPhpVersion()
public static function getPlatformPhpVersion(): ?string
{
return self::$lastSeenPlatformPhp;
}

View File

@ -145,7 +145,7 @@ class RepositoryFactory
*
* @return RepositoryInterface[]
*/
private static function createRepos(RepositoryManager $rm, array $repoConfigs)
private static function createRepos(RepositoryManager $rm, array $repoConfigs): array
{
$repos = array();

View File

@ -336,7 +336,7 @@ class RepositorySet
*
* @return array<string, array<string, array{alias: string, alias_normalized: string}>>
*/
private static function getRootAliasesPerPackage(array $aliases)
private static function getRootAliasesPerPackage(array $aliases): array
{
$normalizedAliases = array();

View File

@ -333,7 +333,7 @@ class GitLabDriver extends VcsDriver
* @param string $string
* @return string
*/
private function urlEncodeAll($string)
private function urlEncodeAll($string): string
{
$encoded = '';
for ($i = 0; isset($string[$i]); $i++) {

View File

@ -55,7 +55,7 @@ class PerforceDriver extends VcsDriver
*
* @return void
*/
private function initPerforce($repoConfig)
private function initPerforce($repoConfig): void
{
if (!empty($this->perforce)) {
return;

View File

@ -542,7 +542,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
/**
* @return bool
*/
private function shouldRethrowTransportException(TransportException $e)
private function shouldRethrowTransportException(TransportException $e): bool
{
return in_array($e->getCode(), array(401, 403, 429), true) || $e->getCode() >= 500;
}

View File

@ -121,7 +121,7 @@ class Event extends BaseEvent
* @param BaseEvent $event
* @return BaseEvent
*/
private function calculateOriginatingEvent(BaseEvent $event)
private function calculateOriginatingEvent(BaseEvent $event): BaseEvent
{
if ($event instanceof Event && $event->getOriginatingEvent()) {
return $this->calculateOriginatingEvent($event->getOriginatingEvent());

View File

@ -95,7 +95,7 @@ class Versions
/**
* @return array<string, array<int, array{path: string, version: string, min-php: int}>>
*/
private function getVersionsData()
private function getVersionsData(): array
{
if (!$this->versionsData) {
if ($this->config->get('disable-tls') === true) {

View File

@ -92,7 +92,7 @@ class Bitbucket
/**
* @return bool
*/
private function requestAccessToken()
private function requestAccessToken(): bool
{
try {
$response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
@ -246,7 +246,7 @@ class Bitbucket
* @param string $originUrl
* @return bool
*/
private function getTokenFromConfig($originUrl)
private function getTokenFromConfig($originUrl): bool
{
$authConfig = $this->config->get('bitbucket-oauth');

View File

@ -177,7 +177,7 @@ class Filesystem
*
* @return bool|null Returns null, when no edge case was hit. Otherwise a bool whether removal was successful
*/
private function removeEdgeCases($directory, $fallbackToPhp = true)
private function removeEdgeCases($directory, $fallbackToPhp = true): ?bool
{
if ($this->isSymlinkedDirectory($directory)) {
return $this->unlinkSymlinkedDirectory($directory);
@ -711,7 +711,7 @@ class Filesystem
*
* @return bool
*/
private function unlinkImplementation($path)
private function unlinkImplementation($path): bool
{
if (Platform::isWindows() && is_dir($path) && is_link($path)) {
return rmdir($path);
@ -767,7 +767,7 @@ class Filesystem
*
* @return bool
*/
private function unlinkSymlinkedDirectory($directory)
private function unlinkSymlinkedDirectory($directory): bool
{
$resolved = $this->resolveSymlinkedDirectorySymlink($directory);
@ -781,7 +781,7 @@ class Filesystem
*
* @return string resolved path to symbolic link or original pathname (unresolved)
*/
private function resolveSymlinkedDirectorySymlink($pathname)
private function resolveSymlinkedDirectorySymlink($pathname): string
{
if (!is_dir($pathname)) {
return $pathname;
@ -926,7 +926,7 @@ class Filesystem
*
* @return bool
*/
private function filesAreEqual($a, $b)
private function filesAreEqual($a, $b): bool
{
// Check if filesize is different
if (filesize($a) !== filesize($b)) {

View File

@ -349,7 +349,7 @@ class Git
*
* @return bool
*/
private function checkRefIsInMirror($dir, $ref)
private function checkRefIsInMirror($dir, $ref): bool
{
if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
$escapedRef = ProcessExecutor::escape($ref.'^{commit}');
@ -368,7 +368,7 @@ class Git
*
* @return bool
*/
private function isAuthenticationFailure($url, &$match)
private function isAuthenticationFailure($url, &$match): bool
{
if (!Preg::isMatch('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
return false;
@ -441,7 +441,7 @@ class Git
*
* @return never
*/
private function throwException($message, $url)
private function throwException($message, $url): void
{
// git might delete a directory when it fails and php will not know
clearstatcache();
@ -476,7 +476,7 @@ class Git
*
* @return string
*/
private function maskCredentials($error, array $credentials)
private function maskCredentials($error, array $credentials): string
{
$maskedCredentials = array();

View File

@ -169,7 +169,7 @@ class GitLab
*
* @see https://docs.gitlab.com/ee/api/oauth2.html#resource-owner-password-credentials-flow
*/
private function createToken($scheme, $originUrl)
private function createToken($scheme, $originUrl): array
{
$username = $this->io->ask('Username: ');
$password = $this->io->askAndHideAnswer('Password: ');

View File

@ -89,7 +89,7 @@ class Hg
*
* @return never
*/
private function throwException($message, $url)
private function throwException($message, $url): void
{
if (null === self::getVersion($this->process)) {
throw new \RuntimeException(Url::sanitize('Failed to clone ' . $url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()));

View File

@ -133,7 +133,7 @@ class CurlDownloader
*
* @return int internal job id
*/
public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
public function download($resolve, $reject, $origin, $url, $options, $copyTo = null): int
{
$attributes = array();
if (isset($options['retry-auth-failure'])) {
@ -156,7 +156,7 @@ class CurlDownloader
*
* @return int internal job id
*/
private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array()): int
{
// set defaults in a PHPStan-happy way (array_merge is not well supported)
$attributes['retryAuthFailure'] = $attributes['retryAuthFailure'] ?? true;
@ -489,7 +489,7 @@ class CurlDownloader
* @param Job $job
* @return string
*/
private function handleRedirect(array $job, Response $response)
private function handleRedirect(array $job, Response $response): string
{
if ($locationHeader = $response->getHeader('location')) {
if (parse_url($locationHeader, PHP_URL_SCHEME)) {
@ -524,7 +524,7 @@ class CurlDownloader
* @param Job $job
* @return array{retry: bool, storeAuth: string|bool}
*/
private function isAuthenticatedRetryNeeded(array $job, Response $response)
private function isAuthenticatedRetryNeeded(array $job, Response $response): array
{
if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
$result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
@ -596,7 +596,7 @@ class CurlDownloader
* @param string $errorMessage
* @return TransportException
*/
private function failResponse(array $job, Response $response, $errorMessage)
private function failResponse(array $job, Response $response, $errorMessage): TransportException
{
if (null !== $job['filename']) {
@unlink($job['filename'].'~');

View File

@ -27,7 +27,7 @@ class ProxyHelper
*
* @throws \RuntimeException on malformed url
*/
public static function getProxyData()
public static function getProxyData(): array
{
$httpProxy = null;
$httpsProxy = null;
@ -64,7 +64,7 @@ class ProxyHelper
*
* @return array{http: array{proxy: string, header?: string}}
*/
public static function getContextOptions($proxyUrl)
public static function getContextOptions($proxyUrl): array
{
$proxy = parse_url($proxyUrl);
@ -114,7 +114,7 @@ class ProxyHelper
*
* @return string|null The found value
*/
private static function getProxyEnv(array $names, &$name)
private static function getProxyEnv(array $names, &$name): ?string
{
foreach ($names as $name) {
if (!empty($_SERVER[$name])) {
@ -133,7 +133,7 @@ class ProxyHelper
* @throws \RuntimeException on malformed url
* @return string The formatted proxy url
*/
private static function checkProxy($proxyUrl, $envName)
private static function checkProxy($proxyUrl, $envName): string
{
$error = sprintf('malformed %s url', $envName);
$proxy = parse_url($proxyUrl);
@ -161,7 +161,7 @@ class ProxyHelper
*
* @return string The formatted value
*/
private static function formatParsedUrl(array $proxy, $includeAuth)
private static function formatParsedUrl(array $proxy, $includeAuth): string
{
$proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';

View File

@ -58,7 +58,7 @@ class ProxyManager
/**
* @return ProxyManager
*/
public static function getInstance()
public static function getInstance(): ProxyManager
{
if (!self::$instance) {
self::$instance = new self();
@ -83,7 +83,7 @@ class ProxyManager
* @param string $requestUrl
* @return RequestProxy
*/
public function getProxyForRequest($requestUrl)
public function getProxyForRequest($requestUrl): RequestProxy
{
if ($this->error) {
throw new TransportException('Unable to use a proxy: '.$this->error);
@ -113,7 +113,7 @@ class ProxyManager
*
* @return bool If false any error will be in $message
*/
public function isProxying()
public function isProxying(): bool
{
return $this->hasProxy;
}
@ -123,7 +123,7 @@ class ProxyManager
*
* @return string|null Safe proxy URL or an error message if setting up proxy failed or null if no proxy was configured
*/
public function getFormattedProxy()
public function getFormattedProxy(): ?string
{
return $this->hasProxy ? $this->info : $this->error;
}
@ -167,7 +167,7 @@ class ProxyManager
*
* @return non-empty-string
*/
private function setData($url, $scheme)
private function setData($url, $scheme): string
{
$safeProxy = Url::sanitize($url);
$this->fullProxy[$scheme] = $url;
@ -184,7 +184,7 @@ class ProxyManager
* @param string $requestUrl
* @return bool
*/
private function noProxy($requestUrl)
private function noProxy($requestUrl): bool
{
return $this->noProxyHandler && $this->noProxyHandler->test($requestUrl);
}

View File

@ -47,7 +47,7 @@ class RequestProxy
*
* @return mixed[]
*/
public function getContextOptions()
public function getContextOptions(): array
{
return $this->contextOptions;
}
@ -58,7 +58,7 @@ class RequestProxy
* @param string|null $format Output format specifier
* @return string Safe proxy, no proxy or empty
*/
public function getFormattedUrl($format = '')
public function getFormattedUrl($format = ''): string
{
$result = '';
if ($this->formattedUrl) {
@ -74,7 +74,7 @@ class RequestProxy
*
* @return string Proxy url or empty
*/
public function getUrl()
public function getUrl(): string
{
return $this->url;
}
@ -84,7 +84,7 @@ class RequestProxy
*
* @return bool False if not secure or there is no proxy
*/
public function isSecure()
public function isSecure(): bool
{
return $this->isSecure;
}

View File

@ -191,7 +191,7 @@ class HttpDownloader
*
* @return array{Job, PromiseInterface}
*/
private function addJob($request, $sync = false)
private function addJob($request, $sync = false): array
{
$request['options'] = array_replace_recursive($this->options, $request['options']);
@ -291,7 +291,7 @@ class HttpDownloader
* @param int $id
* @return void
*/
private function startJob($id)
private function startJob($id): void
{
$job = &$this->jobs[$id];
if ($job['status'] !== self::STATUS_QUEUED) {
@ -355,7 +355,7 @@ class HttpDownloader
*
* @return void
*/
public function enableAsync()
public function enableAsync(): void
{
$this->allowAsync = true;
}
@ -366,7 +366,7 @@ class HttpDownloader
* @param int|null $index For internal use only, the job id
* @return int number of active (queued or started) jobs
*/
public function countActiveJobs($index = null)
public function countActiveJobs($index = null): int
{
if ($this->runningJobs < $this->maxJobs) {
foreach ($this->jobs as $job) {
@ -400,7 +400,7 @@ class HttpDownloader
* @param int $index Job id
* @return Response
*/
private function getResponse($index)
private function getResponse($index): Response
{
if (!isset($this->jobs[$index])) {
throw new \LogicException('Invalid request id');
@ -428,7 +428,7 @@ class HttpDownloader
* @param array{warning?: string, info?: string, warning-versions?: string, info-versions?: string, warnings?: array<array{versions: string, message: string}>, infos?: array<array{versions: string, message: string}>} $data
* @return void
*/
public static function outputWarnings(IOInterface $io, $url, $data)
public static function outputWarnings(IOInterface $io, $url, $data): void
{
// legacy warning/info keys
foreach (array('warning', 'info') as $type) {
@ -473,7 +473,7 @@ class HttpDownloader
*
* @return ?string[]
*/
public static function getExceptionHints(\Exception $e)
public static function getExceptionHints(\Exception $e): ?array
{
if (!$e instanceof TransportException) {
return null;
@ -507,7 +507,7 @@ class HttpDownloader
* @param Job $job
* @return bool
*/
private function canUseCurl(array $job)
private function canUseCurl(array $job): bool
{
if (!$this->curl) {
return false;
@ -528,7 +528,7 @@ class HttpDownloader
* @internal
* @return bool
*/
public static function isCurlEnabled()
public static function isCurlEnabled(): bool
{
return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
}

View File

@ -186,7 +186,7 @@ class NoProxyPattern
*
* @return null|stdClass Null if the hostname is invalid
*/
private function getRule($index, $hostName)
private function getRule($index, $hostName): ?stdClass
{
if (array_key_exists($index, $this->rules)) {
return $this->rules[$index];
@ -213,7 +213,7 @@ class NoProxyPattern
*
* @return bool False if the host contains invalid data
*/
private function ipCheckData($host, &$ipdata, $allowPrefix = false)
private function ipCheckData($host, &$ipdata, $allowPrefix = false): bool
{
$ipdata = null;
$netmask = null;
@ -262,7 +262,7 @@ class NoProxyPattern
*
* @return mixed[] in_addr, size
*/
private function ipGetAddr($host)
private function ipGetAddr($host): array
{
$ip = inet_pton($host);
$size = strlen($ip);
@ -279,7 +279,7 @@ class NoProxyPattern
*
* @return string
*/
private function ipGetMask($prefix, $size)
private function ipGetMask($prefix, $size): string
{
$mask = '';
@ -305,7 +305,7 @@ class NoProxyPattern
*
* @return string[] network in_addr, binary mask
*/
private function ipGetNetwork($rangeIp, $size, $prefix)
private function ipGetNetwork($rangeIp, $size, $prefix): array
{
$netmask = $this->ipGetMask($prefix, $size);
@ -335,7 +335,7 @@ class NoProxyPattern
*
* @return string Mapped or existing in_addr
*/
private function ipMapTo6($binary, $size)
private function ipMapTo6($binary, $size): string
{
if ($size === 4) {
$prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
@ -354,7 +354,7 @@ class NoProxyPattern
*
* @return stdClass
*/
private function makeData($host, $port, $ipdata)
private function makeData($host, $port, $ipdata): stdClass
{
return (object) array(
'host' => $host,
@ -373,7 +373,7 @@ class NoProxyPattern
*
* @return stdClass
*/
private function makeIpData($ip, $size, $netmask)
private function makeIpData($ip, $size, $netmask): stdClass
{
return (object) array(
'ip' => $ip,
@ -389,7 +389,7 @@ class NoProxyPattern
*
* @return mixed[] host, port, if there was error
*/
private function splitHostPort($hostName)
private function splitHostPort($hostName): array
{
// host, port, err
$error = array('', '', true);
@ -439,7 +439,7 @@ class NoProxyPattern
*
* @return bool
*/
private function validateInt($int, $min, $max)
private function validateInt($int, $min, $max): bool
{
$options = array(
'options' => array(

View File

@ -216,7 +216,7 @@ class Platform
*
* @return bool
*/
private static function isVirtualBoxGuest()
private static function isVirtualBoxGuest(): bool
{
if (null === self::$isVirtualBoxGuest) {
self::$isVirtualBoxGuest = false;

View File

@ -100,7 +100,7 @@ class ProcessExecutor
* @param mixed $output
* @return int
*/
private function doExecute($command, $cwd, $tty, &$output = null)
private function doExecute($command, $cwd, $tty, &$output = null): int
{
$this->outputCommandRun($command, $cwd, false);
@ -210,7 +210,7 @@ class ProcessExecutor
* @param int $id
* @return void
*/
private function startJob($id)
private function startJob($id): void
{
$job = &$this->jobs[$id];
if ($job['status'] !== self::STATUS_QUEUED) {
@ -269,7 +269,7 @@ class ProcessExecutor
*
* @return void
*/
public function enableAsync()
public function enableAsync(): void
{
$this->allowAsync = true;
}
@ -280,7 +280,7 @@ class ProcessExecutor
* @param ?int $index job id
* @return int number of active (queued or started) jobs
*/
public function countActiveJobs($index = null)
public function countActiveJobs($index = null): int
{
// tick
foreach ($this->jobs as $job) {
@ -437,7 +437,7 @@ class ProcessExecutor
*
* @return string
*/
private static function escapeArgument($argument)
private static function escapeArgument($argument): string
{
if ('' === ($argument = (string) $argument)) {
return escapeshellarg($argument);

View File

@ -106,7 +106,7 @@ class RemoteFilesystem
*
* @return bool true
*/
public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array()): bool
{
return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
}
@ -131,7 +131,7 @@ class RemoteFilesystem
*
* @return mixed[] Options
*/
public function getOptions()
public function getOptions(): array
{
return $this->options;
}
@ -142,7 +142,7 @@ class RemoteFilesystem
* @param mixed[] $options
* @return void
*/
public function setOptions(array $options)
public function setOptions(array $options): void
{
$this->options = array_replace_recursive($this->options, $options);
}
@ -152,7 +152,7 @@ class RemoteFilesystem
*
* @return bool
*/
public function isTlsDisabled()
public function isTlsDisabled(): bool
{
return $this->disableTls === true;
}
@ -162,7 +162,7 @@ class RemoteFilesystem
*
* @return string[]
*/
public function getLastHeaders()
public function getLastHeaders(): array
{
return $this->lastHeaders;
}
@ -171,7 +171,7 @@ class RemoteFilesystem
* @param string[] $headers array of returned headers like from getLastHeaders()
* @return int|null
*/
public static function findStatusCode(array $headers)
public static function findStatusCode(array $headers): ?int
{
$value = null;
foreach ($headers as $header) {
@ -189,7 +189,7 @@ class RemoteFilesystem
* @param string[] $headers array of returned headers like from getLastHeaders()
* @return string|null
*/
public function findStatusMessage(array $headers)
public function findStatusMessage(array $headers): ?string
{
$value = null;
foreach ($headers as $header) {
@ -554,7 +554,7 @@ class RemoteFilesystem
*
* @throws TransportException
*/
protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax): void
{
switch ($notificationCode) {
case STREAM_NOTIFY_FAILURE:
@ -592,7 +592,7 @@ class RemoteFilesystem
*
* @return void
*/
protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array()): void
{
$result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
@ -610,7 +610,7 @@ class RemoteFilesystem
*
* @return mixed[]
*/
protected function getOptionsForUrl($originUrl, $additionalOptions)
protected function getOptionsForUrl($originUrl, $additionalOptions): array
{
$tlsOptions = array();
$headers = array();
@ -698,7 +698,7 @@ class RemoteFilesystem
*
* @return string|null
*/
private function decodeResult($result, $http_response_header)
private function decodeResult($result, $http_response_header): ?string
{
// decode gzip
if ($result && extension_loaded('zlib')) {
@ -722,7 +722,7 @@ class RemoteFilesystem
*
* @return string|null
*/
private function normalizeResult($result)
private function normalizeResult($result): ?string
{
if ($result === false) {
return null;

View File

@ -63,7 +63,7 @@ final class StreamContextFactory
* @phpstan-return array{http: array{header: string[], proxy?: string, request_fulluri: bool}, ssl?: mixed[]}
* @return array formatted as a stream context array
*/
public static function initOptions($url, array $options, $forCurl = false)
public static function initOptions($url, array $options, $forCurl = false): array
{
// Make sure the headers are in an array form
if (!isset($options['http']['header'])) {
@ -134,7 +134,7 @@ final class StreamContextFactory
*
* @return mixed[]
*/
public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
public static function getTlsDefaults(array $options, LoggerInterface $logger = null): array
{
$ciphers = implode(':', array(
'ECDHE-RSA-AES128-GCM-SHA256',
@ -240,7 +240,7 @@ final class StreamContextFactory
* @param string|string[] $header
* @return string[]
*/
private static function fixHttpHeaderField($header)
private static function fixHttpHeaderField($header): array
{
if (!is_array($header)) {
$header = explode("\r\n", $header);

View File

@ -140,7 +140,7 @@ class Svn
*
* @return ?string
*/
private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose): ?string
{
// Regenerate the command at each try, to use the newly user-provided credentials
$command = $this->getCommand($svnCommand, $url, $path);
@ -337,7 +337,7 @@ class Svn
*
* @return bool
*/
private function createAuthFromConfig()
private function createAuthFromConfig(): bool
{
if (!$this->config->has('http-basic')) {
return $this->hasAuth = false;
@ -363,7 +363,7 @@ class Svn
*
* @return bool
*/
private function createAuthFromUrl()
private function createAuthFromUrl(): bool
{
$uri = parse_url($this->url);
if (empty($uri['user'])) {

View File

@ -40,7 +40,7 @@ class Tar
*
* @return string
*/
private static function extractComposerJsonFromFolder(\PharData $phar)
private static function extractComposerJsonFromFolder(\PharData $phar): string
{
if (isset($phar['composer.json'])) {
return $phar['composer.json']->getContent();

View File

@ -30,7 +30,7 @@ final class TlsHelper
*
* @return bool
*/
public static function checkCertificateHost($certificate, $hostname, &$cn = null)
public static function checkCertificateHost($certificate, $hostname, &$cn = null): bool
{
$names = self::getCertificateNames($certificate);
@ -61,7 +61,7 @@ final class TlsHelper
*
* @return array{cn: string, san: string[]}|null
*/
public static function getCertificateNames($certificate)
public static function getCertificateNames($certificate): ?array
{
if (is_array($certificate)) {
$info = $certificate;
@ -136,7 +136,7 @@ final class TlsHelper
* @param string $certificate
* @return string
*/
public static function getCertificateFingerprint($certificate)
public static function getCertificateFingerprint($certificate): string
{
$pubkey = openssl_get_publickey($certificate);
if ($pubkey === false) {
@ -161,7 +161,7 @@ final class TlsHelper
*
* @return bool
*/
public static function isOpensslParseSafe()
public static function isOpensslParseSafe(): bool
{
return CaBundle::isOpensslParseSafe();
}
@ -173,7 +173,7 @@ final class TlsHelper
*
* @return callable|null
*/
private static function certNameMatcher($certName)
private static function certNameMatcher($certName): ?callable
{
$wildcards = substr_count($certName, '*');

View File

@ -65,7 +65,7 @@ class Zip
*
* @return int
*/
private static function locateFile(\ZipArchive $zip, $filename)
private static function locateFile(\ZipArchive $zip, $filename): int
{
// return root composer.json if it is there and is a file
if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {

View File

@ -179,7 +179,7 @@ class AllFunctionalTest extends TestCase
/**
* @return array<string, array<string>>
*/
public function getTestFiles()
public function getTestFiles(): array
{
$tests = array();
foreach (Finder::create()->in(__DIR__.'/Fixtures/functional')->name('*.test')->files() as $file) {
@ -193,7 +193,7 @@ class AllFunctionalTest extends TestCase
* @param string $file
* @return array{RUN: string, EXPECT?: string, EXPECT-EXIT-CODE?: int, EXPECT-REGEX?: string, EXPECT-REGEXES?: string, TEST?: string}
*/
private function parseTestFile($file)
private function parseTestFile($file): array
{
$tokens = Preg::split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file), -1, PREG_SPLIT_DELIM_CAPTURE);
$data = array();
@ -255,7 +255,7 @@ class AllFunctionalTest extends TestCase
* @param string $output
* @return string
*/
private function cleanOutput($output)
private function cleanOutput($output): string
{
$processed = '';

View File

@ -1741,7 +1741,7 @@ EOF;
/**
* @return array<string, mixed[]>
*/
public function platformCheckProvider()
public function platformCheckProvider(): array
{
$versionParser = new VersionParser();

View File

@ -42,7 +42,7 @@ class ClassLoaderTest extends TestCase
*
* @return array<array<string>> Array of parameter sets to test with.
*/
public function getLoadClassTests()
public function getLoadClassTests(): array
{
return array(
array('Namespaced\\Foo'),

View File

@ -38,7 +38,7 @@ class ClassMapGeneratorTest extends TestCase
/**
* @return array<array<string|array<string>>>
*/
public function getTestCreateMapTests()
public function getTestCreateMapTests(): array
{
$classmap = array(
'Foo\\Bar\\A' => realpath(__DIR__) . '/Fixtures/classmap/sameNsMultipleClasses.php',

View File

@ -89,7 +89,7 @@ class RunScriptCommandTest extends TestCase
}
/** @return bool[][] **/
public function getDevOptions()
public function getDevOptions(): array
{
return array(
array(true, true),
@ -100,7 +100,7 @@ class RunScriptCommandTest extends TestCase
}
/** @return Composer **/
private function createComposerInstance()
private function createComposerInstance(): Composer
{
$composer = new Composer;
$config = new Config;

View File

@ -29,7 +29,7 @@ class JsonConfigSourceTest extends TestCase
*
* @return string
*/
protected function fixturePath($name)
protected function fixturePath($name): string
{
return __DIR__.'/Fixtures/'.$name;
}
@ -160,7 +160,7 @@ class JsonConfigSourceTest extends TestCase
*
* @phpstan-return array{string, string, string, string, string}
*/
protected function addLinkDataArguments($type, $name, $value, $fixtureBasename, $before)
protected function addLinkDataArguments($type, $name, $value, $fixtureBasename, $before): array
{
return array(
$before,
@ -217,7 +217,7 @@ class JsonConfigSourceTest extends TestCase
*
* @phpstan-return array{string, string, string, string}
*/
protected function removeLinkDataArguments($type, $name, $fixtureBasename, $after = null)
protected function removeLinkDataArguments($type, $name, $fixtureBasename, $after = null): array
{
return array(
$this->fixturePath('removeLink/'.$fixtureBasename.'.json'),

View File

@ -269,7 +269,7 @@ class ConfigTest extends TestCase
/**
* @return string[][] List of test URLs that should pass strict security
*/
public function allowedUrlProvider()
public function allowedUrlProvider(): array
{
$urls = array(
'https://packagist.org',
@ -290,7 +290,7 @@ class ConfigTest extends TestCase
/**
* @return string[][] List of test URLs that should not pass strict security
*/
public function prohibitedUrlProvider()
public function prohibitedUrlProvider(): array
{
$urls = array(
'http://packagist.org',

View File

@ -149,7 +149,7 @@ class PoolBuilderTest extends TestCase
* @param array<int, BasePackage> $packageIds
* @return string[]
*/
private function getPackageResultSet(Pool $pool, $packageIds)
private function getPackageResultSet(Pool $pool, $packageIds): array
{
$result = array();
for ($i = 1, $count = count($pool); $i <= $count; $i++) {
@ -184,7 +184,7 @@ class PoolBuilderTest extends TestCase
/**
* @return array<string, array<string>>
*/
public function getIntegrationTests()
public function getIntegrationTests(): array
{
$fixturesDir = realpath(__DIR__.'/Fixtures/poolbuilder/');
$tests = array();
@ -223,7 +223,7 @@ class PoolBuilderTest extends TestCase
* @param string $fixturesDir
* @return array<string, string>
*/
protected function readTestFile(\SplFileInfo $file, $fixturesDir)
protected function readTestFile(\SplFileInfo $file, $fixturesDir): array
{
$tokens = Preg::split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file->getRealPath()), -1, PREG_SPLIT_DELIM_CAPTURE);

View File

@ -100,7 +100,7 @@ class PoolOptimizerTest extends TestCase
* @param string $fixturesDir
* @return mixed[]
*/
protected function readTestFile(\SplFileInfo $file, $fixturesDir)
protected function readTestFile(\SplFileInfo $file, $fixturesDir): array
{
$tokens = Preg::split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file->getRealPath()), -1, PREG_SPLIT_DELIM_CAPTURE);
@ -154,7 +154,7 @@ class PoolOptimizerTest extends TestCase
* @param BasePackage[] $packages
* @return string[]
*/
private function reducePackagesInfoForComparison(array $packages)
private function reducePackagesInfoForComparison(array $packages): array
{
$packagesInfo = array();
@ -171,7 +171,7 @@ class PoolOptimizerTest extends TestCase
* @param mixed[][] $packagesData
* @return BasePackage[]
*/
private function loadPackages(array $packagesData)
private function loadPackages(array $packagesData): array
{
$packages = array();
@ -189,7 +189,7 @@ class PoolOptimizerTest extends TestCase
* @param mixed[] $packageData
* @return BasePackage
*/
private function loadPackage(array $packageData)
private function loadPackage(array $packageData): BasePackage
{
$loader = new ArrayLoader();

View File

@ -61,7 +61,7 @@ class PoolTest extends TestCase
* @param array<\Composer\Package\BasePackage>|null $packages
* @return \Composer\DependencyResolver\Pool
*/
protected function createPool($packages = array())
protected function createPool($packages = array()): \Composer\DependencyResolver\Pool
{
return new Pool($packages);
}

View File

@ -43,7 +43,7 @@ class FileDownloaderTest extends TestCase
* @param \Composer\Util\Filesystem $filesystem
* @return \Composer\Downloader\FileDownloader
*/
protected function getDownloader($io = null, $config = null, $eventDispatcher = null, $cache = null, $httpDownloader = null, $filesystem = null)
protected function getDownloader($io = null, $config = null, $eventDispatcher = null, $cache = null, $httpDownloader = null, $filesystem = null): \Composer\Downloader\FileDownloader
{
$io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$config = $config ?: $this->config;

View File

@ -42,7 +42,7 @@ class FossilDownloaderTest extends TestCase
* @param \Composer\Util\Filesystem $filesystem
* @return FossilDownloader
*/
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null)
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null): FossilDownloader
{
$io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$config = $config ?: $this->getMockBuilder('Composer\Config')->getMock();

View File

@ -62,7 +62,7 @@ class GitDownloaderTest extends TestCase
* @param ?\Composer\Config $config
* @return \Composer\Config
*/
protected function setupConfig($config = null)
protected function setupConfig($config = null): \Composer\Config
{
if (!$config) {
$config = new Config();
@ -82,7 +82,7 @@ class GitDownloaderTest extends TestCase
* @param \Composer\Util\Filesystem $filesystem
* @return GitDownloader
*/
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null)
protected function getDownloaderMock($io = null, $config = null, $executor = null, $filesystem = null): GitDownloader
{
$io = $io ?: $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$executor = $executor ?: $this->getProcessExecutorMock();
@ -647,7 +647,7 @@ composer https://github.com/old/url (push)
* @param string $cmd
* @return string
*/
private function winCompat($cmd)
private function winCompat($cmd): string
{
if (Platform::isWindows()) {
$cmd = str_replace('cd ', 'cd /D ', $cmd);

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