1
0
Fork 0

Removed unused variables, properties and parameters of private functions

pull/9204/head
Simon Berger 2020-09-11 22:51:47 +02:00
parent 002fd39bc6
commit a6475a7118
21 changed files with 23 additions and 56 deletions

View File

@ -609,7 +609,7 @@ EOF;
$extensionProviders = array(); $extensionProviders = array();
foreach ($packageMap as $item) { foreach ($packageMap as $item) {
list($package, $installPath) = $item; $package = $item[0];
foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) { foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) { if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
$extensionProviders[$match[1]][] = $link->getConstraint() ?: new MatchAllConstraint(); $extensionProviders[$match[1]][] = $link->getConstraint() ?: new MatchAllConstraint();
@ -618,7 +618,7 @@ EOF;
} }
foreach ($packageMap as $item) { foreach ($packageMap as $item) {
list($package, $installPath) = $item; $package = $item[0];
foreach ($package->getRequires() as $link) { foreach ($package->getRequires() as $link) {
if (in_array($link->getTarget(), $ignorePlatformReqs, true)) { if (in_array($link->getTarget(), $ignorePlatformReqs, true)) {
continue; continue;

View File

@ -153,7 +153,6 @@ EOT
protected function printTable(OutputInterface $output, $results) protected function printTable(OutputInterface $output, $results)
{ {
$table = array();
$rows = array(); $rows = array();
foreach ($results as $result) { foreach ($results as $result) {
/** /**

View File

@ -434,7 +434,7 @@ EOT
)); ));
} else { } else {
// check that the specified version/constraint exists before we proceed // check that the specified version/constraint exists before we proceed
list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed); list($name) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed);
// replace package name from packagist.org // replace package name from packagist.org
$requirement['name'] = $name; $requirement['name'] = $name;
@ -558,7 +558,7 @@ EOT
); );
if (false === $constraint) { if (false === $constraint) {
list($name, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability); list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
$io->writeError(sprintf( $io->writeError(sprintf(
'Using version <info>%s</info> for <info>%s</info>', 'Using version <info>%s</info> for <info>%s</info>',

View File

@ -1115,7 +1115,7 @@ EOT
array $packagesInTree array $packagesInTree
) { ) {
$children = array(); $children = array();
list($package, $versions) = $this->getPackage( list($package) = $this->getPackage(
$installedRepo, $installedRepo,
$remoteRepos, $remoteRepos,
$name, $name,

View File

@ -73,7 +73,7 @@ EOT
// Dispatch pre-status-command // Dispatch pre-status-command
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true); $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
$exitCode = $this->doExecute($input, $output); $exitCode = $this->doExecute($input);
// Dispatch post-status-command // Dispatch post-status-command
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true); $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
@ -83,10 +83,9 @@ EOT
/** /**
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output
* @return int * @return int
*/ */
private function doExecute(InputInterface $input, OutputInterface $output) private function doExecute(InputInterface $input)
{ {
// init repos // init repos
$composer = $this->getComposer(); $composer = $this->getComposer();

View File

@ -322,7 +322,6 @@ abstract class Rule
*/ */
protected function formatPackagesUnique($pool, array $packages, $isVerbose) protected function formatPackagesUnique($pool, array $packages, $isVerbose)
{ {
$prepared = array();
foreach ($packages as $index => $package) { foreach ($packages as $index => $package) {
if (!\is_object($package)) { if (!\is_object($package)) {
$packages[$index] = $pool->literalToPackage($package); $packages[$index] = $pool->literalToPackage($package);

View File

@ -645,9 +645,6 @@ class Solver
* with step 1 * with step 1
*/ */
$decisionQueue = array();
$decisionSupplementQueue = array();
$level = 1; $level = 1;
$systemLevel = $level + 1; $systemLevel = $level + 1;

View File

@ -62,7 +62,6 @@ class FossilDownloader extends VcsDownloader
// Ensure we are allowed to use this URL by config // Ensure we are allowed to use this URL by config
$this->config->prohibitUrlByConfig($url, $this->io); $this->config->prohibitUrlByConfig($url, $this->io);
$url = ProcessExecutor::escape($url);
$ref = ProcessExecutor::escape($target->getSourceReference()); $ref = ProcessExecutor::escape($target->getSourceReference());
$this->io->writeError(" Updating to ".$target->getSourceReference()); $this->io->writeError(" Updating to ".$target->getSourceReference());

View File

@ -142,7 +142,6 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
$cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/'; $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
$ref = $target->getSourceReference(); $ref = $target->getSourceReference();
$flag = Platform::isWindows() ? '/D ' : '';
if (!empty($this->cachedPackages[$target->getId()][$ref])) { if (!empty($this->cachedPackages[$target->getId()][$ref])) {
$msg = "Checking out ".$this->getShortHash($ref).' from cache'; $msg = "Checking out ".$this->getShortHash($ref).' from cache';

View File

@ -27,8 +27,6 @@ use React\Promise\PromiseInterface;
*/ */
class PluginInstaller extends LibraryInstaller class PluginInstaller extends LibraryInstaller
{ {
private $installationManager;
/** /**
* Initializes Plugin installer. * Initializes Plugin installer.
* *
@ -38,7 +36,6 @@ class PluginInstaller extends LibraryInstaller
public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null) public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
{ {
parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller); parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
$this->installationManager = $composer->getInstallationManager();
} }
/** /**

View File

@ -47,11 +47,6 @@ class RootPackageLoader extends ArrayLoader
*/ */
private $versionGuesser; private $versionGuesser;
/**
* @var IOInterface
*/
private $io;
public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null) public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
{ {
parent::__construct($parser); parent::__construct($parser);
@ -59,7 +54,6 @@ class RootPackageLoader extends ArrayLoader
$this->manager = $manager; $this->manager = $manager;
$this->config = $config; $this->config = $config;
$this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser); $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
$this->io = $io;
} }
/** /**

View File

@ -79,7 +79,7 @@ class VersionGuesser
return $this->postprocess($versionData); return $this->postprocess($versionData);
} }
$versionData = $this->guessFossilVersion($packageConfig, $path); $versionData = $this->guessFossilVersion($path);
if (null !== $versionData && null !== $versionData['version']) { if (null !== $versionData && null !== $versionData['version']) {
return $this->postprocess($versionData); return $this->postprocess($versionData);
} }
@ -288,7 +288,7 @@ class VersionGuesser
return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match); return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
} }
private function guessFossilVersion(array $packageConfig, $path) private function guessFossilVersion($path)
{ {
$version = null; $version = null;
$prettyVersion = null; $prettyVersion = null;

View File

@ -165,7 +165,7 @@ class FossilDriver extends VcsDriver
public function getChangeDate($identifier) public function getChangeDate($identifier)
{ {
$this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir); $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
list($ckout, $date, $message) = explode(' ', trim($output), 3); list(,$date) = explode(' ', trim($output), 2);
return new \DateTime($date, new \DateTimeZone('UTC')); return new \DateTime($date, new \DateTimeZone('UTC'));
} }
@ -196,7 +196,6 @@ class FossilDriver extends VcsDriver
{ {
if (null === $this->branches) { if (null === $this->branches) {
$branches = array(); $branches = array();
$bookmarks = array();
$this->process->execute('fossil branch list', $output, $this->checkoutDir); $this->process->execute('fossil branch list', $output, $this->checkoutDir);
foreach ($this->process->splitLines($output) as $branch) { foreach ($this->process->splitLines($output) as $branch) {

View File

@ -140,7 +140,6 @@ class PerforceDriver extends VcsDriver
public function hasComposerFile($identifier) public function hasComposerFile($identifier)
{ {
$composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier); $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
$composerInfoIdentifier = $identifier;
return !empty($composerInfo); return !empty($composerInfo);
} }

View File

@ -79,7 +79,6 @@ class AuthHelper
public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array()) public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
{ {
$storeAuth = false; $storeAuth = false;
$retry = false;
if (in_array($origin, $this->config->get('github-domains'), true)) { if (in_array($origin, $this->config->get('github-domains'), true)) {
$gitHubUtil = new GitHub($this->io, $this->config, null); $gitHubUtil = new GitHub($this->io, $this->config, null);
@ -181,9 +180,7 @@ class AuthHelper
$storeAuth = $this->config->get('store-auths'); $storeAuth = $this->config->get('store-auths');
} }
$retry = true; return array('retry' => true, 'storeAuth' => $storeAuth);
return array('retry' => $retry, 'storeAuth' => $storeAuth);
} }
/** /**

View File

@ -93,7 +93,7 @@ class Bitbucket
* @param string $originUrl * @param string $originUrl
* @return bool * @return bool
*/ */
private function requestAccessToken($originUrl) private function requestAccessToken()
{ {
try { try {
$response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array( $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
@ -166,7 +166,7 @@ class Bitbucket
$this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret); $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
if (!$this->requestAccessToken($originUrl)) { if (!$this->requestAccessToken()) {
return false; return false;
} }
@ -196,7 +196,7 @@ class Bitbucket
} }
$this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret); $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
if (!$this->requestAccessToken($originUrl)) { if (!$this->requestAccessToken()) {
return ''; return '';
} }

View File

@ -286,12 +286,12 @@ class Git
public function fetchRefOrSyncMirror($url, $dir, $ref) public function fetchRefOrSyncMirror($url, $dir, $ref)
{ {
if ($this->checkRefIsInMirror($url, $dir, $ref)) { if ($this->checkRefIsInMirror($dir, $ref)) {
return true; return true;
} }
if ($this->syncMirror($url, $dir)) { if ($this->syncMirror($url, $dir)) {
return $this->checkRefIsInMirror($url, $dir, $ref); return $this->checkRefIsInMirror($dir, $ref);
} }
return false; return false;
@ -307,7 +307,7 @@ class Git
return ''; return '';
} }
private function checkRefIsInMirror($url, $dir, $ref) private function checkRefIsInMirror($dir, $ref)
{ {
if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') { if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
$escapedRef = ProcessExecutor::escape($ref.'^{commit}'); $escapedRef = ProcessExecutor::escape($ref.'^{commit}');

View File

@ -214,7 +214,6 @@ class CurlDownloader
$this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle)); $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
// TODO progress // TODO progress
//$params['notification'](STREAM_NOTIFY_RESOLVE, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0, false);
return (int) $curlHandle; return (int) $curlHandle;
} }
@ -271,7 +270,6 @@ class CurlDownloader
$response = null; $response = null;
try { try {
// TODO progress // TODO progress
//$this->onProgress($curlHandle, $job['callback'], $progress, $job['progress']);
if (CURLE_OK !== $errno || $error) { if (CURLE_OK !== $errno || $error) {
throw new TransportException($error); throw new TransportException($error);
} }
@ -363,7 +361,6 @@ class CurlDownloader
$progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo); $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
if ($this->jobs[$i]['progress'] !== $progress) { if ($this->jobs[$i]['progress'] !== $progress) {
$previousProgress = $this->jobs[$i]['progress'];
$this->jobs[$i]['progress'] = $progress; $this->jobs[$i]['progress'] = $progress;
if (isset($this->jobs[$i]['options']['max_file_size'])) { if (isset($this->jobs[$i]['options']['max_file_size'])) {
@ -378,8 +375,7 @@ class CurlDownloader
} }
} }
// TODO // TODO progress
//$this->onProgress($curlHandle, $this->jobs[$i]['callback'], $progress, $previousProgress);
} }
} }
} }

View File

@ -39,8 +39,6 @@ class HttpDownloader
private $options = array(); private $options = array();
private $runningJobs = 0; private $runningJobs = 0;
private $maxJobs = 10; private $maxJobs = 10;
private $lastProgress;
private $disableTls = false;
private $curl; private $curl;
private $rfs; private $rfs;
private $idGen = 0; private $idGen = 0;
@ -63,8 +61,6 @@ class HttpDownloader
// The cafile option can be set via config.json // The cafile option can be set via config.json
if ($disableTls === false) { if ($disableTls === false) {
$this->options = StreamContextFactory::getTlsDefaults($options, $io); $this->options = StreamContextFactory::getTlsDefaults($options, $io);
} else {
$this->disableTls = true;
} }
// handle the other externally set options normally. // handle the other externally set options normally.
@ -81,7 +77,7 @@ class HttpDownloader
public function get($url, $options = array()) public function get($url, $options = array())
{ {
list($job, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true); list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
$this->wait($job['id']); $this->wait($job['id']);
return $this->getResponse($job['id']); return $this->getResponse($job['id']);
@ -89,14 +85,14 @@ class HttpDownloader
public function add($url, $options = array()) public function add($url, $options = array())
{ {
list($job, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false)); list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false));
return $promise; return $promise;
} }
public function copy($url, $to, $options = array()) public function copy($url, $to, $options = array())
{ {
list($job, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true); list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
$this->wait($job['id']); $this->wait($job['id']);
return $this->getResponse($job['id']); return $this->getResponse($job['id']);
@ -104,7 +100,7 @@ class HttpDownloader
public function addCopy($url, $to, $options = array()) public function addCopy($url, $to, $options = array())
{ {
list($job, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to)); list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
return $promise; return $promise;
} }
@ -167,7 +163,7 @@ class HttpDownloader
$job['status'] = HttpDownloader::STATUS_STARTED; $job['status'] = HttpDownloader::STATUS_STARTED;
if ($job['request']['copyTo']) { if ($job['request']['copyTo']) {
$result = $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false /* TODO progress */, $options); $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false /* TODO progress */, $options);
$headers = $rfs->getLastHeaders(); $headers = $rfs->getLastHeaders();
$response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~'); $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
@ -184,7 +180,6 @@ class HttpDownloader
} }
$downloader = $this; $downloader = $this;
$io = $this->io;
$curl = $this->curl; $curl = $this->curl;
$canceler = function () use (&$job, $curl) { $canceler = function () use (&$job, $curl) {

View File

@ -389,7 +389,6 @@ class Perforce
} else { } else {
$command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false); $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
$exitCode = $this->executeCommand($command); $exitCode = $this->executeCommand($command);
$result = trim($this->commandResult);
if ($exitCode) { if ($exitCode) {
throw new \Exception("Error logging in:" . $this->process->getErrorOutput()); throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
} }

View File

@ -155,7 +155,6 @@ class ProcessExecutor
}; };
$self = $this; $self = $this;
$io = $this->io;
$canceler = function () use (&$job) { $canceler = function () use (&$job) {
if ($job['status'] === ProcessExecutor::STATUS_QUEUED) { if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {