1
0
Fork 0
pull/9517/head
Jordi Boggiano 2020-11-22 14:48:56 +01:00
parent 152694b574
commit b7d770659b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
175 changed files with 688 additions and 724 deletions

View File

@ -695,6 +695,7 @@ EOF;
$version = str_replace('-', '.', $bound->getVersion()); $version = str_replace('-', '.', $bound->getVersion());
$chunks = array_map('intval', explode('.', $version)); $chunks = array_map('intval', explode('.', $version));
return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2]; return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
}; };
@ -710,6 +711,7 @@ EOF;
$version = str_replace('-', '.', $bound->getVersion()); $version = str_replace('-', '.', $bound->getVersion());
$chunks = explode('.', $version); $chunks = explode('.', $version);
$chunks = array_slice($chunks, 0, 3); $chunks = array_slice($chunks, 0, 3);
return implode('.', $chunks); return implode('.', $chunks);
}; };

View File

@ -176,8 +176,7 @@ class ClassMapGenerator
$className = substr($class, $namespaceLength + 1); $className = substr($class, $namespaceLength + 1);
$subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
. str_replace('_', DIRECTORY_SEPARATOR, $className); . str_replace('_', DIRECTORY_SEPARATOR, $className);
} } else {
else {
$subPath = str_replace('_', DIRECTORY_SEPARATOR, $class); $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
} }
} elseif ('psr-4' === $namespaceType) { } elseif ('psr-4' === $namespaceType) {

View File

@ -209,6 +209,7 @@ class Cache
{ {
if ($this->enabled) { if ($this->enabled) {
$this->filesystem->emptyDirectory($this->root); $this->filesystem->emptyDirectory($this->root);
return true; return true;
} }

View File

@ -13,7 +13,6 @@
namespace Composer\Command; namespace Composer\Command;
use Composer\Package\Link; use Composer\Package\Link;
use Composer\Package\PackageInterface;
use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\Constraint;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;

View File

@ -16,7 +16,6 @@ use Composer\Config;
use Composer\Factory; use Composer\Factory;
use Composer\Installer; use Composer\Installer;
use Composer\Installer\ProjectInstaller; use Composer\Installer\ProjectInstaller;
use Composer\Installer\InstallationManager;
use Composer\Installer\SuggestedPackagesReporter; use Composer\Installer\SuggestedPackagesReporter;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
@ -39,9 +38,7 @@ use Composer\Json\JsonFile;
use Composer\Config\JsonConfigSource; use Composer\Config\JsonConfigSource;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Loop;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\EventDispatcher\EventDispatcher;
/** /**
* Install a package as new project into new directory. * Install a package as new project into new directory.

View File

@ -677,7 +677,6 @@ EOT
return !$warnings && !$errors ? true : $output; return !$warnings && !$errors ? true : $output;
} }
/** /**
* Check if allow_url_fopen is ON * Check if allow_url_fopen is ON
* *

View File

@ -18,7 +18,6 @@ use Composer\Package\BasePackage;
use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Semver\Constraint\MatchAllConstraint;
use Composer\Repository\CompositeRepository; use Composer\Repository\CompositeRepository;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
/** /**

View File

@ -845,7 +845,6 @@ EOT
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.'); $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.');
} }
} }
private function hasDependencies($options) private function hasDependencies($options)

View File

@ -275,6 +275,7 @@ EOT
foreach ($packages as $package) { foreach ($packages as $package) {
if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) { if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
$io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>'); $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
return 2; return 2;
} }
} }

View File

@ -269,7 +269,6 @@ EOT
$rootPackage->setDevRequires($links['require-dev']); $rootPackage->setDevRequires($links['require-dev']);
} }
$updateDevMode = !$input->getOption('update-no-dev'); $updateDevMode = !$input->getOption('update-no-dev');
$optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader'); $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
$authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative'); $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');

View File

@ -488,8 +488,8 @@ TAGSPUBKEY
* Code taken from getcomposer.org/installer. Any changes should be made * Code taken from getcomposer.org/installer. Any changes should be made
* there and replicated here * there and replicated here
* *
* @return bool If the operation succeeded
* @throws \Exception * @throws \Exception
* @return bool If the operation succeeded
*/ */
protected function validatePhar($pharFile, &$error) protected function validatePhar($pharFile, &$error)
{ {

View File

@ -160,6 +160,7 @@ EOT
$package = $this->getComposer()->getPackage(); $package = $this->getComposer()->getPackage();
if ($input->getOption('name-only')) { if ($input->getOption('name-only')) {
$io->write($package->getName()); $io->write($package->getName());
return 0; return 0;
} }
$repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package))); $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
@ -207,7 +208,9 @@ EOT
if ($input->getOption('no-dev')) { if ($input->getOption('no-dev')) {
$packages = $this->filterRequiredPackages($installedRepo, $rootPkg); $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
$repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) { return clone $pkg; }, $packages)))); $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) {
return clone $pkg;
}, $packages))));
} }
if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) { if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
@ -798,7 +801,7 @@ EOT
'keywords' => $package->getKeywords() ?: array(), 'keywords' => $package->getKeywords() ?: array(),
'type' => $package->getType(), 'type' => $package->getType(),
'homepage' => $package->getHomepage(), 'homepage' => $package->getHomepage(),
'names' => $package->getNames() 'names' => $package->getNames(),
); );
$json = $this->appendVersions($json, $versions); $json = $this->appendVersions($json, $versions);
@ -814,7 +817,7 @@ EOT
$json['source'] = array( $json['source'] = array(
'type' => $package->getSourceType(), 'type' => $package->getSourceType(),
'url' => $package->getSourceUrl(), 'url' => $package->getSourceUrl(),
'reference' => $package->getSourceReference() 'reference' => $package->getSourceReference(),
); );
} }
@ -822,7 +825,7 @@ EOT
$json['dist'] = array( $json['dist'] = array(
'type' => $package->getDistType(), 'type' => $package->getDistType(),
'url' => $package->getDistUrl(), 'url' => $package->getDistUrl(),
'reference' => $package->getDistReference() 'reference' => $package->getDistReference(),
); );
} }
@ -880,7 +883,7 @@ EOT
return array( return array(
'name' => $license[0], 'name' => $license[0],
'osi' => $licenseId, 'osi' => $licenseId,
'url' => $license[2] 'url' => $license[2],
); );
}, $licenses); }, $licenses);
} }

View File

@ -175,6 +175,7 @@ EOT
if ($updateMirrors && !empty($packages)) { if ($updateMirrors && !empty($packages)) {
$io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>'); $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
return -1; return -1;
} }
@ -299,6 +300,7 @@ EOT
$oldPrettyString = $link->getConstraint()->getPrettyString(); $oldPrettyString = $link->getConstraint()->getPrettyString();
$newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint))); $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
$newConstraint->setPrettyString($oldPrettyString.', '.$constraint); $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
return new Link( return new Link(
$link->getSource(), $link->getSource(),
$link->getTarget(), $link->getTarget(),

View File

@ -13,7 +13,6 @@
namespace Composer; namespace Composer;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
use Composer\Spdx\SpdxLicenses;
use Composer\CaBundle\CaBundle; use Composer\CaBundle\CaBundle;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
@ -208,7 +207,7 @@ class Compiler
array( array(
'@package_version@' => $this->version, '@package_version@' => $this->version,
'@package_branch_alias_version@' => $this->branchAliasVersion, '@package_branch_alias_version@' => $this->branchAliasVersion,
'@release_date@' => $this->versionDate->format('Y-m-d H:i:s') '@release_date@' => $this->versionDate->format('Y-m-d H:i:s'),
) )
); );
$content = preg_replace('{SOURCE_VERSION = \'[^\']+\';}', 'SOURCE_VERSION = \'\';', $content); $content = preg_replace('{SOURCE_VERSION = \'[^\']+\';}', 'SOURCE_VERSION = \'\';', $content);

View File

@ -248,6 +248,7 @@ class Config
if (false === $val) { if (false === $val) {
$val = $this->config[$key]; $val = $this->config[$key];
} }
return $val !== 'false' && (bool) $val; return $val !== 'false' && (bool) $val;
// booleans without env var support // booleans without env var support

View File

@ -252,7 +252,7 @@ class JsonConfigSource implements ConfigSourceInterface
$this->arrayUnshiftRef($args, $config); $this->arrayUnshiftRef($args, $config);
call_user_func_array($fallback, $args); call_user_func_array($fallback, $args);
// avoid ending up with arrays for keys that should be objects // avoid ending up with arrays for keys that should be objects
foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support', ) as $prop) { foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support') as $prop) {
if (isset($config[$prop]) && $config[$prop] === array()) { if (isset($config[$prop]) && $config[$prop] === array()) {
$config[$prop] = new \stdClass; $config[$prop] = new \stdClass;
} }

View File

@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Console; namespace Composer\Console;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;

View File

@ -206,6 +206,7 @@ class Decisions implements \Iterator, \Countable
$str .= $packageId.':'.$level.','; $str .= $packageId.':'.$level.',';
} }
$str .= ']'; $str .= ']';
return $str; return $str;
} }
} }

View File

@ -12,14 +12,7 @@
namespace Composer\DependencyResolver; namespace Composer\DependencyResolver;
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
use Composer\DependencyResolver\Operation\UninstallOperation;
use Composer\Package\AliasPackage;
use Composer\Package\Link;
use Composer\Package\PackageInterface;
use Composer\Repository\PlatformRepository;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\Semver\Constraint\Constraint;
/** /**
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>

View File

@ -12,13 +12,8 @@
namespace Composer\DependencyResolver; namespace Composer\DependencyResolver;
use Composer\DependencyResolver\Operation\OperationInterface;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
use Composer\Package\RootAliasPackage; use Composer\Package\RootAliasPackage;
use Composer\Package\RootPackageInterface;
use Composer\Repository\ArrayRepository;
use Composer\Repository\RepositoryInterface;
use Composer\Test\Repository\ArrayRepositoryTest;
/** /**
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
@ -50,7 +45,6 @@ class LockTransaction extends Transaction
$this->setResultPackages($pool, $decisions); $this->setResultPackages($pool, $decisions);
parent::__construct($this->presentMap, $this->resultPackages['all']); parent::__construct($this->presentMap, $this->resultPackages['all']);
} }
// TODO make this a bit prettier instead of the two text indexes? // TODO make this a bit prettier instead of the two text indexes?

View File

@ -68,6 +68,7 @@ class MultiConflictRule extends Rule
if ($rule instanceof MultiConflictRule) { if ($rule instanceof MultiConflictRule) {
return $this->literals === $rule->getLiterals(); return $this->literals === $rule->getLiterals();
} }
return false; return false;
} }

View File

@ -13,7 +13,6 @@
namespace Composer\DependencyResolver\Operation; namespace Composer\DependencyResolver\Operation;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
use Composer\Package\PackageInterface;
/** /**
* Solver install operation. * Solver install operation.

View File

@ -13,7 +13,6 @@
namespace Composer\DependencyResolver\Operation; namespace Composer\DependencyResolver\Operation;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
use Composer\Package\PackageInterface;
/** /**
* Solver install operation. * Solver install operation.

View File

@ -12,8 +12,6 @@
namespace Composer\DependencyResolver\Operation; namespace Composer\DependencyResolver\Operation;
use Composer\Package\PackageInterface;
/** /**
* Abstract operation class. * Abstract operation class.
* *

View File

@ -20,5 +20,6 @@ use Composer\Package\PackageInterface;
interface PolicyInterface interface PolicyInterface
{ {
public function versionCompare(PackageInterface $a, PackageInterface $b, $operator); public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null); public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
} }

View File

@ -12,7 +12,6 @@
namespace Composer\DependencyResolver; namespace Composer\DependencyResolver;
use Composer\Package\AliasPackage;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\Semver\CompilingMatcher; use Composer\Semver\CompilingMatcher;
use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\ConstraintInterface;

View File

@ -281,6 +281,7 @@ class PoolBuilder
} }
$this->packagesToLoad[$name] = $constraint; $this->packagesToLoad[$name] = $constraint;
return; return;
} }
@ -420,6 +421,7 @@ class PoolBuilder
private function isRootRequire(Request $request, $name) private function isRootRequire(Request $request, $name)
{ {
$rootRequires = $request->getRequires(); $rootRequires = $request->getRequires();
return isset($rootRequires[$name]); return isset($rootRequires[$name]);
} }
@ -503,4 +505,3 @@ class PoolBuilder
} }
} }
} }

View File

@ -304,11 +304,13 @@ class Problem
$maxProviders = 20; $maxProviders = 20;
$providersStr = implode(array_map(function ($p) { $providersStr = implode(array_map(function ($p) {
$description = $p['description'] ? ' '.substr($p['description'], 0, 100) : ''; $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
return " - ${p['name']}".$description."\n"; return " - ${p['name']}".$description."\n";
}, count($providers) > $maxProviders+1 ? array_slice($providers, 0, $maxProviders) : $providers)); }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
if (count($providers) > $maxProviders+1) { if (count($providers) > $maxProviders + 1) {
$providersStr .= ' ... and '.(count($providers)-$maxProviders).' more.'."\n"; $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
} }
return array("- Root composer.json requires $packageName".self::constraintToText($constraint).", it ", "could not be found in any version, but the following packages provide it:\n".$providersStr." Consider requiring one of these to satisfy the $packageName requirement."); return array("- Root composer.json requires $packageName".self::constraintToText($constraint).", it ", "could not be found in any version, but the following packages provide it:\n".$providersStr." Consider requiring one of these to satisfy the $packageName requirement.");
} }
@ -403,7 +405,6 @@ class Problem
} }
return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages with higher priority do not match your '.$reason.' and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.'); return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages with higher priority do not match your '.$reason.' and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.');
} }
/** /**

View File

@ -14,7 +14,6 @@ namespace Composer\DependencyResolver;
use Composer\Package\Package; use Composer\Package\Package;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\RootAliasPackage;
use Composer\Repository\LockArrayRepository; use Composer\Repository\LockArrayRepository;
use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Semver\Constraint\MatchAllConstraint;

View File

@ -12,7 +12,6 @@
namespace Composer\DependencyResolver; namespace Composer\DependencyResolver;
use Composer\Package\CompletePackage;
use Composer\Package\Link; use Composer\Package\Link;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
@ -279,14 +278,13 @@ abstract class Rule
return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.'; return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.';
case self::RULE_LEARNED: case self::RULE_LEARNED:
/** @TODO currently still generates way too much output to be helpful, and in some cases can even lead to endless recursion /** @TODO currently still generates way too much output to be helpful, and in some cases can even lead to endless recursion */
if (isset($learnedPool[$this->reasonData])) { // if (isset($learnedPool[$this->reasonData])) {
echo $this->reasonData."\n"; // echo $this->reasonData."\n";
$learnedString = ', learned rules:' . Problem::formatDeduplicatedRules($learnedPool[$this->reasonData], ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool); // $learnedString = ', learned rules:' . Problem::formatDeduplicatedRules($learnedPool[$this->reasonData], ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
} else { // } else {
$learnedString = ' (reasoning unavailable)'; // $learnedString = ' (reasoning unavailable)';
} // }
*/
$learnedString = ' (conflict analysis result)'; $learnedString = ' (conflict analysis result)';
if (count($literals) === 1) { if (count($literals) === 1) {

View File

@ -12,11 +12,9 @@
namespace Composer\DependencyResolver; namespace Composer\DependencyResolver;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Semver\Constraint\Constraint;
/** /**
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>

View File

@ -61,7 +61,6 @@ class RuleWatchGraph
$this->watchChains[$literal]->unshift($node); $this->watchChains[$literal]->unshift($node);
} }
} }
} }
/** /**

View File

@ -15,7 +15,6 @@ namespace Composer\DependencyResolver;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Repository\PlatformRepository; use Composer\Repository\PlatformRepository;
use Composer\Semver\Constraint\MultiConstraint;
/** /**
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>

View File

@ -68,6 +68,7 @@ class Transaction
// if names are the same, compare version, e.g. to sort aliases reliably, actual order does not matter // if names are the same, compare version, e.g. to sort aliases reliably, actual order does not matter
return strcmp($b->getVersion(), $a->getVersion()); return strcmp($b->getVersion(), $a->getVersion());
} }
return strcmp($b->getName(), $a->getName()); return strcmp($b->getName(), $a->getName());
}; };
@ -230,6 +231,7 @@ class Transaction
if (!isset($this->resultPackagesByName[$link->getTarget()])) { if (!isset($this->resultPackagesByName[$link->getTarget()])) {
return array(); return array();
} }
return $this->resultPackagesByName[$link->getTarget()]; return $this->resultPackagesByName[$link->getTarget()];
} }

View File

@ -14,8 +14,6 @@ namespace Composer\Downloader;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Composer\IO\IOInterface;
use Composer\Exception\IrrecoverableDownloadException;
use React\Promise\PromiseInterface; use React\Promise\PromiseInterface;
use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\InstallOperation;
@ -28,7 +26,6 @@ use Composer\DependencyResolver\Operation\InstallOperation;
*/ */
abstract class ArchiveDownloader extends FileDownloader abstract class ArchiveDownloader extends FileDownloader
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}
* @throws \RuntimeException * @throws \RuntimeException
@ -158,8 +155,8 @@ abstract class ArchiveDownloader extends FileDownloader
* @param string $file Extracted file * @param string $file Extracted file
* @param string $path Directory * @param string $path Directory
* *
* @return PromiseInterface|null
* @throws \UnexpectedValueException If can not extract downloaded file to path * @throws \UnexpectedValueException If can not extract downloaded file to path
* @return PromiseInterface|null
*/ */
abstract protected function extract(PackageInterface $package, $file, $path); abstract protected function extract(PackageInterface $package, $file, $path);
} }

View File

@ -175,9 +175,9 @@ class DownloadManager
* @param string $targetDir target dir * @param string $targetDir target dir
* @param PackageInterface|null $prevPackage previous package instance in case of updates * @param PackageInterface|null $prevPackage previous package instance in case of updates
* *
* @return PromiseInterface
* @throws \InvalidArgumentException if package have no urls to download from * @throws \InvalidArgumentException if package have no urls to download from
* @throws \RuntimeException * @throws \RuntimeException
* @return PromiseInterface
*/ */
public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null) public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
{ {
@ -264,9 +264,9 @@ class DownloadManager
* @param PackageInterface $package package instance * @param PackageInterface $package package instance
* @param string $targetDir target dir * @param string $targetDir target dir
* *
* @return PromiseInterface|null
* @throws \InvalidArgumentException if package have no urls to download from * @throws \InvalidArgumentException if package have no urls to download from
* @throws \RuntimeException * @throws \RuntimeException
* @return PromiseInterface|null
*/ */
public function install(PackageInterface $package, $targetDir) public function install(PackageInterface $package, $targetDir)
{ {
@ -284,8 +284,8 @@ class DownloadManager
* @param PackageInterface $target target package version * @param PackageInterface $target target package version
* @param string $targetDir target dir * @param string $targetDir target dir
* *
* @return PromiseInterface|null
* @throws \InvalidArgumentException if initial package is not installed * @throws \InvalidArgumentException if initial package is not installed
* @return PromiseInterface|null
*/ */
public function update(PackageInterface $initial, PackageInterface $target, $targetDir) public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
{ {
@ -324,6 +324,7 @@ class DownloadManager
$promise = $initialDownloader->remove($initial, $targetDir); $promise = $initialDownloader->remove($initial, $targetDir);
if ($promise) { if ($promise) {
$self = $this; $self = $this;
return $promise->then(function ($res) use ($self, $target, $targetDir) { return $promise->then(function ($res) use ($self, $target, $targetDir) {
return $self->install($target, $targetDir); return $self->install($target, $targetDir);
}); });

View File

@ -29,7 +29,6 @@ use Composer\Util\Filesystem;
use Composer\Util\HttpDownloader; use Composer\Util\HttpDownloader;
use Composer\Util\Url as UrlUtil; use Composer\Util\Url as UrlUtil;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Downloader\TransportException;
use React\Promise\PromiseInterface; use React\Promise\PromiseInterface;
/** /**
@ -121,7 +120,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
// from different packages, which would potentially allow a given package // from different packages, which would potentially allow a given package
// in a third party repo to pre-populate the cache for the same package in // in a third party repo to pre-populate the cache for the same package in
// packagist for example. // packagist for example.
'cacheKey' => $cacheKeyGenerator($package, $processedUrl) 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
); );
} }
@ -147,7 +146,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface
$eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent); $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
if ($preFileDownloadEvent->getCustomCacheKey() !== null) { if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
$url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey()); $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
} else if ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) { } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
$url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl()); $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
} }
$url['processed'] = $preFileDownloadEvent->getProcessedUrl(); $url['processed'] = $preFileDownloadEvent->getProcessedUrl();

View File

@ -25,7 +25,6 @@ class FossilDownloader extends VcsDownloader
*/ */
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
{ {
} }
/** /**

View File

@ -12,15 +12,9 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use Composer\Config;
use Composer\Cache;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Util\Platform; use Composer\Util\Platform;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\HttpDownloader;
use Composer\IO\IOInterface;
use Composer\Util\Filesystem;
/** /**
* GZip archive downloader. * GZip archive downloader.

View File

@ -26,7 +26,6 @@ class HgDownloader extends VcsDownloader
*/ */
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
{ {
} }
/** /**

View File

@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Downloader; namespace Composer\Downloader;
class MaxFileSizeExceededException extends TransportException class MaxFileSizeExceededException extends TransportException

View File

@ -18,16 +18,9 @@ use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionGuesser; use Composer\Package\Version\VersionGuesser;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\Util\Platform; use Composer\Util\Platform;
use Composer\IO\IOInterface;
use Composer\Config;
use Composer\Cache;
use Composer\Util\HttpDownloader;
use Composer\Util\ProcessExecutor;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\EventDispatcher\EventDispatcher;
use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem; use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\UninstallOperation;

View File

@ -29,7 +29,6 @@ class PerforceDownloader extends VcsDownloader
*/ */
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
{ {
} }
/** /**

View File

@ -12,15 +12,9 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use Composer\Config;
use Composer\Cache;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\IniHelper; use Composer\Util\IniHelper;
use Composer\Util\Platform; use Composer\Util\Platform;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\HttpDownloader;
use Composer\Util\Filesystem;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use RarArchive; use RarArchive;

View File

@ -30,7 +30,6 @@ class SvnDownloader extends VcsDownloader
*/ */
protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
{ {
} }
/** /**

View File

@ -12,14 +12,8 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use Composer\Config;
use Composer\Cache;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\HttpDownloader;
use Composer\IO\IOInterface;
use Composer\Util\Filesystem;
/** /**
* Xz archive downloader. * Xz archive downloader.

View File

@ -12,16 +12,10 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use Composer\Config;
use Composer\Cache;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Util\IniHelper; use Composer\Util\IniHelper;
use Composer\Util\Platform; use Composer\Util\Platform;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Filesystem;
use Composer\Util\HttpDownloader;
use Composer\IO\IOInterface;
use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\ExecutableFinder;
use ZipArchive; use ZipArchive;

View File

@ -158,7 +158,6 @@ class EventDispatcher
$return = 0; $return = 0;
foreach ($listeners as $callable) { foreach ($listeners as $callable) {
$this->ensureBinDirIsInPath(); $this->ensureBinDirIsInPath();
if (!is_string($callable)) { if (!is_string($callable)) {
@ -168,7 +167,7 @@ class EventDispatcher
throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public'); throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
} }
if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) { if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
$this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1] ), true, IOInterface::VERBOSE); $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
} }
$return = false === call_user_func($callable, $event) ? 1 : 0; $return = false === call_user_func($callable, $event) ? 1 : 0;
} elseif ($this->isComposerScript($callable)) { } elseif ($this->isComposerScript($callable)) {

View File

@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer; namespace Composer;
use Composer\Semver\VersionParser; use Composer\Semver\VersionParser;

View File

@ -20,19 +20,14 @@ use Composer\DependencyResolver\LockTransaction;
use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\UninstallOperation;
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
use Composer\DependencyResolver\Operation\OperationInterface;
use Composer\DependencyResolver\PolicyInterface;
use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Request; use Composer\DependencyResolver\Request;
use Composer\DependencyResolver\Rule;
use Composer\DependencyResolver\Solver; use Composer\DependencyResolver\Solver;
use Composer\DependencyResolver\SolverProblemsException; use Composer\DependencyResolver\SolverProblemsException;
use Composer\Downloader\DownloadManager; use Composer\Downloader\DownloadManager;
use Composer\EventDispatcher\EventDispatcher; use Composer\EventDispatcher\EventDispatcher;
use Composer\Installer\InstallationManager; use Composer\Installer\InstallationManager;
use Composer\Installer\InstallerEvents; use Composer\Installer\InstallerEvents;
use Composer\Installer\NoopInstaller;
use Composer\Installer\SuggestedPackagesReporter; use Composer\Installer\SuggestedPackagesReporter;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
@ -41,7 +36,6 @@ use Composer\Package\BasePackage;
use Composer\Package\CompletePackage; use Composer\Package\CompletePackage;
use Composer\Package\CompletePackageInterface; use Composer\Package\CompletePackageInterface;
use Composer\Package\Link; use Composer\Package\Link;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Package\Loader\ArrayLoader; use Composer\Package\Loader\ArrayLoader;
use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Dumper\ArrayDumper;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
@ -50,9 +44,7 @@ use Composer\Repository\ArrayRepository;
use Composer\Repository\RepositorySet; use Composer\Repository\RepositorySet;
use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\Constraint;
use Composer\Package\Locker; use Composer\Package\Locker;
use Composer\Package\PackageInterface;
use Composer\Package\RootPackageInterface; use Composer\Package\RootPackageInterface;
use Composer\Repository\CompositeRepository;
use Composer\Repository\InstalledArrayRepository; use Composer\Repository\InstalledArrayRepository;
use Composer\Repository\InstalledRepositoryInterface; use Composer\Repository\InstalledRepositoryInterface;
use Composer\Repository\InstalledRepository; use Composer\Repository\InstalledRepository;
@ -376,6 +368,7 @@ class Installer
if ($this->updateAllowList) { if ($this->updateAllowList) {
if (!$lockedRepository) { if (!$lockedRepository) {
$this->io->writeError('<error>Cannot update only a partial set of packages without a lock file present.</error>', true, IOInterface::QUIET); $this->io->writeError('<error>Cannot update only a partial set of packages without a lock file present.</error>', true, IOInterface::QUIET);
return 1; return 1;
} }
} }
@ -660,6 +653,7 @@ class Installer
// installing the locked packages on this platform resulted in lock modifying operations, there wasn't a conflict, but the lock file as-is seems to not work on this system // installing the locked packages on this platform resulted in lock modifying operations, there wasn't a conflict, but the lock file as-is seems to not work on this system
if (0 !== count($lockTransaction->getOperations())) { if (0 !== count($lockTransaction->getOperations())) {
$this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET); $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
return 1; return 1;
} }
} catch (SolverProblemsException $e) { } catch (SolverProblemsException $e) {

View File

@ -25,7 +25,6 @@ use Composer\DependencyResolver\Operation\UninstallOperation;
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation; use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation; use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
use Composer\EventDispatcher\EventDispatcher; use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\StreamContextFactory;
use Composer\Util\Loop; use Composer\Util\Loop;
use React\Promise\PromiseInterface; use React\Promise\PromiseInterface;

View File

@ -13,13 +13,9 @@
namespace Composer\Installer; namespace Composer\Installer;
use Composer\Composer; use Composer\Composer;
use Composer\DependencyResolver\PolicyInterface;
use Composer\DependencyResolver\Request;
use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Transaction; use Composer\DependencyResolver\Transaction;
use Composer\EventDispatcher\Event; use Composer\EventDispatcher\Event;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Repository\RepositorySet;
class InstallerEvent extends Event class InstallerEvent extends Event
{ {

View File

@ -82,9 +82,8 @@ interface InstallerInterface
* @param InstalledRepositoryInterface $repo repository in which to check * @param InstalledRepositoryInterface $repo repository in which to check
* @param PackageInterface $initial already installed package version * @param PackageInterface $initial already installed package version
* @param PackageInterface $target updated version * @param PackageInterface $target updated version
* @return PromiseInterface|null
*
* @throws InvalidArgumentException if $initial package is not installed * @throws InvalidArgumentException if $initial package is not installed
* @return PromiseInterface|null
*/ */
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target); public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);

View File

@ -139,6 +139,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
$binaryInstaller = $this->binaryInstaller; $binaryInstaller = $this->binaryInstaller;
$installPath = $this->getInstallPath($package); $installPath = $this->getInstallPath($package);
return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) { return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
$binaryInstaller->installBinaries($package, $installPath); $binaryInstaller->installBinaries($package, $installPath);
if (!$repo->hasPackage($package)) { if (!$repo->hasPackage($package)) {
@ -166,6 +167,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
$binaryInstaller = $this->binaryInstaller; $binaryInstaller = $this->binaryInstaller;
$installPath = $this->getInstallPath($target); $installPath = $this->getInstallPath($target);
return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) { return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
$binaryInstaller->installBinaries($target, $installPath); $binaryInstaller->installBinaries($target, $installPath);
$repo->removePackage($initial); $repo->removePackage($initial);
@ -192,6 +194,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
$binaryInstaller = $this->binaryInstaller; $binaryInstaller = $this->binaryInstaller;
$downloadPath = $this->getPackageBasePath($package); $downloadPath = $this->getPackageBasePath($package);
$filesystem = $this->filesystem; $filesystem = $this->filesystem;
return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) { return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
$binaryInstaller->removeBinaries($package); $binaryInstaller->removeBinaries($package);
$repo->removePackage($package); $repo->removePackage($package);
@ -252,6 +255,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
protected function installCode(PackageInterface $package) protected function installCode(PackageInterface $package)
{ {
$downloadPath = $this->getInstallPath($package); $downloadPath = $this->getInstallPath($package);
return $this->downloadManager->install($package, $downloadPath); return $this->downloadManager->install($package, $downloadPath);
} }
@ -271,6 +275,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
} }
$self = $this; $self = $this;
return $promise->then(function () use ($self, $target) { return $promise->then(function () use ($self, $target) {
$reflMethod = new \ReflectionMethod($self, 'installCode'); $reflMethod = new \ReflectionMethod($self, 'installCode');
$reflMethod->setAccessible(true); $reflMethod->setAccessible(true);
@ -283,12 +288,14 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
$this->filesystem->rename($initialDownloadPath, $targetDownloadPath); $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
} }
return $this->downloadManager->update($initial, $target, $targetDownloadPath); return $this->downloadManager->update($initial, $target, $targetDownloadPath);
} }
protected function removeCode(PackageInterface $package) protected function removeCode(PackageInterface $package)
{ {
$downloadPath = $this->getPackageBasePath($package); $downloadPath = $this->getPackageBasePath($package);
return $this->downloadManager->remove($package, $downloadPath); return $this->downloadManager->remove($package, $downloadPath);
} }

View File

@ -14,7 +14,6 @@ namespace Composer\Installer;
use Composer\Repository\InstalledRepositoryInterface; use Composer\Repository\InstalledRepositoryInterface;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\InstallOperation;

View File

@ -15,10 +15,7 @@ namespace Composer\Installer;
use Composer\Composer; use Composer\Composer;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\DependencyResolver\Operation\OperationInterface; use Composer\DependencyResolver\Operation\OperationInterface;
use Composer\DependencyResolver\PolicyInterface;
use Composer\DependencyResolver\Request;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\Repository\RepositorySet;
use Composer\EventDispatcher\Event; use Composer\EventDispatcher\Event;
/** /**

View File

@ -71,6 +71,7 @@ class PluginInstaller extends LibraryInstaller
$pluginManager = $this->composer->getPluginManager(); $pluginManager = $this->composer->getPluginManager();
$self = $this; $self = $this;
return $promise->then(function () use ($self, $pluginManager, $package, $repo) { return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
try { try {
$pluginManager->registerPackage($package, true); $pluginManager->registerPackage($package, true);
@ -92,6 +93,7 @@ class PluginInstaller extends LibraryInstaller
$pluginManager = $this->composer->getPluginManager(); $pluginManager = $this->composer->getPluginManager();
$self = $this; $self = $this;
return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) { return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
try { try {
$pluginManager->deactivatePackage($initial, true); $pluginManager->deactivatePackage($initial, true);

View File

@ -431,7 +431,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
public function __toString() public function __toString()
{ {
return parent::__toString().' ('.($this->rootPackageAlias ? 'root ':''). 'alias of '.$this->aliasOf->getVersion().')'; return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
} }
public function setDistUrl($url) public function setDistUrl($url)

View File

@ -15,7 +15,6 @@ namespace Composer\Package;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
use Composer\Installer\InstallationManager; use Composer\Installer\InstallationManager;
use Composer\Repository\LockArrayRepository; use Composer\Repository\LockArrayRepository;
use Composer\Repository\RepositoryManager;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Dumper\ArrayDumper;
use Composer\Package\Loader\ArrayLoader; use Composer\Package\Loader\ArrayLoader;
@ -334,6 +333,7 @@ class Locker
if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) { if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
$alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS; $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
} }
return $alias; return $alias;
}, $aliases); }, $aliases);

View File

@ -21,7 +21,6 @@ use Composer\Util\HttpDownloader;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Svn as SvnUtil; use Composer\Util\Svn as SvnUtil;
/** /**
* Try to guess the current version number based on different VCS configuration. * Try to guess the current version number based on different VCS configuration.
* *

View File

@ -12,10 +12,8 @@
namespace Composer\Package\Version; namespace Composer\Package\Version;
use Composer\DependencyResolver\Pool;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Plugin\PluginInterface;
use Composer\Composer; use Composer\Composer;
use Composer\Package\Loader\ArrayLoader; use Composer\Package\Loader\ArrayLoader;
use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Dumper\ArrayDumper;

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Composer. * This file is part of Composer.
* *

View File

@ -74,6 +74,7 @@ class Runtime
} }
$refl = new \ReflectionClass($class); $refl = new \ReflectionClass($class);
return $refl->newInstanceArgs($arguments); return $refl->newInstanceArgs($arguments);
} }

View File

@ -71,7 +71,7 @@ class Version
*/ */
private static function convertAlphaVersionToIntVersion($alpha) private static function convertAlphaVersionToIntVersion($alpha)
{ {
return strlen($alpha) * (-ord('a')+1) + array_sum(array_map('ord', str_split($alpha))); return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
} }
/** /**

View File

@ -22,7 +22,6 @@ use Composer\Package\PackageInterface;
*/ */
class PostFileDownloadEvent extends Event class PostFileDownloadEvent extends Event
{ {
/** /**
* @var string * @var string
*/ */
@ -76,7 +75,8 @@ class PostFileDownloadEvent extends Event
* *
* @return string|null * @return string|null
*/ */
public function getChecksum() { public function getChecksum()
{
return $this->checksum; return $this->checksum;
} }
@ -85,18 +85,18 @@ class PostFileDownloadEvent extends Event
* *
* @return string * @return string
*/ */
public function getUrl() { public function getUrl()
{
return $this->url; return $this->url;
} }
/** /**
* Get the package. * Get the package.
* *
* @return \Composer\Package\PackageInterface * @return \Composer\Package\PackageInterface The package.
* The package.
*/ */
public function getPackage() { public function getPackage()
{
return $this->package; return $this->package;
} }
} }

View File

@ -13,7 +13,6 @@
namespace Composer\Plugin; namespace Composer\Plugin;
use Composer\EventDispatcher\Event; use Composer\EventDispatcher\Event;
use Symfony\Component\Console\Input\InputInterface;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\DependencyResolver\Request; use Composer\DependencyResolver\Request;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;

View File

@ -94,7 +94,7 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
$fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION); $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) { if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
$fileType = 'tar'; $fileType = 'tar';
} else if ($fileExtension === 'zip') { } elseif ($fileExtension === 'zip') {
$fileType = 'zip'; $fileType = 'zip';
} else { } else {
throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.'); throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');

View File

@ -1244,19 +1244,21 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$io = $this->io; $io = $this->io;
$url = $this->url; $url = $this->url;
$cache = $this->cache; $cache = $this->cache;
$degradedMode =& $this->degradedMode; $degradedMode = &$this->degradedMode;
$repo = $this; $repo = $this;
$accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) { $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) {
// package not found is acceptable for a v2 protocol repository // package not found is acceptable for a v2 protocol repository
if ($response->getStatusCode() === 404) { if ($response->getStatusCode() === 404) {
$repo->packagesNotFoundCache[$filename] = true; $repo->packagesNotFoundCache[$filename] = true;
return array('packages' => array()); return array('packages' => array());
} }
$json = $response->getBody(); $json = $response->getBody();
if ($json === '' && $response->getStatusCode() === 304) { if ($json === '' && $response->getStatusCode() === 304) {
$repo->freshMetadataUrls[$filename] = true; $repo->freshMetadataUrls[$filename] = true;
return true; return true;
} }
@ -1280,6 +1282,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
$reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) { $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) {
if ($e instanceof TransportException && $e->getStatusCode() === 404) { if ($e instanceof TransportException && $e->getStatusCode() === 404) {
$repo->packagesNotFoundCache[$filename] = true; $repo->packagesNotFoundCache[$filename] = true;
return false; return false;
} }

View File

@ -41,7 +41,9 @@ class CompositeRepository implements RepositoryInterface
public function getRepoName() public function getRepoName()
{ {
return 'composite repo ('.implode(', ', array_map(function ($repo) { return $repo->getRepoName(); }, $this->repositories)).')'; return 'composite repo ('.implode(', ', array_map(function ($repo) {
return $repo->getRepoName();
}, $this->repositories)).')';
} }
/** /**

View File

@ -16,11 +16,9 @@ use Composer\Package\Version\VersionParser;
use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\Constraint;
use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Semver\Constraint\MatchAllConstraint;
use Composer\Package\AliasPackage;
use Composer\Package\RootPackageInterface; use Composer\Package\RootPackageInterface;
use Composer\Package\Link; use Composer\Package\Link;
/** /**
* Installed repository is a composite of all installed repo types. * Installed repository is a composite of all installed repo types.
* *
@ -231,7 +229,9 @@ class InstalledRepository extends CompositeRepository
public function getRepoName() public function getRepoName()
{ {
return 'installed repo ('.implode(', ', array_map(function ($repo) { return $repo->getRepoName(); }, $this->getRepositories())).')'; return 'installed repo ('.implode(', ', array_map(function ($repo) {
return $repo->getRepoName();
}, $this->getRepositories())).')';
} }
/** /**

View File

@ -26,4 +26,3 @@ class LockArrayRepository extends ArrayRepository
return 'lock repo'; return 'lock repo';
} }
} }

View File

@ -12,17 +12,6 @@
namespace Composer\Repository; namespace Composer\Repository;
use Composer\IO\IOInterface;
use Composer\Semver\VersionParser as SemverVersionParser;
use Composer\Package\Version\VersionParser;
use Composer\Package\CompletePackage;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Package\Link;
use Composer\Semver\Constraint\Constraint;
use Composer\Util\HttpDownloader;
use Composer\Config;
use Composer\Factory;
/** /**
* Builds list of package from PEAR channel. * Builds list of package from PEAR channel.
* *

View File

@ -186,7 +186,7 @@ class PlatformRepository extends ArrayRepository
$library = strtolower($sslMatches['library']); $library = strtolower($sslMatches['library']);
if ($library === 'openssl') { if ($library === 'openssl') {
$parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips); $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
$this->addLibrary($name.'-openssl'.($isFips ? '-fips': ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl'): array()); $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl') : array());
} else { } else {
$this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl')); $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
} }
@ -315,7 +315,7 @@ class PlatformRepository extends ArrayRepository
case 'libxml': case 'libxml':
// ext/dom, ext/simplexml, ext/xmlreader and ext/xmlwriter use the same libxml as the ext/libxml // ext/dom, ext/simplexml, ext/xmlreader and ext/xmlwriter use the same libxml as the ext/libxml
$libxmlProvides = array_map(function($extension) { $libxmlProvides = array_map(function ($extension) {
return $extension . '-libxml'; return $extension . '-libxml';
}, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter'))); }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
$this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides); $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
@ -441,7 +441,7 @@ class PlatformRepository extends ArrayRepository
case 'zip': case 'zip':
if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) { if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
$this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION','ZipArchive'), null, array('zip')); $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, array('zip'));
} }
break; break;
@ -549,7 +549,7 @@ class PlatformRepository extends ArrayRepository
if ($name === 'uuid') { if ($name === 'uuid') {
$ext->setReplaces(array( $ext->setReplaces(array(
new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()) new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
)); ));
} }

View File

@ -20,12 +20,6 @@ use Composer\IO\IOInterface;
use Composer\IO\NullIO; use Composer\IO\NullIO;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
use Composer\Package\AliasPackage; use Composer\Package\AliasPackage;
use Composer\Package\Version\VersionParser;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
use Composer\Repository\LockArrayRepository;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\Repository\InstalledRepository;
use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Package\Version\StabilityFilter; use Composer\Package\Version\StabilityFilter;
@ -262,7 +256,6 @@ class RepositorySet
$aliasPackage->setRootPackageAlias(true); $aliasPackage->setRootPackageAlias(true);
$packages[] = $aliasPackage; $packages[] = $aliasPackage;
} }
} }
} }

View File

@ -144,7 +144,7 @@ abstract class BitbucketDriver extends VcsDriver
$hash = $branches[$label]; $hash = $branches[$label];
} }
if (! isset($hash)) { if (!isset($hash)) {
$composer['support']['source'] = sprintf( $composer['support']['source'] = sprintf(
'https://%s/%s/%s/src', 'https://%s/%s/%s/src',
$this->originUrl, $this->originUrl,

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(,$date) = explode(' ', trim($output), 3); list(, $date) = explode(' ', trim($output), 3);
return new \DateTime($date, new \DateTimeZone('UTC')); return new \DateTime($date, new \DateTimeZone('UTC'));
} }

View File

@ -30,7 +30,7 @@ class GitBitbucketDriver extends BitbucketDriver
} }
if (null === $this->rootIdentifier) { if (null === $this->rootIdentifier) {
if (! $this->getRepoData()) { if (!$this->getRepoData()) {
return $this->fallbackDriver->getRootIdentifier(); return $this->fallbackDriver->getRootIdentifier();
} }

View File

@ -58,7 +58,7 @@ class GitHubDriver extends VcsDriver
$this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository); $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
$this->cache->setReadOnly($this->config->get('cache-read-only')); $this->cache->setReadOnly($this->config->get('cache-read-only'));
if ( $this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'] ) ){ if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
$this->setupGitDriver($this->url); $this->setupGitDriver($this->url);
return; return;
@ -193,7 +193,6 @@ class GitHubDriver extends VcsDriver
} }
foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) { foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
try { try {
$response = $this->httpDownloader->get($file, array( $response = $this->httpDownloader->get($file, array(
'retry-auth-failure' => false, 'retry-auth-failure' => false,

View File

@ -563,6 +563,7 @@ class GitLabDriver extends VcsDriver
if ($portNumber) { if ($portNumber) {
return $guessedDomain.':'.$portNumber; return $guessedDomain.':'.$portNumber;
} }
return $guessedDomain; return $guessedDomain;
} }

View File

@ -30,7 +30,7 @@ class HgBitbucketDriver extends BitbucketDriver
} }
if (null === $this->rootIdentifier) { if (null === $this->rootIdentifier) {
if (! $this->getRepoData()) { if (!$this->getRepoData()) {
return $this->fallbackDriver->getRootIdentifier(); return $this->fallbackDriver->getRootIdentifier();
} }

View File

@ -15,7 +15,6 @@ namespace Composer\Repository\Vcs;
use Composer\Cache; use Composer\Cache;
use Composer\Downloader\TransportException; use Composer\Downloader\TransportException;
use Composer\Config; use Composer\Config;
use Composer\Factory;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;

View File

@ -14,7 +14,6 @@ namespace Composer\SelfUpdate;
use Composer\Util\HttpDownloader; use Composer\Util\HttpDownloader;
use Composer\Config; use Composer\Config;
use Composer\Json\JsonFile;
/** /**
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>

View File

@ -145,8 +145,8 @@ class AuthHelper
if ($askForOAuthToken) { if ($askForOAuthToken) {
$message = "\n".'Could not fetch ' . $url . ', please create a bitbucket OAuth token to ' . (($statusCode === 401 || $statusCode === 403) ? 'access private repos' : 'go over the API rate limit'); $message = "\n".'Could not fetch ' . $url . ', please create a bitbucket OAuth token to ' . (($statusCode === 401 || $statusCode === 403) ? 'access private repos' : 'go over the API rate limit');
$bitBucketUtil = new Bitbucket($this->io, $this->config); $bitBucketUtil = new Bitbucket($this->io, $this->config);
if (! $bitBucketUtil->authorizeOAuth($origin) if (!$bitBucketUtil->authorizeOAuth($origin)
&& (! $this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message)) && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
) { ) {
throw new TransportException('Could not authenticate against ' . $origin, 401); throw new TransportException('Could not authenticate against ' . $origin, 401);
} }

View File

@ -141,7 +141,6 @@ class ConfigValidator
} }
} }
// check for meaningless provide/replace satisfying requirements // check for meaningless provide/replace satisfying requirements
foreach (array('provide', 'replace') as $linkType) { foreach (array('provide', 'replace') as $linkType) {
if (isset($manifest[$linkType])) { if (isset($manifest[$linkType])) {

View File

@ -139,7 +139,7 @@ class Git
//We already have an access_token from a previous request. //We already have an access_token from a previous request.
if ($auth['username'] !== 'x-token-auth') { if ($auth['username'] !== 'x-token-auth') {
$accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']); $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
if (! empty($accessToken)) { if (!empty($accessToken)) {
$this->io->setAuthentication($match[1], 'x-token-auth', $accessToken); $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
} }
} }

View File

@ -16,7 +16,6 @@ use Composer\IO\IOInterface;
use Composer\Config; use Composer\Config;
use Composer\Factory; use Composer\Factory;
use Composer\Downloader\TransportException; use Composer\Downloader\TransportException;
use Composer\Json\JsonFile;
/** /**
* @author Roshan Gautam <roshan.gautam@hotmail.com> * @author Roshan Gautam <roshan.gautam@hotmail.com>
@ -89,7 +88,7 @@ class GitLab
$token = $authTokens[$bcOriginUrl]; $token = $authTokens[$bcOriginUrl];
} }
if(isset($token)){ if (isset($token)) {
$username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token; $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
$password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token'; $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
$this->io->setAuthentication($originUrl, $username, $password); $this->io->setAuthentication($originUrl, $username, $password);

View File

@ -16,7 +16,6 @@ use Composer\Config;
use Composer\Downloader\MaxFileSizeExceededException; use Composer\Downloader\MaxFileSizeExceededException;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Downloader\TransportException; use Composer\Downloader\TransportException;
use Composer\CaBundle\CaBundle;
use Composer\Util\StreamContextFactory; use Composer\Util\StreamContextFactory;
use Composer\Util\AuthHelper; use Composer\Util\AuthHelper;
use Composer\Util\Url; use Composer\Util\Url;
@ -48,7 +47,7 @@ class CurlDownloader
CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'), CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
CURLM_BAD_EASY_HANDLE => array('CURLM_BAD_EASY_HANDLE', "An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle."), CURLM_BAD_EASY_HANDLE => array('CURLM_BAD_EASY_HANDLE', "An easy handle was not good/valid. It could mean that it isn't an easy handle at all, or possibly that the handle already is in used by this or another multi handle."),
CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'), CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!') CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'),
); );
private static $options = array( private static $options = array(
@ -165,7 +164,7 @@ class CurlDownloader
curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle); curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle); curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip"); curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip");
curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
if (function_exists('curl_share_init')) { if (function_exists('curl_share_init')) {
curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle); curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
} }
@ -513,7 +512,8 @@ class CurlDownloader
private function checkCurlResult($code) private function checkCurlResult($code)
{ {
if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) { if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
throw new \RuntimeException(isset($this->multiErrors[$code]) throw new \RuntimeException(
isset($this->multiErrors[$code])
? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}" ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
: 'Unexpected cURL error: ' . $code : 'Unexpected cURL error: ' . $code
); );

View File

@ -51,7 +51,7 @@ class ProxyManager
} }
/** /**
* @return ProxyManager * * @return ProxyManager
*/ */
public static function getInstance() public static function getInstance()
{ {
@ -130,6 +130,7 @@ class ProxyManager
list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData(); list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
} catch (\RuntimeException $e) { } catch (\RuntimeException $e) {
$this->error = $e->getMessage(); $this->error = $e->getMessage();
return; return;
} }
@ -177,6 +178,7 @@ class ProxyManager
if ($this->noProxyHandler) { if ($this->noProxyHandler) {
if (call_user_func($this->noProxyHandler, $requestUrl)) { if (call_user_func($this->noProxyHandler, $requestUrl)) {
$this->lastProxy = 'excluded by no_proxy'; $this->lastProxy = 'excluded by no_proxy';
return true; return true;
} }
} }

View File

@ -15,7 +15,6 @@ namespace Composer\Util;
use Composer\Config; use Composer\Config;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
use Composer\Downloader\TransportException; use Composer\Downloader\TransportException;
use Composer\CaBundle\CaBundle;
use Composer\Util\Http\Response; use Composer\Util\Http\Response;
use Composer\Composer; use Composer\Composer;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
@ -231,7 +230,7 @@ class HttpDownloader
throw $e; throw $e;
}); });
$this->jobs[$job['id']] =& $job; $this->jobs[$job['id']] = &$job;
if ($this->runningJobs < $this->maxJobs) { if ($this->runningJobs < $this->maxJobs) {
$this->startJob($job['id']); $this->startJob($job['id']);
@ -242,7 +241,7 @@ class HttpDownloader
private function startJob($id) private function startJob($id)
{ {
$job =& $this->jobs[$id]; $job = &$this->jobs[$id];
if ($job['status'] !== self::STATUS_QUEUED) { if ($job['status'] !== self::STATUS_QUEUED) {
return; return;
} }
@ -265,6 +264,7 @@ class HttpDownloader
$e->setStatusCode(499); $e->setStatusCode(499);
$reject($e); $reject($e);
} }
return; return;
} }
@ -395,17 +395,17 @@ class HttpDownloader
Silencer::suppress(); Silencer::suppress();
$testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array( $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
'ssl' => array('verify_peer' => false), 'ssl' => array('verify_peer' => false),
'http' => array('follow_location' => false, 'ignore_errors' => true) 'http' => array('follow_location' => false, 'ignore_errors' => true),
))); )));
Silencer::restore(); Silencer::restore();
if (false !== $testConnectivity) { if (false !== $testConnectivity) {
return array( return array(
'<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>' '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
); );
} }
return array( return array(
'<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>' '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
); );
} }
} }

View File

@ -12,7 +12,6 @@
namespace Composer\Util; namespace Composer\Util;
use Composer\Util\HttpDownloader;
use React\Promise\Promise; use React\Promise\Promise;
use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\ProgressBar;
@ -63,7 +62,8 @@ class Loop
$uncaught = null; $uncaught = null;
\React\Promise\all($promises)->then( \React\Promise\all($promises)->then(
function () { }, function () {
},
function ($e) use (&$uncaught) { function ($e) use (&$uncaught) {
$uncaught = $e; $uncaught = $e;
} }

View File

@ -134,7 +134,7 @@ class NoProxyPattern
$match = $rule->ipdata->ip === $url->ipdata->ip; $match = $rule->ipdata->ip === $url->ipdata->ip;
} else { } else {
// Match host and port // Match host and port
$haystack = substr($url->name, - strlen($rule->name)); $haystack = substr($url->name, -strlen($rule->name));
$match = stripos($haystack, $rule->name) === 0; $match = stripos($haystack, $rule->name) === 0;
} }
@ -392,8 +392,7 @@ class NoProxyPattern
$ip6 = substr($hostName, 1, $index - 1); $ip6 = substr($hostName, 1, $index - 1);
$hostName = substr($hostName, $index + 1); $hostName = substr($hostName, $index + 1);
if (strpbrk($hostName, '[]') !== false if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
|| substr_count($hostName, ':') > 1) {
return $error; return $error;
} }
} }
@ -427,7 +426,8 @@ class NoProxyPattern
$options = array( $options = array(
'options' => array( 'options' => array(
'min_range' => $min, 'min_range' => $min,
'max_range' => $max) 'max_range' => $max,
),
); );
return false !== filter_var($int, FILTER_VALIDATE_INT, $options); return false !== filter_var($int, FILTER_VALIDATE_INT, $options);

View File

@ -1,5 +1,14 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Util; namespace Composer\Util;
@ -16,7 +25,8 @@ class PackageSorter
* @param array $packages * @param array $packages
* @return array * @return array
*/ */
public static function sortPackages(array $packages) { public static function sortPackages(array $packages)
{
$usageList = array(); $usageList = array();
foreach ($packages as $package) { /** @var PackageInterface $package */ foreach ($packages as $package) { /** @var PackageInterface $package */
@ -87,6 +97,7 @@ class PackageSorter
foreach (array_keys($weightList) as $index) { foreach (array_keys($weightList) as $index) {
$sortedPackages[] = $packages[$index]; $sortedPackages[] = $packages[$index];
} }
return $sortedPackages; return $sortedPackages;
} }
} }

View File

@ -198,7 +198,7 @@ class ProcessExecutor
throw $e; throw $e;
}); });
$this->jobs[$job['id']] =& $job; $this->jobs[$job['id']] = &$job;
if ($this->runningJobs < $this->maxJobs) { if ($this->runningJobs < $this->maxJobs) {
$this->startJob($job['id']); $this->startJob($job['id']);
@ -209,7 +209,7 @@ class ProcessExecutor
private function startJob($id) private function startJob($id)
{ {
$job =& $this->jobs[$id]; $job = &$this->jobs[$id];
if ($job['status'] !== self::STATUS_QUEUED) { if ($job['status'] !== self::STATUS_QUEUED) {
return; return;
} }

View File

@ -550,7 +550,6 @@ class RemoteFilesystem
// passing `null` to file_get_contents will convert `null` to `0` and return 0 bytes // passing `null` to file_get_contents will convert `null` to `0` and return 0 bytes
$result = file_get_contents($fileUrl, false, $context); $result = file_get_contents($fileUrl, false, $context);
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
} catch (\Exception $e) { } catch (\Exception $e) {
} }

View File

@ -1,5 +1,15 @@
<?php <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Util; namespace Composer\Util;
use Composer\Downloader\DownloaderInterface; use Composer\Downloader\DownloaderInterface;

View File

@ -12,7 +12,6 @@
namespace Composer\Test; namespace Composer\Test;
use Composer\Test\TestCase;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;

View File

@ -13,7 +13,6 @@
namespace Composer\Test; namespace Composer\Test;
use Composer\Console\Application; use Composer\Console\Application;
use Composer\Test\TestCase;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class ApplicationTest extends TestCase class ApplicationTest extends TestCase

View File

@ -500,7 +500,7 @@ class AutoloadGeneratorTest extends TestCase
{ {
$package = new RootPackage('root/a', '1.0', '1.0'); $package = new RootPackage('root/a', '1.0', '1.0');
$package->setRequires(array( $package->setRequires(array(
new Link('a', 'a/a', new MatchAllConstraint()) new Link('a', 'a/a', new MatchAllConstraint()),
)); ));
$packages = array(); $packages = array();
@ -511,18 +511,18 @@ class AutoloadGeneratorTest extends TestCase
$packages[] = $e = new Package('e/e', '1.0', '1.0'); $packages[] = $e = new Package('e/e', '1.0', '1.0');
$a->setAutoload(array('classmap' => array('src/A.php'))); $a->setAutoload(array('classmap' => array('src/A.php')));
$a->setRequires(array( $a->setRequires(array(
new Link('a/a', 'b/b', new MatchAllConstraint()) new Link('a/a', 'b/b', new MatchAllConstraint()),
)); ));
$b->setAutoload(array('classmap' => array('src/B.php'))); $b->setAutoload(array('classmap' => array('src/B.php')));
$b->setRequires(array( $b->setRequires(array(
new Link('b/b', 'e/e', new MatchAllConstraint()) new Link('b/b', 'e/e', new MatchAllConstraint()),
)); ));
$c->setAutoload(array('classmap' => array('src/C.php'))); $c->setAutoload(array('classmap' => array('src/C.php')));
$c->setReplaces(array( $c->setReplaces(array(
new Link('c/c', 'b/b', new MatchAllConstraint()) new Link('c/c', 'b/b', new MatchAllConstraint()),
)); ));
$c->setRequires(array( $c->setRequires(array(
new Link('c/c', 'd/d', new MatchAllConstraint()) new Link('c/c', 'd/d', new MatchAllConstraint()),
)); ));
$d->setAutoload(array('classmap' => array('src/D.php'))); $d->setAutoload(array('classmap' => array('src/D.php')));
$e->setAutoload(array('classmap' => array('src/E.php'))); $e->setAutoload(array('classmap' => array('src/E.php')));
@ -1740,63 +1740,63 @@ EOF;
array( array(
new Link('a', 'php', $versionParser->parseConstraints('^7.2')), new Link('a', 'php', $versionParser->parseConstraints('^7.2')),
new Link('a', 'ext-xml', $versionParser->parseConstraints('*')), new Link('a', 'ext-xml', $versionParser->parseConstraints('*')),
new Link('a', 'ext-json', $versionParser->parseConstraints('*')) new Link('a', 'ext-json', $versionParser->parseConstraints('*')),
), ),
'typical' 'typical',
), ),
'No PHP lower bound' => array( 'No PHP lower bound' => array(
array( array(
new Link('a', 'php', $versionParser->parseConstraints('< 8')), new Link('a', 'php', $versionParser->parseConstraints('< 8')),
), ),
null null,
), ),
'No PHP upper bound' => array( 'No PHP upper bound' => array(
array( array(
new Link('a', 'php', $versionParser->parseConstraints('>= 7.2')), new Link('a', 'php', $versionParser->parseConstraints('>= 7.2')),
), ),
'no_php_upper_bound' 'no_php_upper_bound',
), ),
'Specific PHP release version' => array( 'Specific PHP release version' => array(
array( array(
new Link('a', 'php', $versionParser->parseConstraints('^7.2.8')), new Link('a', 'php', $versionParser->parseConstraints('^7.2.8')),
), ),
'specific_php_release' 'specific_php_release',
), ),
'No PHP required' => array( 'No PHP required' => array(
array( array(
new Link('a', 'ext-xml', $versionParser->parseConstraints('*')), new Link('a', 'ext-xml', $versionParser->parseConstraints('*')),
new Link('a', 'ext-json', $versionParser->parseConstraints('*')) new Link('a', 'ext-json', $versionParser->parseConstraints('*')),
), ),
'no_php_required' 'no_php_required',
), ),
'Ignoring all platform requirements skips check completely' => array( 'Ignoring all platform requirements skips check completely' => array(
array( array(
new Link('a', 'php', $versionParser->parseConstraints('^7.2')), new Link('a', 'php', $versionParser->parseConstraints('^7.2')),
new Link('a', 'ext-xml', $versionParser->parseConstraints('*')), new Link('a', 'ext-xml', $versionParser->parseConstraints('*')),
new Link('a', 'ext-json', $versionParser->parseConstraints('*')) new Link('a', 'ext-json', $versionParser->parseConstraints('*')),
), ),
null, null,
array(), array(),
array(), array(),
true true,
), ),
'Ignored platform requirements are not checked for' => array( 'Ignored platform requirements are not checked for' => array(
array( array(
new Link('a', 'php', $versionParser->parseConstraints('^7.2.8')), new Link('a', 'php', $versionParser->parseConstraints('^7.2.8')),
new Link('a', 'ext-xml', $versionParser->parseConstraints('*')), new Link('a', 'ext-xml', $versionParser->parseConstraints('*')),
new Link('a', 'ext-json', $versionParser->parseConstraints('*')), new Link('a', 'ext-json', $versionParser->parseConstraints('*')),
new Link('a', 'ext-pdo', $versionParser->parseConstraints('*')) new Link('a', 'ext-pdo', $versionParser->parseConstraints('*')),
), ),
'no_php_required', 'no_php_required',
array(), array(),
array(), array(),
array('php', 'ext-pdo') array('php', 'ext-pdo'),
), ),
'No extensions required' => array( 'No extensions required' => array(
array( array(
new Link('a', 'php', $versionParser->parseConstraints('^7.2')), new Link('a', 'php', $versionParser->parseConstraints('^7.2')),
), ),
'no_extensions_required' 'no_extensions_required',
), ),
'Replaced/provided extensions are not checked for + checking case insensitivity' => array( 'Replaced/provided extensions are not checked for + checking case insensitivity' => array(
array( array(

View File

@ -12,7 +12,6 @@
namespace Composer\Test; namespace Composer\Test;
use Composer\Test\TestCase;
use Composer\Cache; use Composer\Cache;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;

View File

@ -13,7 +13,6 @@
namespace Composer\Test; namespace Composer\Test;
use Composer\Composer; use Composer\Composer;
use Composer\Test\TestCase;
class ComposerTest extends TestCase class ComposerTest extends TestCase
{ {

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