Type annotations
parent
9fde6ec88b
commit
e137046558
|
@ -280,6 +280,9 @@ class Compiler
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getStub()
|
||||
{
|
||||
$stub = <<<'EOF'
|
||||
|
|
|
@ -67,6 +67,9 @@ class Composer
|
|||
*/
|
||||
const RUNTIME_API_VERSION = '2.1.0';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getVersion()
|
||||
{
|
||||
// no replacement done, this must be a source checkout
|
||||
|
|
|
@ -119,6 +119,9 @@ class Config
|
|||
$this->configSource = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ConfigSourceInterface
|
||||
*/
|
||||
public function getConfigSource()
|
||||
{
|
||||
return $this->configSource;
|
||||
|
@ -129,6 +132,9 @@ class Config
|
|||
$this->authConfigSource = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ConfigSourceInterface
|
||||
*/
|
||||
public function getAuthConfigSource()
|
||||
{
|
||||
return $this->authConfigSource;
|
||||
|
@ -373,6 +379,9 @@ class Config
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
public function all($flags = 0)
|
||||
{
|
||||
$all = array(
|
||||
|
@ -385,6 +394,9 @@ class Config
|
|||
return $all;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed[]>
|
||||
*/
|
||||
public function raw()
|
||||
{
|
||||
return array(
|
||||
|
|
|
@ -468,6 +468,9 @@ class Application extends BaseApplication
|
|||
return $this->io;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHelp()
|
||||
{
|
||||
return self::$logo . parent::getHelp();
|
||||
|
@ -548,6 +551,9 @@ class Application extends BaseApplication
|
|||
return $definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Command\BaseCommand[]
|
||||
*/
|
||||
private function getPluginCommands()
|
||||
{
|
||||
$commands = array();
|
||||
|
|
|
@ -58,6 +58,9 @@ class HtmlOutputFormatter extends OutputFormatter
|
|||
parent::__construct(true, $styles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function format($message)
|
||||
{
|
||||
$formatted = parent::format($message);
|
||||
|
@ -67,6 +70,9 @@ class HtmlOutputFormatter extends OutputFormatter
|
|||
return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function formatHtml($matches)
|
||||
{
|
||||
$out = '<span style="';
|
||||
|
|
|
@ -45,6 +45,9 @@ class Decisions implements \Iterator, \Countable
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function satisfy($literal)
|
||||
{
|
||||
$packageId = abs($literal);
|
||||
|
@ -55,6 +58,9 @@ class Decisions implements \Iterator, \Countable
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function conflict($literal)
|
||||
{
|
||||
$packageId = abs($literal);
|
||||
|
@ -65,16 +71,25 @@ class Decisions implements \Iterator, \Countable
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function decided($literalOrPackageId)
|
||||
{
|
||||
return !empty($this->decisionMap[abs($literalOrPackageId)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function undecided($literalOrPackageId)
|
||||
{
|
||||
return empty($this->decisionMap[abs($literalOrPackageId)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function decidedInstall($literalOrPackageId)
|
||||
{
|
||||
$packageId = abs($literalOrPackageId);
|
||||
|
@ -82,6 +97,9 @@ class Decisions implements \Iterator, \Countable
|
|||
return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function decisionLevel($literalOrPackageId)
|
||||
{
|
||||
$packageId = abs($literalOrPackageId);
|
||||
|
@ -92,6 +110,9 @@ class Decisions implements \Iterator, \Countable
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function decisionRule($literalOrPackageId)
|
||||
{
|
||||
$packageId = abs($literalOrPackageId);
|
||||
|
@ -105,26 +126,41 @@ class Decisions implements \Iterator, \Countable
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: int, 1: mixed} a literal and decision reason
|
||||
*/
|
||||
public function atOffset($queueOffset)
|
||||
{
|
||||
return $this->decisionQueue[$queueOffset];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function validOffset($queueOffset)
|
||||
{
|
||||
return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function lastReason()
|
||||
{
|
||||
return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function lastLiteral()
|
||||
{
|
||||
return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
while ($decision = array_pop($this->decisionQueue)) {
|
||||
|
@ -132,6 +168,9 @@ class Decisions implements \Iterator, \Countable
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function resetToOffset($offset)
|
||||
{
|
||||
while (\count($this->decisionQueue) > $offset + 1) {
|
||||
|
@ -140,53 +179,80 @@ class Decisions implements \Iterator, \Countable
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function revertLast()
|
||||
{
|
||||
$this->decisionMap[abs($this->lastLiteral())] = 0;
|
||||
array_pop($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return \count($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
end($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: int, 1: mixed}|false
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return current($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return key($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
prev($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function valid()
|
||||
{
|
||||
return false !== current($this->decisionQueue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return \count($this->decisionQueue) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function addDecision($literal, $level)
|
||||
{
|
||||
$packageId = abs($literal);
|
||||
|
@ -207,6 +273,9 @@ class Decisions implements \Iterator, \Countable
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function toString(Pool $pool = null)
|
||||
{
|
||||
$decisionMap = $this->decisionMap;
|
||||
|
@ -220,6 +289,9 @@ class Decisions implements \Iterator, \Countable
|
|||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString();
|
||||
|
|
|
@ -34,6 +34,9 @@ class DefaultPolicy implements PolicyInterface
|
|||
$this->preferLowest = $preferLowest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
|
||||
{
|
||||
if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
|
||||
|
@ -46,6 +49,11 @@ class DefaultPolicy implements PolicyInterface
|
|||
return $constraint->matchSpecific($version, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $literals
|
||||
* @param bool $requiredPackage
|
||||
* @return int[]
|
||||
*/
|
||||
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
|
||||
{
|
||||
$packages = $this->groupLiteralsByName($pool, $literals);
|
||||
|
@ -72,6 +80,10 @@ class DefaultPolicy implements PolicyInterface
|
|||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $literals
|
||||
* @return array<string, int[]>
|
||||
*/
|
||||
protected function groupLiteralsByName(Pool $pool, $literals)
|
||||
{
|
||||
$packages = array();
|
||||
|
@ -89,6 +101,7 @@ class DefaultPolicy implements PolicyInterface
|
|||
|
||||
/**
|
||||
* @protected
|
||||
* @return int
|
||||
*/
|
||||
public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, $requiredPackage = null, $ignoreReplace = false)
|
||||
{
|
||||
|
@ -159,6 +172,10 @@ class DefaultPolicy implements PolicyInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $literals
|
||||
* @return int[]
|
||||
*/
|
||||
protected function pruneToBestVersion(Pool $pool, $literals)
|
||||
{
|
||||
$operator = $this->preferLowest ? '<' : '>';
|
||||
|
@ -186,6 +203,9 @@ class DefaultPolicy implements PolicyInterface
|
|||
* Assumes that locally aliased (in root package requires) packages take priority over branch-alias ones
|
||||
*
|
||||
* If no package is a local alias, nothing happens
|
||||
*
|
||||
* @param int[] $literals
|
||||
* @return int[]
|
||||
*/
|
||||
protected function pruneRemoteAliases(Pool $pool, array $literals)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,9 @@ class GenericRule extends Rule
|
|||
$this->literals = $literals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getLiterals()
|
||||
{
|
||||
return $this->literals;
|
||||
|
@ -62,6 +65,9 @@ class GenericRule extends Rule
|
|||
return $this->literals === $rule->getLiterals();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAssertion()
|
||||
{
|
||||
return 1 === \count($this->literals);
|
||||
|
|
|
@ -95,6 +95,9 @@ class LockTransaction extends Transaction
|
|||
}
|
||||
|
||||
// TODO additionalFixedRepository needs to be looked at here as well?
|
||||
/**
|
||||
* @return BasePackage[]
|
||||
*/
|
||||
public function getNewLockPackages($devMode, $updateMirrors = false)
|
||||
{
|
||||
$packages = array();
|
||||
|
|
|
@ -42,6 +42,9 @@ class MultiConflictRule extends Rule
|
|||
$this->literals = $literals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getLiterals()
|
||||
{
|
||||
return $this->literals;
|
||||
|
@ -71,6 +74,9 @@ class MultiConflictRule extends Rule
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAssertion()
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -51,6 +51,9 @@ class InstallOperation extends SolverOperation implements OperationInterface
|
|||
return self::format($this->package, $lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function format(PackageInterface $package, $lock = false)
|
||||
{
|
||||
return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
|
||||
|
|
|
@ -51,6 +51,9 @@ class UninstallOperation extends SolverOperation implements OperationInterface
|
|||
return self::format($this->package, $lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function format(PackageInterface $package, $lock = false)
|
||||
{
|
||||
return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
|
||||
|
|
|
@ -72,6 +72,9 @@ class UpdateOperation extends SolverOperation implements OperationInterface
|
|||
return self::format($this->initialPackage, $this->targetPackage, $lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
|
||||
{
|
||||
$fromVersion = $initialPackage->getFullPrettyVersion();
|
||||
|
|
|
@ -80,6 +80,7 @@ class Pool implements \Countable
|
|||
|
||||
/**
|
||||
* Returns how many packages have been loaded into the pool
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
|
|
Loading…
Reference in New Issue