Type annotations

main
Jordi Boggiano 3 years ago
parent 98f1465610
commit b209816056
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -107,7 +107,10 @@ class Pool implements \Countable
}
/**
* @see whatProvides
* @param string $name The package name to be searched for
* @param ConstraintInterface $constraint A constraint that all returned
* packages must match or null to return all
* @return BasePackage[]
*/
private function computeWhatProvides($name, $constraint)
{
@ -126,6 +129,9 @@ class Pool implements \Countable
return $matches;
}
/**
* @return BasePackage
*/
public function literalToPackage($literal)
{
$packageId = abs($literal);
@ -133,6 +139,9 @@ class Pool implements \Countable
return $this->packageById($packageId);
}
/**
* @return string
*/
public function literalToPrettyString($literal, $installedMap)
{
$package = $this->literalToPackage($literal);
@ -195,6 +204,9 @@ class Pool implements \Countable
return false;
}
/**
* @return bool
*/
public function isUnacceptableFixedOrLockedPackage(BasePackage $package)
{
return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);

@ -139,6 +139,9 @@ class PoolBuilder
$this->io = $io;
}
/**
* @return Pool
*/
public function buildPool(array $repositories, Request $request)
{
if ($request->getUpdateAllowList()) {
@ -261,6 +264,9 @@ class PoolBuilder
return $pool;
}
/**
* @return void
*/
private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
{
// Skip platform requires at this stage
@ -316,6 +322,9 @@ class PoolBuilder
unset($this->loadedPackages[$name]);
}
/**
* @return void
*/
private function loadPackagesMarkedForLoading(Request $request, $repositories)
{
foreach ($this->packagesToLoad as $name => $constraint) {
@ -348,6 +357,9 @@ class PoolBuilder
}
}
/**
* @return void
*/
private function loadPackage(Request $request, BasePackage $package, $propagateUpdate = true)
{
$index = $this->indexCounter++;
@ -445,6 +457,7 @@ class PoolBuilder
/**
* Checks whether the update allow list allows this package in the lock file to be updated
*
* @return bool
*/
private function isUpdateAllowed(PackageInterface $package)
@ -469,6 +482,9 @@ class PoolBuilder
return false;
}
/**
* @return void
*/
private function warnAboutNonMatchingUpdateAllowList(Request $request)
{
foreach ($this->updateAllowList as $pattern => $void) {
@ -496,6 +512,8 @@ class PoolBuilder
/**
* Reverts the decision to use a locked package if a partial update with transitive dependencies
* found that this package actually needs to be updated
*
* @return void
*/
private function unlockPackage(Request $request, $name)
{
@ -534,6 +552,9 @@ class PoolBuilder
}
}
/**
* @return void
*/
private function removeLoadedPackage(Request $request, PackageInterface $package, $index)
{
unset($this->packages[$index]);

@ -102,6 +102,7 @@ class Problem
/**
* @internal
* @return string
*/
public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
{
@ -144,6 +145,9 @@ class Problem
return "\n$indent- ".implode("\n$indent- ", $result);
}
/**
* @return bool
*/
public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
{
foreach ($this->reasons as $sectionRules) {
@ -153,6 +157,8 @@ class Problem
}
}
}
return false;
}
/**
@ -160,6 +166,8 @@ class Problem
*
* @param string $id A canonical identifier for the reason
* @param Rule $reason The reason descriptor
*
* @return void
*/
protected function addReason($id, Rule $reason)
{
@ -172,6 +180,9 @@ class Problem
}
}
/**
* @return void
*/
public function nextSection()
{
$this->section++;
@ -179,6 +190,7 @@ class Problem
/**
* @internal
* @return array{0: string, 1: string}
*/
public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, $constraint = null)
{
@ -331,6 +343,7 @@ class Problem
/**
* @internal
* @return string
*/
public static function getPackageList(array $packages, $isVerbose)
{
@ -360,6 +373,11 @@ class Problem
return implode(', ', $prepared);
}
/**
* @param string $version
* @param string $packageName
* @return string
*/
private static function getPlatformPackageVersion(Pool $pool, $packageName, $version)
{
$available = $pool->whatProvides($packageName);
@ -410,6 +428,9 @@ class Problem
return $filtered;
}
/**
* @return bool
*/
private static function hasMultipleNames(array $packages)
{
$name = null;
@ -424,6 +445,9 @@ class Problem
return false;
}
/**
* @return array{0: string, 1: string}
*/
private static function computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, array $higherRepoPackages, array $allReposPackages, $reason)
{
$nextRepoPackages = array();

@ -123,46 +123,73 @@ class Request
$this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
}
/**
* @return string[]
*/
public function getUpdateAllowList()
{
return $this->updateAllowList;
}
/**
* @return bool
*/
public function getUpdateAllowTransitiveDependencies()
{
return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
}
/**
* @return bool
*/
public function getUpdateAllowTransitiveRootDependencies()
{
return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
}
/**
* @return array<string, ConstraintInterface>
*/
public function getRequires()
{
return $this->requires;
}
/**
* @return array<string, PackageInterface>
*/
public function getFixedPackages()
{
return $this->fixedPackages;
}
/**
* @return bool
*/
public function isFixedPackage(PackageInterface $package)
{
return isset($this->fixedPackages[spl_object_hash($package)]);
}
/**
* @return array<string, PackageInterface>
*/
public function getLockedPackages()
{
return $this->lockedPackages;
}
/**
* @return bool
*/
public function isLockedPackage(PackageInterface $package)
{
return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
}
/**
* @return array<string, PackageInterface>
*/
public function getFixedOrLockedPackages()
{
return array_merge($this->fixedPackages, $this->lockedPackages);
@ -170,6 +197,9 @@ class Request
// TODO look into removing the packageIds option, the only place true is used is for the installed map in the solver problems
// some locked packages may not be in the pool so they have a package->id of -1
/**
* @return array<int|string, PackageInterface>
*/
public function getPresentMap($packageIds = false)
{
$presentMap = array();
@ -187,6 +217,9 @@ class Request
return $presentMap;
}
/**
* @return PackageInterface[]
*/
public function getFixedPackagesMap()
{
$fixedPackagesMap = array();
@ -198,6 +231,9 @@ class Request
return $fixedPackagesMap;
}
/**
* @return ?LockArrayRepository
*/
public function getLockedRepository()
{
return $this->lockedRepository;

@ -100,12 +100,18 @@ class RuleSet implements \IteratorAggregate, \Countable
}
}
/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return $this->nextRuleId;
}
/**
* @return Rule
*/
public function ruleById($id)
{
return $this->ruleById[$id];
@ -148,6 +154,9 @@ class RuleSet implements \IteratorAggregate, \Countable
return new RuleSetIterator($rules);
}
/**
* @return RuleSetIterator
*/
public function getIteratorWithout($types)
{
if (!\is_array($types)) {
@ -172,6 +181,9 @@ class RuleSet implements \IteratorAggregate, \Countable
return array_keys($types);
}
/**
* @return string
*/
public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
{
$string = "\n";

@ -122,6 +122,9 @@ class RuleSetGenerator
return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
}
/**
* @return Rule
*/
protected function createMultiConflictRule(array $packages, $reason, $reasonData = null)
{
$literals = array();
@ -144,6 +147,8 @@ class RuleSetGenerator
*
* @param int $type A TYPE_* constant defining the rule type
* @param Rule $newRule The rule about to be added
*
* @return void
*/
private function addRule($type, Rule $newRule = null)
{
@ -154,6 +159,9 @@ class RuleSetGenerator
$this->rules->add($newRule, $type);
}
/**
* @return void
*/
protected function addRulesForPackage(BasePackage $package, $ignorePlatformReqs)
{
/** @var \SplQueue<BasePackage> */
@ -202,6 +210,9 @@ class RuleSetGenerator
}
}
/**
* @return void
*/
protected function addConflictRules($ignorePlatformReqs = false)
{
/** @var BasePackage $package */
@ -237,6 +248,9 @@ class RuleSetGenerator
}
}
/**
* @return void
*/
protected function addRulesForRequest(Request $request, $ignorePlatformReqs)
{
foreach ($request->getFixedPackages() as $package) {
@ -278,6 +292,9 @@ class RuleSetGenerator
}
}
/**
* @return void
*/
protected function addRulesForRootAliases($ignorePlatformReqs)
{
foreach ($this->pool->getPackages() as $package) {
@ -295,6 +312,7 @@ class RuleSetGenerator
/**
* @param bool|array $ignorePlatformReqs
* @return RuleSet
*/
public function getRulesFor(Request $request, $ignorePlatformReqs = false)
{

@ -42,18 +42,27 @@ class RuleSetIterator implements \Iterator
$this->rewind();
}
/**
* @return Rule
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->rules[$this->currentType][$this->currentOffset];
}
/**
* @return RuleSet::TYPE_*|-1
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->currentType;
}
/**
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
{
@ -79,6 +88,9 @@ class RuleSetIterator implements \Iterator
}
}
/**
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
{
@ -99,6 +111,9 @@ class RuleSetIterator implements \Iterator
} while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
}
/**
* @return bool
*/
#[\ReturnTypeWillChange]
public function valid()
{

@ -76,6 +76,9 @@ class Solver
return \count($this->rules);
}
/**
* @return Pool
*/
public function getPool()
{
return $this->pool;
@ -83,6 +86,9 @@ class Solver
// aka solver_makeruledecisions
/**
* @return void
*/
private function makeAssertionRuleDecisions()
{
$decisionStart = \count($this->decisions) - 1;
@ -153,6 +159,9 @@ class Solver
}
}
/**
* @return void
*/
protected function setupFixedMap(Request $request)
{
$this->fixedMap = array();
@ -164,6 +173,8 @@ class Solver
/**
* @param Request $request
* @param bool|array $ignorePlatformReqs
*
* @return void
*/
protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
{
@ -251,6 +262,8 @@ class Solver
* Reverts a decision at the given level.
*
* @param int $level
*
* @return void
*/
private function revert($level)
{
@ -513,6 +526,9 @@ class Solver
return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
}
/**
* @return void
*/
private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen)
{
$why = spl_object_hash($conflictRule);
@ -599,6 +615,8 @@ class Solver
* we have enabled or disabled some of our rules. We now re-enable all
* of our learnt rules except the ones that were learnt from rules that
* are now disabled.
*
* @return void
*/
private function enableDisableLearnedRules()
{
@ -622,6 +640,9 @@ class Solver
}
}
/**
* @return void
*/
private function runSat()
{
$this->propagateIndex = 0;

@ -40,6 +40,9 @@ class SolverProblemsException extends \RuntimeException
parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED);
}
/**
* @return string
*/
public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
{
$installedMap = $request->getPresentMap(true);
@ -54,7 +57,7 @@ class SolverProblemsException extends \RuntimeException
$hasExtensionProblems = true;
}
$isCausedByLock |= $problem->isCausedByLock($repositorySet, $request, $pool);
$isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool);
}
$i = 1;
@ -93,11 +96,17 @@ class SolverProblemsException extends \RuntimeException
return $text;
}
/**
* @return Problem[]
*/
public function getProblems()
{
return $this->problems;
}
/**
* @return string
*/
private function createExtensionHint()
{
$paths = IniHelper::getAll();
@ -113,6 +122,9 @@ class SolverProblemsException extends \RuntimeException
return $text;
}
/**
* @return bool
*/
private function hasExtensionProblems(array $reasonSets)
{
foreach ($reasonSets as $reasonSet) {

@ -32,6 +32,9 @@ abstract class ArchiveDownloader extends FileDownloader
*/
public $cleanupExecuted = array();
/**
* @return PromiseInterface|null
*/
public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
{
unset($this->cleanupExecuted[$package->getName()]);
@ -39,6 +42,9 @@ abstract class ArchiveDownloader extends FileDownloader
return parent::prepare($type, $package, $path, $prevPackage);
}
/**
* @return PromiseInterface|null
*/
public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
{
$this->cleanupExecuted[$package->getName()] = true;
@ -50,6 +56,7 @@ abstract class ArchiveDownloader extends FileDownloader
* {@inheritDoc}
* @throws \RuntimeException
* @throws \UnexpectedValueException
* @return PromiseInterface
*/
public function install(PackageInterface $package, $path, $output = true)
{

@ -163,6 +163,9 @@ class DownloadManager
return $downloader;
}
/**
* @return string
*/
public function getDownloaderType(DownloaderInterface $downloader)
{
return array_search($downloader, $this->downloaders);

@ -218,6 +218,9 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
return trim($output) ?: null;
}
/**
* @return null|string
*/
public function getUnpushedChanges(PackageInterface $package, $path)
{
GitUtil::cleanEnv();
@ -590,6 +593,10 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
return is_dir($path.'/.git');
}
/**
* @param string $reference
* @return string
*/
protected function getShortHash($reference)
{
if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {

@ -52,6 +52,9 @@ class PerforceDownloader extends VcsDownloader
return \React\Promise\resolve();
}
/**
* @return string|null
*/
private function getLabelFromSourceReference($ref)
{
$pos = strpos($ref, '@');
@ -78,6 +81,9 @@ class PerforceDownloader extends VcsDownloader
$this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
}
/**
* @return array<string, mixed>
*/
private function getRepoConfig(VcsRepository $repository)
{
return $repository->getRepoConfig();

@ -77,6 +77,7 @@ class EventDispatcher
* Set whether script handlers are active or not
*
* @param bool $runScripts
* @return $this
*/
public function setRunScripts($runScripts = true)
{
@ -336,6 +337,9 @@ class EventDispatcher
return $returnMax;
}
/**
* @return int
*/
protected function executeTty($exec)
{
if ($this->io->isInteractive()) {
@ -345,6 +349,9 @@ class EventDispatcher
return $this->process->execute($exec);
}
/**
* @return string
*/
protected function getPhpExecCommand()
{
$finder = new PhpExecutableFinder();
@ -536,7 +543,7 @@ class EventDispatcher
/**
* Pops the active event from the stack
*
* @return mixed
* @return string|null
*/
protected function popEvent()
{

@ -241,11 +241,17 @@ class Factory
return $config;
}
/**
* @return string
*/
public static function getComposerFile()
{
return trim(getenv('COMPOSER')) ?: './composer.json';
}
/**
* @return string
*/
public static function getLockFile($composerFile)
{
return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
@ -253,6 +259,9 @@ class Factory
: $composerFile . '.lock';
}
/**
* @return array{highlight: OutputFormatterStyle, warning: OutputFormatterStyle}
*/
public static function createAdditionalStyles()
{
return array(
@ -596,6 +605,9 @@ class Factory
}
}
/**
* @return Package\Loader\RootPackageLoader
*/
protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
{
return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);

Loading…
Cancel
Save