Type annotations

main
Jordi Boggiano 3 years ago
parent 6d5f6eb090
commit 9599eb613b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -54,6 +54,9 @@ class PhpFileCleaner
$this->maxMatches = $maxMatches;
}
/**
* @return string
*/
public function clean()
{
$clean = '';
@ -212,11 +215,17 @@ class PhpFileCleaner
}
}
/**
* @return bool
*/
private function peek($char)
{
return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
}
/**
* @return bool
*/
private function match($regex, array &$match = null)
{
if (\preg_match($regex, $this->contents, $match, 0, $this->index)) {

@ -75,11 +75,17 @@ class Cache
return $this->readOnly;
}
/**
* @return bool
*/
public static function isUsable($path)
{
return !preg_match('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
}
/**
* @return bool
*/
public function isEnabled()
{
if ($this->enabled === null) {
@ -97,11 +103,17 @@ class Cache
return $this->enabled;
}
/**
* @return string
*/
public function getRoot()
{
return $this->root;
}
/**
* @return string|false
*/
public function read($file)
{
if ($this->isEnabled()) {
@ -116,6 +128,9 @@ class Cache
return false;
}
/**
* @return bool
*/
public function write($file, $contents)
{
if ($this->isEnabled() && !$this->readOnly) {
@ -154,6 +169,7 @@ class Cache
/**
* Copy a file into the cache
* @return bool
*/
public function copyFrom($file, $source)
{
@ -175,6 +191,7 @@ class Cache
/**
* Copy a file out of the cache
* @return bool
*/
public function copyTo($file, $target)
{
@ -198,6 +215,9 @@ class Cache
return false;
}
/**
* @return bool
*/
public function gcIsNecessary()
{
if (self::$cacheCollected) {
@ -216,6 +236,9 @@ class Cache
return !mt_rand(0, 50);
}
/**
* @return bool
*/
public function remove($file)
{
if ($this->isEnabled()) {
@ -228,6 +251,9 @@ class Cache
return false;
}
/**
* @return bool
*/
public function clear()
{
if ($this->isEnabled()) {
@ -239,6 +265,9 @@ class Cache
return false;
}
/**
* @return bool
*/
public function gc($ttl, $maxSize)
{
if ($this->isEnabled()) {
@ -269,6 +298,9 @@ class Cache
return false;
}
/**
* @return string|false
*/
public function sha1($file)
{
if ($this->isEnabled()) {
@ -281,6 +313,9 @@ class Cache
return false;
}
/**
* @return string|false
*/
public function sha256($file)
{
if ($this->isEnabled()) {
@ -293,6 +328,9 @@ class Cache
return false;
}
/**
* @return Finder
*/
protected function getFinder()
{
return Finder::create()->in($this->root)->files();

@ -16,6 +16,7 @@ use Composer\Factory;
use Composer\IO\IOInterface;
use Composer\Config;
use Composer\Composer;
use Composer\Package\BasePackage;
use Composer\Package\CompletePackageInterface;
use Composer\Repository\CompositeRepository;
use Composer\Repository\RepositoryFactory;
@ -108,6 +109,9 @@ EOT
return $returnCode;
}
/**
* @return int
*/
protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
{
if ($composer) {
@ -142,7 +146,7 @@ EOT
}
/**
* @return CompletePackageInterface|false
* @return BasePackage&CompletePackageInterface|false
*/
protected function selectPackage(IOInterface $io, $packageName, $version = null)
{

@ -58,9 +58,6 @@ class ConfigCommand extends BaseCommand
*/
protected $authConfigSource;
/**
* {@inheritDoc}
*/
protected function configure()
{
$this
@ -148,9 +145,6 @@ EOT
;
}
/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);
@ -204,9 +198,6 @@ EOT
}
}
/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// Open file in editor

@ -159,6 +159,9 @@ EOT
);
}
/**
* @return int
*/
public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $noScripts = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, $secureHttp = true, $addRepository = false)
{
$oldCwd = getcwd();
@ -304,6 +307,9 @@ EOT
return 0;
}
/**
* @return bool
*/
protected function installRootPackage(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, array $repositories = null, $disablePlugins = false, $noScripts = false, $noProgress = false, $ignorePlatformReqs = false, $secureHttp = true)
{
if (!$secureHttp) {

@ -65,9 +65,6 @@ EOT
;
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$composer = $this->getComposer(false);
@ -195,6 +192,9 @@ EOT
return $this->exitCode;
}
/**
* @return string|true
*/
private function checkComposerSchema()
{
$validator = new ConfigValidator($this->getIO());
@ -219,6 +219,9 @@ EOT
return true;
}
/**
* @return string|true
*/
private function checkGit()
{
if (!function_exists('proc_open')) {
@ -233,6 +236,9 @@ EOT
return true;
}
/**
* @return string|string[]|true
*/
private function checkHttp($proto, Config $config)
{
$result = $this->checkConnectivity();
@ -268,6 +274,9 @@ EOT
return true;
}
/**
* @return string|true|\Exception
*/
private function checkHttpProxy()
{
$result = $this->checkConnectivity();
@ -293,6 +302,9 @@ EOT
return true;
}
/**
* @return string|true|\Exception
*/
private function checkGithubOauth($domain, $token)
{
$result = $this->checkConnectivity();
@ -322,7 +334,7 @@ EOT
* @param string $domain
* @param string $token
* @throws TransportException
* @return array|string
* @return mixed|string
*/
private function getGithubRateLimit($domain, $token = null)
{
@ -341,6 +353,9 @@ EOT
return $data['resources']['core'];
}
/**
* @return string|true
*/
private function checkDiskSpace($config)
{
$minSpaceFree = 1024 * 1024;
@ -353,6 +368,9 @@ EOT
return true;
}
/**
* @return string[]|true
*/
private function checkPubKeys($config)
{
$home = $config->get('home');
@ -382,6 +400,9 @@ EOT
return $errors ?: true;
}
/**
* @return string|\Exception|true
*/
private function checkVersion($config)
{
$result = $this->checkConnectivity();
@ -403,6 +424,9 @@ EOT
return true;
}
/**
* @return string
*/
private function getCurlVersion()
{
if (extension_loaded('curl')) {
@ -469,6 +493,9 @@ EOT
}
}
/**
* @return string|true
*/
private function checkPlatform()
{
$output = '';
@ -699,7 +726,7 @@ EOT
/**
* Check if allow_url_fopen is ON
*
* @return true|string
* @return string|true
*/
private function checkConnectivity()
{

@ -97,6 +97,9 @@ EOT
return $return;
}
/**
* @return bool
*/
private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
{
$support = $package->getSupport();
@ -122,6 +125,7 @@ EOT
* opens a url in your system default browser
*
* @param string $url
* @return void
*/
private function openBrowser($url)
{
@ -129,7 +133,8 @@ EOT
$process = new ProcessExecutor($this->getIO());
if (Platform::isWindows()) {
return $process->execute('start "web" explorer ' . $url, $output);
$process->execute('start "web" explorer ' . $url, $output);
return;
}
$linux = $process->execute('which xdg-open', $output);

@ -461,7 +461,7 @@ EOT
/**
* @private
* @param string $author
* @return array
* @return array{name: string, email: string}
*/
public function parseAuthorString($author)
{
@ -485,6 +485,9 @@ EOT
return $this->getRepos()->search($name);
}
/**
* @return CompositeRepository
*/
protected function getRepos()
{
if (!$this->repos) {
@ -663,6 +666,9 @@ EOT
return $requires;
}
/**
* @return array<int, array{name: string, email: string}>
*/
protected function formatAuthors($author)
{
return array($this->parseAuthorString($author));
@ -775,6 +781,9 @@ EOT
file_put_contents($ignoreFile, $contents . $vendor. "\n");
}
/**
* @return bool
*/
protected function isValidEmail($email)
{
// assume it's valid if we can't validate it
@ -790,6 +799,9 @@ EOT
return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
}
/**
* @return RepositorySet
*/
private function getRepositorySet(InputInterface $input, $minimumStability = null)
{
$key = $minimumStability ?: 'default';
@ -802,6 +814,9 @@ EOT
return $this->repositorySets[$key];
}
/**
* @return string
*/
private function getMinimumStability(InputInterface $input)
{
if ($input->hasOption('stability')) {
@ -936,6 +951,9 @@ EOT
);
}
/**
* @return string
*/
private function getPlatformExceptionDetails(PackageInterface $candidate, PlatformRepository $platformRepo = null)
{
$details = array();
@ -993,6 +1011,9 @@ EOT
return array_keys(array_slice($similarPackages, 0, 5));
}
/**
* @return void
*/
private function updateDependencies($output)
{
try {
@ -1004,6 +1025,9 @@ EOT
}
}
/**
* @return void
*/
private function runDumpAutoloadCommand($output)
{
try {
@ -1015,6 +1039,9 @@ EOT
}
}
/**
* @return bool
*/
private function hasDependencies($options)
{
$requires = (array) $options['require'];

@ -417,6 +417,9 @@ EOT
return $status;
}
/**
* @return bool
*/
private function updateFileCleanly($json, array $new, $requireKey, $removeKey, $sortPackages)
{
$contents = file_get_contents($json->getPath());

@ -109,6 +109,9 @@ EOT
return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
}
/**
* @return int
*/
protected function listScripts(OutputInterface $output)
{
$scripts = $this->getComposer()->getPackage()->getScripts();

@ -369,6 +369,9 @@ TAGSPUBKEY
$io->write('Public keys stored in '.$config->get('home'));
}
/**
* @return int
*/
protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
{
$rollbackVersion = $this->getLastBackupVersion($rollbackDir);
@ -464,6 +467,9 @@ TAGSPUBKEY
}
}
/**
* @return string|false
*/
protected function getLastBackupVersion($rollbackDir)
{
$finder = $this->getOldInstallationFinder($rollbackDir);
@ -477,6 +483,9 @@ TAGSPUBKEY
return false;
}
/**
* @return Finder
*/
protected function getOldInstallationFinder($rollbackDir)
{
return Finder::create()

@ -304,6 +304,9 @@ EOT
throw new \RuntimeException('Installation aborted.');
}
/**
* @return Link
*/
private function appendConstraintToLink(Link $link, $constraint)
{
$parser = new VersionParser;

@ -1737,6 +1737,9 @@ EOF;
}
}
/**
* @return array<string, mixed[]>
*/
public function platformCheckProvider()
{
$versionParser = new VersionParser();

Loading…
Cancel
Save