From b7d770659b4e3ef21423bd67ade935572913a4c1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 22 Nov 2020 14:48:56 +0100 Subject: [PATCH] CS fixes --- src/Composer/Autoload/AutoloadGenerator.php | 2 + src/Composer/Autoload/ClassMapGenerator.php | 19 +- src/Composer/Cache.php | 1 + .../Command/CheckPlatformReqsCommand.php | 1 - src/Composer/Command/CreateProjectCommand.php | 3 - src/Composer/Command/DiagnoseCommand.php | 1 - src/Composer/Command/FundCommand.php | 1 - src/Composer/Command/InitCommand.php | 1 - src/Composer/Command/RemoveCommand.php | 1 + src/Composer/Command/RequireCommand.php | 1 - src/Composer/Command/SelfUpdateCommand.php | 20 +- src/Composer/Command/ShowCommand.php | 13 +- src/Composer/Command/StatusCommand.php | 2 +- src/Composer/Command/UpdateCommand.php | 2 + src/Composer/Compiler.php | 3 +- src/Composer/Config.php | 1 + src/Composer/Config/ConfigSourceInterface.php | 2 +- src/Composer/Config/JsonConfigSource.php | 2 +- src/Composer/Console/Application.php | 4 +- src/Composer/Console/GithubActionError.php | 14 +- src/Composer/DependencyResolver/Decisions.php | 1 + .../LocalRepoTransaction.php | 7 - .../DependencyResolver/LockTransaction.php | 6 - .../DependencyResolver/MultiConflictRule.php | 1 + .../Operation/MarkAliasInstalledOperation.php | 1 - .../MarkAliasUninstalledOperation.php | 1 - .../Operation/OperationInterface.php | 2 +- .../Operation/SolverOperation.php | 2 - .../DependencyResolver/PolicyInterface.php | 1 + src/Composer/DependencyResolver/Pool.php | 13 +- .../DependencyResolver/PoolBuilder.php | 3 +- src/Composer/DependencyResolver/Problem.php | 13 +- src/Composer/DependencyResolver/Request.php | 1 - src/Composer/DependencyResolver/Rule.php | 16 +- .../DependencyResolver/RuleSetGenerator.php | 12 +- .../DependencyResolver/RuleWatchGraph.php | 5 +- src/Composer/DependencyResolver/Solver.php | 11 +- .../DependencyResolver/Transaction.php | 2 + src/Composer/Downloader/ArchiveDownloader.php | 5 +- src/Composer/Downloader/DownloadManager.php | 39 ++-- src/Composer/Downloader/FileDownloader.php | 17 +- src/Composer/Downloader/FossilDownloader.php | 1 - src/Composer/Downloader/GitDownloader.php | 6 +- src/Composer/Downloader/GzipDownloader.php | 6 - src/Composer/Downloader/HgDownloader.php | 1 - .../MaxFileSizeExceededException.php | 10 + src/Composer/Downloader/PathDownloader.php | 7 - .../Downloader/PerforceDownloader.php | 1 - src/Composer/Downloader/RarDownloader.php | 6 - src/Composer/Downloader/SvnDownloader.php | 1 - src/Composer/Downloader/XzDownloader.php | 6 - src/Composer/Downloader/ZipDownloader.php | 18 +- .../EventDispatcher/EventDispatcher.php | 11 +- src/Composer/Factory.php | 10 +- src/Composer/IO/ConsoleIO.php | 2 +- src/Composer/IO/IOInterface.php | 2 +- src/Composer/InstalledVersions.php | 10 + src/Composer/Installer.php | 36 ++-- .../Installer/InstallationManager.php | 5 +- src/Composer/Installer/InstallerEvent.php | 16 +- src/Composer/Installer/InstallerInterface.php | 3 +- src/Composer/Installer/LibraryInstaller.php | 7 + .../Installer/MetapackageInstaller.php | 1 - src/Composer/Installer/PackageEvent.php | 3 - src/Composer/Installer/PluginInstaller.php | 2 + .../Installer/SuggestedPackagesReporter.php | 4 +- src/Composer/Json/JsonFile.php | 2 +- src/Composer/Package/AliasPackage.php | 2 +- src/Composer/Package/BasePackage.php | 2 +- src/Composer/Package/Link.php | 10 +- src/Composer/Package/Loader/ArrayLoader.php | 8 +- src/Composer/Package/Locker.php | 2 +- src/Composer/Package/PackageInterface.php | 2 +- .../Package/Version/StabilityFilter.php | 6 +- .../Package/Version/VersionGuesser.php | 1 - .../Package/Version/VersionSelector.php | 10 +- src/Composer/Platform/HhvmDetector.php | 1 + src/Composer/Platform/Runtime.php | 25 +-- src/Composer/Platform/Version.php | 16 +- src/Composer/Plugin/PostFileDownloadEvent.php | 24 +-- src/Composer/Plugin/PreFileDownloadEvent.php | 10 +- src/Composer/Plugin/PrePoolCreateEvent.php | 1 - src/Composer/Repository/ArrayRepository.php | 4 +- .../Repository/ArtifactRepository.php | 2 +- .../Repository/ComposerRepository.php | 15 +- .../Repository/CompositeRepository.php | 4 +- .../Repository/FilesystemRepository.php | 6 +- .../Repository/InstalledRepository.php | 6 +- .../Repository/LockArrayRepository.php | 1 - src/Composer/Repository/PearRepository.php | 11 -- .../Repository/PlatformRepository.php | 12 +- .../Repository/RepositoryInterface.php | 4 +- src/Composer/Repository/RepositorySet.php | 17 +- .../Repository/Vcs/BitbucketDriver.php | 2 +- src/Composer/Repository/Vcs/FossilDriver.php | 2 +- .../Repository/Vcs/GitBitbucketDriver.php | 2 +- src/Composer/Repository/Vcs/GitHubDriver.php | 5 +- src/Composer/Repository/Vcs/GitLabDriver.php | 3 +- .../Repository/Vcs/HgBitbucketDriver.php | 2 +- src/Composer/Repository/Vcs/VcsDriver.php | 11 +- .../Repository/Vcs/VcsDriverInterface.php | 10 +- .../Repository/VersionCacheInterface.php | 4 +- src/Composer/Script/Event.php | 4 +- src/Composer/SelfUpdate/Versions.php | 1 - src/Composer/Util/AuthHelper.php | 28 +-- src/Composer/Util/Bitbucket.php | 10 +- src/Composer/Util/ConfigValidator.php | 1 - src/Composer/Util/Filesystem.php | 6 +- src/Composer/Util/Git.php | 2 +- src/Composer/Util/GitHub.php | 8 +- src/Composer/Util/GitLab.php | 13 +- src/Composer/Util/Http/CurlDownloader.php | 12 +- src/Composer/Util/Http/ProxyHelper.php | 20 +- src/Composer/Util/Http/ProxyManager.php | 10 +- src/Composer/Util/Http/RequestProxy.php | 6 +- src/Composer/Util/HttpDownloader.php | 12 +- src/Composer/Util/Loop.php | 4 +- src/Composer/Util/NoProxyPattern.php | 38 ++-- src/Composer/Util/PackageSorter.php | 13 +- src/Composer/Util/Perforce.php | 6 +- src/Composer/Util/ProcessExecutor.php | 8 +- src/Composer/Util/RemoteFilesystem.php | 1 - src/Composer/Util/StreamContextFactory.php | 8 +- src/Composer/Util/SyncHelper.php | 10 + src/Composer/Util/Url.php | 8 +- src/Composer/Util/Zip.php | 4 +- tests/Composer/Test/AllFunctionalTest.php | 5 +- tests/Composer/Test/ApplicationTest.php | 1 - .../Test/Autoload/AutoloadGeneratorTest.php | 34 ++-- tests/Composer/Test/CacheTest.php | 1 - .../Composer/Test/Command/InitCommandTest.php | 4 +- tests/Composer/Test/ComposerTest.php | 1 - tests/Composer/Test/ConfigTest.php | 1 - tests/Composer/Test/DefaultConfigTest.php | 1 - .../DependencyResolver/DefaultPolicyTest.php | 2 - .../DependencyResolver/PoolBuilderTest.php | 7 - .../Test/DependencyResolver/PoolTest.php | 3 - .../RuleSetIteratorTest.php | 1 - .../Test/DependencyResolver/RuleSetTest.php | 2 - .../Test/DependencyResolver/RuleTest.php | 2 - .../Test/DependencyResolver/SolverTest.php | 2 - .../Test/Downloader/FileDownloaderTest.php | 10 +- .../Test/Downloader/GitDownloaderTest.php | 2 - .../EventDispatcher/EventDispatcherTest.php | 20 +- tests/Composer/Test/InstalledVersionsTest.php | 1 - tests/Composer/Test/InstallerTest.php | 7 +- .../Composer/Test/Json/ComposerSchemaTest.php | 2 +- .../Test/Json/JsonManipulatorTest.php | 3 +- .../Test/Mock/InstallationManagerMock.php | 2 - .../Loader/ValidatingArrayLoaderTest.php | 8 +- .../Test/Platform/HhvmDetectorTest.php | 4 + .../Test/Plugin/PluginInstallerTest.php | 1 - tests/Composer/Test/PolyfillTestCase.php | 17 +- .../StrictConfirmationQuestionTest.php | 1 - .../Repository/ArtifactRepositoryTest.php | 1 - .../Repository/ComposerRepositoryTest.php | 6 +- .../Test/Repository/FilterRepositoryTest.php | 4 +- .../Test/Repository/Fixtures/installed.php | 20 +- .../Test/Repository/PathRepositoryTest.php | 2 - .../Repository/PlatformRepositoryTest.php | 175 ++++++++++-------- .../Test/Repository/Vcs/FossilDriverTest.php | 1 - .../Repository/Vcs/GitBitbucketDriverTest.php | 12 +- .../Test/Repository/Vcs/GitHubDriverTest.php | 2 +- .../Test/Repository/Vcs/SvnDriverTest.php | 1 - tests/Composer/Test/TestCase.php | 1 - tests/Composer/Test/Util/AuthHelperTest.php | 58 +++--- tests/Composer/Test/Util/BitbucketTest.php | 9 +- tests/Composer/Test/Util/GitTest.php | 10 + .../Test/Util/Http/ProxyHelperTest.php | 10 +- .../Test/Util/Http/ProxyManagerTest.php | 11 +- .../Test/Util/Http/RequestProxyTest.php | 6 +- .../Composer/Test/Util/PackageSorterTest.php | 4 +- .../Test/Util/ProcessExecutorTest.php | 4 +- .../Test/Util/RemoteFilesystemTest.php | 16 +- tests/Composer/Test/Util/ZipTest.php | 8 + 175 files changed, 688 insertions(+), 724 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 750b42f1a..6ad5d94b0 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -695,6 +695,7 @@ EOF; $version = str_replace('-', '.', $bound->getVersion()); $chunks = array_map('intval', explode('.', $version)); + return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2]; }; @@ -710,6 +711,7 @@ EOF; $version = str_replace('-', '.', $bound->getVersion()); $chunks = explode('.', $version); $chunks = array_slice($chunks, 0, 3); + return implode('.', $chunks); }; diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index a71cb1a4b..60044e19c 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -51,7 +51,7 @@ class ClassMapGenerator * Iterate over all files in the given directory searching for classes * * @param \Iterator|string $path The path to search in or an iterator - * @param string $excluded Regex that matches against the file path that exclude from the classmap. + * @param string $excluded Regex that matches against the file path that exclude from the classmap. * @param IOInterface $io IO object * @param string $namespace Optional namespace prefix to filter by * @param string $autoloadType psr-0|psr-4 Optional autoload standard to use mapping rules @@ -147,13 +147,13 @@ class ClassMapGenerator /** * Remove classes which could not have been loaded by namespace autoloaders * - * @param array $classes found classes in given file - * @param string $filePath current file - * @param string $baseNamespace prefix of given autoload mapping - * @param string $namespaceType psr-0|psr-4 - * @param string $basePath root directory of given autoload mapping - * @param IOInterface $io IO object - * @return array valid classes + * @param array $classes found classes in given file + * @param string $filePath current file + * @param string $baseNamespace prefix of given autoload mapping + * @param string $namespaceType psr-0|psr-4 + * @param string $basePath root directory of given autoload mapping + * @param IOInterface $io IO object + * @return array valid classes */ private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io) { @@ -176,8 +176,7 @@ class ClassMapGenerator $className = substr($class, $namespaceLength + 1); $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . str_replace('_', DIRECTORY_SEPARATOR, $className); - } - else { + } else { $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class); } } elseif ('psr-4' === $namespaceType) { diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index 97be1e1a2..d92cb4ac4 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -209,6 +209,7 @@ class Cache { if ($this->enabled) { $this->filesystem->emptyDirectory($this->root); + return true; } diff --git a/src/Composer/Command/CheckPlatformReqsCommand.php b/src/Composer/Command/CheckPlatformReqsCommand.php index b8fdbd78a..2f68a65cb 100644 --- a/src/Composer/Command/CheckPlatformReqsCommand.php +++ b/src/Composer/Command/CheckPlatformReqsCommand.php @@ -13,7 +13,6 @@ namespace Composer\Command; use Composer\Package\Link; -use Composer\Package\PackageInterface; use Composer\Semver\Constraint\Constraint; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 497b71680..b029b1c6d 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -16,7 +16,6 @@ use Composer\Config; use Composer\Factory; use Composer\Installer; use Composer\Installer\ProjectInstaller; -use Composer\Installer\InstallationManager; use Composer\Installer\SuggestedPackagesReporter; use Composer\IO\IOInterface; use Composer\Package\BasePackage; @@ -39,9 +38,7 @@ use Composer\Json\JsonFile; use Composer\Config\JsonConfigSource; use Composer\Util\Filesystem; use Composer\Util\ProcessExecutor; -use Composer\Util\Loop; use Composer\Package\Version\VersionParser; -use Composer\EventDispatcher\EventDispatcher; /** * Install a package as new project into new directory. diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 2385053e1..5f35fc4c5 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -677,7 +677,6 @@ EOT return !$warnings && !$errors ? true : $output; } - /** * Check if allow_url_fopen is ON * diff --git a/src/Composer/Command/FundCommand.php b/src/Composer/Command/FundCommand.php index 045eb5051..6ae37ef2d 100644 --- a/src/Composer/Command/FundCommand.php +++ b/src/Composer/Command/FundCommand.php @@ -18,7 +18,6 @@ use Composer\Package\BasePackage; use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Repository\CompositeRepository; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 885c1ba4f..30e30dcfa 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -845,7 +845,6 @@ EOT } catch (\Exception $e) { $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.'); } - } private function hasDependencies($options) diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index f4e65d1b4..f5f0c2282 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -275,6 +275,7 @@ EOT foreach ($packages as $package) { if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) { $io->writeError('Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.'); + return 2; } } diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index cf7c95664..d3310afc1 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -269,7 +269,6 @@ EOT $rootPackage->setDevRequires($links['require-dev']); } - $updateDevMode = !$input->getOption('update-no-dev'); $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader'); $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative'); diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 110fa9100..2bc36e37a 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -397,11 +397,11 @@ TAGSPUBKEY /** * Checks if the downloaded/rollback phar is valid then moves it * - * @param string $localFilename The composer.phar location - * @param string $newFilename The downloaded or backup phar - * @param string $backupTarget The filename to use for the backup + * @param string $localFilename The composer.phar location + * @param string $newFilename The downloaded or backup phar + * @param string $backupTarget The filename to use for the backup * @throws FilesystemException If the file cannot be moved - * @return bool Whether the phar is valid and has been moved + * @return bool Whether the phar is valid and has been moved */ protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null) { @@ -482,14 +482,14 @@ TAGSPUBKEY /** * Validates the downloaded/backup phar file * - * @param string $pharFile The downloaded or backup phar - * @param null|string $error Set by method on failure + * @param string $pharFile The downloaded or backup phar + * @param null|string $error Set by method on failure * * Code taken from getcomposer.org/installer. Any changes should be made * there and replicated here * - * @return bool If the operation succeeded * @throws \Exception + * @return bool If the operation succeeded */ protected function validatePhar($pharFile, &$error) { @@ -536,9 +536,9 @@ TAGSPUBKEY * * Uses a .vbs script to elevate and run the cmd.exe move command. * - * @param string $localFilename The composer.phar location - * @param string $newFilename The downloaded or backup phar - * @return bool Whether composer.phar has been updated + * @param string $localFilename The composer.phar location + * @param string $newFilename The downloaded or backup phar + * @return bool Whether composer.phar has been updated */ protected function tryAsWindowsAdmin($localFilename, $newFilename) { diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index b77853d23..2586cfc2e 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -160,6 +160,7 @@ EOT $package = $this->getComposer()->getPackage(); if ($input->getOption('name-only')) { $io->write($package->getName()); + return 0; } $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package))); @@ -207,7 +208,9 @@ EOT if ($input->getOption('no-dev')) { $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())) { @@ -798,7 +801,7 @@ EOT 'keywords' => $package->getKeywords() ?: array(), 'type' => $package->getType(), 'homepage' => $package->getHomepage(), - 'names' => $package->getNames() + 'names' => $package->getNames(), ); $json = $this->appendVersions($json, $versions); @@ -814,7 +817,7 @@ EOT $json['source'] = array( 'type' => $package->getSourceType(), 'url' => $package->getSourceUrl(), - 'reference' => $package->getSourceReference() + 'reference' => $package->getSourceReference(), ); } @@ -822,7 +825,7 @@ EOT $json['dist'] = array( 'type' => $package->getDistType(), 'url' => $package->getDistUrl(), - 'reference' => $package->getDistReference() + 'reference' => $package->getDistReference(), ); } @@ -880,7 +883,7 @@ EOT return array( 'name' => $license[0], 'osi' => $licenseId, - 'url' => $license[2] + 'url' => $license[2], ); }, $licenses); } diff --git a/src/Composer/Command/StatusCommand.php b/src/Composer/Command/StatusCommand.php index 564cd7a5d..ede91ac13 100644 --- a/src/Composer/Command/StatusCommand.php +++ b/src/Composer/Command/StatusCommand.php @@ -82,7 +82,7 @@ EOT } /** - * @param InputInterface $input + * @param InputInterface $input * @return int */ private function doExecute(InputInterface $input) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 4d9462910..60a4758f1 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -175,6 +175,7 @@ EOT if ($updateMirrors && !empty($packages)) { $io->writeError('You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.'); + return -1; } @@ -299,6 +300,7 @@ EOT $oldPrettyString = $link->getConstraint()->getPrettyString(); $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint))); $newConstraint->setPrettyString($oldPrettyString.', '.$constraint); + return new Link( $link->getSource(), $link->getTarget(), diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index 2d0c679ae..a31aff946 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -13,7 +13,6 @@ namespace Composer; use Composer\Json\JsonFile; -use Composer\Spdx\SpdxLicenses; use Composer\CaBundle\CaBundle; use Symfony\Component\Finder\Finder; use Symfony\Component\Process\Process; @@ -208,7 +207,7 @@ class Compiler array( '@package_version@' => $this->version, '@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); diff --git a/src/Composer/Config.php b/src/Composer/Config.php index ab609dd43..436de79f2 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -248,6 +248,7 @@ class Config if (false === $val) { $val = $this->config[$key]; } + return $val !== 'false' && (bool) $val; // booleans without env var support diff --git a/src/Composer/Config/ConfigSourceInterface.php b/src/Composer/Config/ConfigSourceInterface.php index 42bac5623..e1ef38de0 100644 --- a/src/Composer/Config/ConfigSourceInterface.php +++ b/src/Composer/Config/ConfigSourceInterface.php @@ -38,7 +38,7 @@ interface ConfigSourceInterface /** * Add a config setting * - * @param string $name Name + * @param string $name Name * @param string|array $value Value */ public function addConfigSetting($name, $value); diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index e3d3729d8..80cf51050 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/src/Composer/Config/JsonConfigSource.php @@ -252,7 +252,7 @@ class JsonConfigSource implements ConfigSourceInterface $this->arrayUnshiftRef($args, $config); call_user_func_array($fallback, $args); // 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()) { $config[$prop] = new \stdClass; } diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 762425272..cd78684c1 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -158,8 +158,8 @@ class Application extends BaseApplication try { $commandName = $this->find($name)->getName(); } catch (CommandNotFoundException $e) { - // we'll check command validity again later after plugins are loaded - $commandName = false; + // we'll check command validity again later after plugins are loaded + $commandName = false; } catch (\InvalidArgumentException $e) { } } diff --git a/src/Composer/Console/GithubActionError.php b/src/Composer/Console/GithubActionError.php index bbf5eaca1..c862dd9be 100644 --- a/src/Composer/Console/GithubActionError.php +++ b/src/Composer/Console/GithubActionError.php @@ -1,5 +1,15 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer\Console; use Composer\IO\IOInterface; @@ -17,9 +27,9 @@ final class GithubActionError } /** - * @param string $message + * @param string $message * @param null|string $file - * @param null|int $line + * @param null|int $line */ public function emit($message, $file = null, $line = null) { diff --git a/src/Composer/DependencyResolver/Decisions.php b/src/Composer/DependencyResolver/Decisions.php index bbf774ba9..2fdf6da74 100644 --- a/src/Composer/DependencyResolver/Decisions.php +++ b/src/Composer/DependencyResolver/Decisions.php @@ -206,6 +206,7 @@ class Decisions implements \Iterator, \Countable $str .= $packageId.':'.$level.','; } $str .= ']'; + return $str; } } diff --git a/src/Composer/DependencyResolver/LocalRepoTransaction.php b/src/Composer/DependencyResolver/LocalRepoTransaction.php index de30cc977..daefc12b9 100644 --- a/src/Composer/DependencyResolver/LocalRepoTransaction.php +++ b/src/Composer/DependencyResolver/LocalRepoTransaction.php @@ -12,14 +12,7 @@ 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\Semver\Constraint\Constraint; /** * @author Nils Adermann diff --git a/src/Composer/DependencyResolver/LockTransaction.php b/src/Composer/DependencyResolver/LockTransaction.php index 7c0d19834..f4f6d1bb8 100644 --- a/src/Composer/DependencyResolver/LockTransaction.php +++ b/src/Composer/DependencyResolver/LockTransaction.php @@ -12,13 +12,8 @@ namespace Composer\DependencyResolver; -use Composer\DependencyResolver\Operation\OperationInterface; use Composer\Package\AliasPackage; use Composer\Package\RootAliasPackage; -use Composer\Package\RootPackageInterface; -use Composer\Repository\ArrayRepository; -use Composer\Repository\RepositoryInterface; -use Composer\Test\Repository\ArrayRepositoryTest; /** * @author Nils Adermann @@ -50,7 +45,6 @@ class LockTransaction extends Transaction $this->setResultPackages($pool, $decisions); parent::__construct($this->presentMap, $this->resultPackages['all']); - } // TODO make this a bit prettier instead of the two text indexes? diff --git a/src/Composer/DependencyResolver/MultiConflictRule.php b/src/Composer/DependencyResolver/MultiConflictRule.php index 8200eef0a..60d849962 100644 --- a/src/Composer/DependencyResolver/MultiConflictRule.php +++ b/src/Composer/DependencyResolver/MultiConflictRule.php @@ -68,6 +68,7 @@ class MultiConflictRule extends Rule if ($rule instanceof MultiConflictRule) { return $this->literals === $rule->getLiterals(); } + return false; } diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php index 4c70257a3..a1aa1219f 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php @@ -13,7 +13,6 @@ namespace Composer\DependencyResolver\Operation; use Composer\Package\AliasPackage; -use Composer\Package\PackageInterface; /** * Solver install operation. diff --git a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php index 08ed93ac3..d0c193478 100644 --- a/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php +++ b/src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php @@ -13,7 +13,6 @@ namespace Composer\DependencyResolver\Operation; use Composer\Package\AliasPackage; -use Composer\Package\PackageInterface; /** * Solver install operation. diff --git a/src/Composer/DependencyResolver/Operation/OperationInterface.php b/src/Composer/DependencyResolver/Operation/OperationInterface.php index 363cf35a2..b0cc29b6d 100644 --- a/src/Composer/DependencyResolver/Operation/OperationInterface.php +++ b/src/Composer/DependencyResolver/Operation/OperationInterface.php @@ -29,7 +29,7 @@ interface OperationInterface /** * Serializes the operation in a human readable format * - * @param bool $lock Whether this is an operation on the lock file + * @param bool $lock Whether this is an operation on the lock file * @return string */ public function show($lock); diff --git a/src/Composer/DependencyResolver/Operation/SolverOperation.php b/src/Composer/DependencyResolver/Operation/SolverOperation.php index e1a78da84..7ab87fe8a 100644 --- a/src/Composer/DependencyResolver/Operation/SolverOperation.php +++ b/src/Composer/DependencyResolver/Operation/SolverOperation.php @@ -12,8 +12,6 @@ namespace Composer\DependencyResolver\Operation; -use Composer\Package\PackageInterface; - /** * Abstract operation class. * diff --git a/src/Composer/DependencyResolver/PolicyInterface.php b/src/Composer/DependencyResolver/PolicyInterface.php index 49e23b041..b10a43e9f 100644 --- a/src/Composer/DependencyResolver/PolicyInterface.php +++ b/src/Composer/DependencyResolver/PolicyInterface.php @@ -20,5 +20,6 @@ use Composer\Package\PackageInterface; interface PolicyInterface { public function versionCompare(PackageInterface $a, PackageInterface $b, $operator); + public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null); } diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index 195864599..23d412ac4 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -12,7 +12,6 @@ namespace Composer\DependencyResolver; -use Composer\Package\AliasPackage; use Composer\Package\Version\VersionParser; use Composer\Semver\CompilingMatcher; use Composer\Semver\Constraint\ConstraintInterface; @@ -82,9 +81,9 @@ class Pool implements \Countable /** * Searches all packages providing the given package name and match the constraint * - * @param string $name The package name to be searched for - * @param ConstraintInterface $constraint A constraint that all returned - * packages must match or null to return all + * @param string $name The package name to be searched for + * @param ConstraintInterface $constraint A constraint that all returned + * packages must match or null to return all * @return PackageInterface[] A set of packages */ public function whatProvides($name, ConstraintInterface $constraint = null) @@ -141,9 +140,9 @@ class Pool implements \Countable * Checks if the package matches the given constraint directly or through * provided or replaced packages * - * @param PackageInterface $candidate - * @param string $name Name of the package to be matched - * @param ConstraintInterface $constraint The constraint to verify + * @param PackageInterface $candidate + * @param string $name Name of the package to be matched + * @param ConstraintInterface $constraint The constraint to verify * @return bool */ public function match($candidate, $name, ConstraintInterface $constraint = null) diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index ccd3e9dde..174821da9 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -281,6 +281,7 @@ class PoolBuilder } $this->packagesToLoad[$name] = $constraint; + return; } @@ -420,6 +421,7 @@ class PoolBuilder private function isRootRequire(Request $request, $name) { $rootRequires = $request->getRequires(); + return isset($rootRequires[$name]); } @@ -503,4 +505,3 @@ class PoolBuilder } } } - diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 327874b26..7e8cce33f 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -156,7 +156,7 @@ class Problem * Store a reason descriptor but ignore duplicates * * @param string $id A canonical identifier for the reason - * @param Rule $reason The reason descriptor + * @param Rule $reason The reason descriptor */ protected function addReason($id, Rule $reason) { @@ -304,11 +304,13 @@ class Problem $maxProviders = 20; $providersStr = implode(array_map(function ($p) { $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : ''; + return " - ${p['name']}".$description."\n"; - }, count($providers) > $maxProviders+1 ? array_slice($providers, 0, $maxProviders) : $providers)); - if (count($providers) > $maxProviders+1) { - $providersStr .= ' ... and '.(count($providers)-$maxProviders).' more.'."\n"; + }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers)); + if (count($providers) > $maxProviders + 1) { + $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."); } @@ -347,7 +349,7 @@ class Problem } /** - * @param string[] $versions an array of pretty versions, with normalized versions as keys + * @param string[] $versions an array of pretty versions, with normalized versions as keys * @return list a list of pretty versions and '...' where versions were removed */ private static function condenseVersionList(array $versions, $max) @@ -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.'); - } /** diff --git a/src/Composer/DependencyResolver/Request.php b/src/Composer/DependencyResolver/Request.php index 01753ee55..5167ce63c 100644 --- a/src/Composer/DependencyResolver/Request.php +++ b/src/Composer/DependencyResolver/Request.php @@ -14,7 +14,6 @@ namespace Composer\DependencyResolver; use Composer\Package\Package; use Composer\Package\PackageInterface; -use Composer\Package\RootAliasPackage; use Composer\Repository\LockArrayRepository; use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\MatchAllConstraint; diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index 7e1311a76..eb0f6e296 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -12,7 +12,6 @@ namespace Composer\DependencyResolver; -use Composer\Package\CompletePackage; use Composer\Package\Link; use Composer\Package\PackageInterface; 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) . '.'; 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 - if (isset($learnedPool[$this->reasonData])) { - echo $this->reasonData."\n"; - $learnedString = ', learned rules:' . Problem::formatDeduplicatedRules($learnedPool[$this->reasonData], ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool); - } else { - $learnedString = ' (reasoning unavailable)'; - } - */ + /** @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])) { + // echo $this->reasonData."\n"; + // $learnedString = ', learned rules:' . Problem::formatDeduplicatedRules($learnedPool[$this->reasonData], ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool); + // } else { + // $learnedString = ' (reasoning unavailable)'; + // } $learnedString = ' (conflict analysis result)'; if (count($literals) === 1) { diff --git a/src/Composer/DependencyResolver/RuleSetGenerator.php b/src/Composer/DependencyResolver/RuleSetGenerator.php index 3744bdd2a..edd492b4e 100644 --- a/src/Composer/DependencyResolver/RuleSetGenerator.php +++ b/src/Composer/DependencyResolver/RuleSetGenerator.php @@ -12,11 +12,9 @@ namespace Composer\DependencyResolver; -use Composer\Package\LinkConstraint\VersionConstraint; use Composer\Package\PackageInterface; use Composer\Package\AliasPackage; use Composer\Repository\PlatformRepository; -use Composer\Semver\Constraint\Constraint; /** * @author Nils Adermann @@ -49,7 +47,7 @@ class RuleSetGenerator * reason for generating this rule * @param mixed $reasonData Any data, e.g. the requirement name, * that goes with the reason - * @return Rule|null The generated rule or null if tautological + * @return Rule|null The generated rule or null if tautological */ protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null) { @@ -72,9 +70,9 @@ class RuleSetGenerator * The rule is (A|B|C) with A, B and C different packages. If the given * set of packages is empty an impossible rule is generated. * - * @param array $packages The set of packages to choose from - * @param int $reason A RULE_* constant describing the reason for - * generating this rule + * @param array $packages The set of packages to choose from + * @param int $reason A RULE_* constant describing the reason for + * generating this rule * @param array $reasonData Additional data like the root require or fix request info * @return Rule The generated rule */ @@ -100,7 +98,7 @@ class RuleSetGenerator * reason for generating this rule * @param mixed $reasonData Any data, e.g. the package name, that * goes with the reason - * @return Rule|null The generated rule + * @return Rule|null The generated rule */ protected function createRule2Literals(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null) { diff --git a/src/Composer/DependencyResolver/RuleWatchGraph.php b/src/Composer/DependencyResolver/RuleWatchGraph.php index e7fae0c61..42bcfd551 100644 --- a/src/Composer/DependencyResolver/RuleWatchGraph.php +++ b/src/Composer/DependencyResolver/RuleWatchGraph.php @@ -61,7 +61,6 @@ class RuleWatchGraph $this->watchChains[$literal]->unshift($node); } } - } /** @@ -151,8 +150,8 @@ class RuleWatchGraph * The rule node's watched literals are updated accordingly. * * @param int $fromLiteral A literal the node used to watch - * @param int $toLiteral A literal the node should watch now - * @param RuleWatchNode $node The rule node to be moved + * @param int $toLiteral A literal the node should watch now + * @param RuleWatchNode $node The rule node to be moved */ protected function moveWatch($fromLiteral, $toLiteral, $node) { diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 63fc1577c..4b5330923 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -15,7 +15,6 @@ namespace Composer\DependencyResolver; use Composer\IO\IOInterface; use Composer\Package\PackageInterface; use Composer\Repository\PlatformRepository; -use Composer\Semver\Constraint\MultiConstraint; /** * @author Nils Adermann @@ -58,9 +57,9 @@ class Solver protected $io; /** - * @param PolicyInterface $policy - * @param Pool $pool - * @param IOInterface $io + * @param PolicyInterface $policy + * @param Pool $pool + * @param IOInterface $io */ public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io) { @@ -182,8 +181,8 @@ class Solver } /** - * @param Request $request - * @param bool|array $ignorePlatformReqs + * @param Request $request + * @param bool|array $ignorePlatformReqs * @return LockTransaction */ public function solve(Request $request, $ignorePlatformReqs = false) diff --git a/src/Composer/DependencyResolver/Transaction.php b/src/Composer/DependencyResolver/Transaction.php index 3d662166a..66b9b9a3e 100644 --- a/src/Composer/DependencyResolver/Transaction.php +++ b/src/Composer/DependencyResolver/Transaction.php @@ -68,6 +68,7 @@ class Transaction // 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->getName(), $a->getName()); }; @@ -230,6 +231,7 @@ class Transaction if (!isset($this->resultPackagesByName[$link->getTarget()])) { return array(); } + return $this->resultPackagesByName[$link->getTarget()]; } diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index e525a1f77..5bfd5cb18 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -14,8 +14,6 @@ namespace Composer\Downloader; use Composer\Package\PackageInterface; use Symfony\Component\Finder\Finder; -use Composer\IO\IOInterface; -use Composer\Exception\IrrecoverableDownloadException; use React\Promise\PromiseInterface; use Composer\DependencyResolver\Operation\InstallOperation; @@ -28,7 +26,6 @@ use Composer\DependencyResolver\Operation\InstallOperation; */ abstract class ArchiveDownloader extends FileDownloader { - /** * {@inheritDoc} * @throws \RuntimeException @@ -158,8 +155,8 @@ abstract class ArchiveDownloader extends FileDownloader * @param string $file Extracted file * @param string $path Directory * - * @return PromiseInterface|null * @throws \UnexpectedValueException If can not extract downloaded file to path + * @return PromiseInterface|null */ abstract protected function extract(PackageInterface $package, $file, $path); } diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index 54c3d0e2f..aebbf5039 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -41,9 +41,9 @@ class DownloadManager /** * Initializes download manager. * - * @param IOInterface $io The Input Output Interface - * @param bool $preferSource prefer downloading from source - * @param Filesystem|null $filesystem custom Filesystem object + * @param IOInterface $io The Input Output Interface + * @param bool $preferSource prefer downloading from source + * @param Filesystem|null $filesystem custom Filesystem object */ public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null) { @@ -171,13 +171,13 @@ class DownloadManager /** * Downloads package into target dir. * - * @param PackageInterface $package package instance - * @param string $targetDir target dir - * @param PackageInterface|null $prevPackage previous package instance in case of updates + * @param PackageInterface $package package instance + * @param string $targetDir target dir + * @param PackageInterface|null $prevPackage previous package instance in case of updates * - * @return PromiseInterface * @throws \InvalidArgumentException if package have no urls to download from * @throws \RuntimeException + * @return PromiseInterface */ public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null) { @@ -242,10 +242,10 @@ class DownloadManager /** * Prepares an operation execution * - * @param string $type one of install/update/uninstall - * @param PackageInterface $package package instance - * @param string $targetDir target dir - * @param PackageInterface|null $prevPackage previous package instance in case of updates + * @param string $type one of install/update/uninstall + * @param PackageInterface $package package instance + * @param string $targetDir target dir + * @param PackageInterface|null $prevPackage previous package instance in case of updates * * @return PromiseInterface|null */ @@ -261,12 +261,12 @@ class DownloadManager /** * Installs package into target dir. * - * @param PackageInterface $package package instance - * @param string $targetDir target dir + * @param PackageInterface $package package instance + * @param string $targetDir target dir * - * @return PromiseInterface|null * @throws \InvalidArgumentException if package have no urls to download from * @throws \RuntimeException + * @return PromiseInterface|null */ public function install(PackageInterface $package, $targetDir) { @@ -284,8 +284,8 @@ class DownloadManager * @param PackageInterface $target target package version * @param string $targetDir target dir * - * @return PromiseInterface|null * @throws \InvalidArgumentException if initial package is not installed + * @return PromiseInterface|null */ public function update(PackageInterface $initial, PackageInterface $target, $targetDir) { @@ -324,6 +324,7 @@ class DownloadManager $promise = $initialDownloader->remove($initial, $targetDir); if ($promise) { $self = $this; + return $promise->then(function ($res) use ($self, $target, $targetDir) { return $self->install($target, $targetDir); }); @@ -352,10 +353,10 @@ class DownloadManager /** * Cleans up a failed operation * - * @param string $type one of install/update/uninstall - * @param PackageInterface $package package instance - * @param string $targetDir target dir - * @param PackageInterface|null $prevPackage previous package instance in case of updates + * @param string $type one of install/update/uninstall + * @param PackageInterface $package package instance + * @param string $targetDir target dir + * @param PackageInterface|null $prevPackage previous package instance in case of updates * * @return PromiseInterface|null */ diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index 1fd183650..3ca7eb9e4 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/src/Composer/Downloader/FileDownloader.php @@ -29,7 +29,6 @@ use Composer\Util\Filesystem; use Composer\Util\HttpDownloader; use Composer\Util\Url as UrlUtil; use Composer\Util\ProcessExecutor; -use Composer\Downloader\TransportException; use React\Promise\PromiseInterface; /** @@ -65,12 +64,12 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface /** * Constructor. * - * @param IOInterface $io The IO instance - * @param Config $config The config - * @param HttpDownloader $httpDownloader The remote filesystem - * @param EventDispatcher $eventDispatcher The event dispatcher - * @param Cache $cache Cache instance - * @param Filesystem $filesystem The filesystem + * @param IOInterface $io The IO instance + * @param Config $config The config + * @param HttpDownloader $httpDownloader The remote filesystem + * @param EventDispatcher $eventDispatcher The event dispatcher + * @param Cache $cache Cache instance + * @param Filesystem $filesystem The filesystem */ public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null) { @@ -121,7 +120,7 @@ class FileDownloader implements DownloaderInterface, ChangeReportInterface // 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 // 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); if ($preFileDownloadEvent->getCustomCacheKey() !== null) { $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey()); - } else if ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) { + } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) { $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl()); } $url['processed'] = $preFileDownloadEvent->getProcessedUrl(); diff --git a/src/Composer/Downloader/FossilDownloader.php b/src/Composer/Downloader/FossilDownloader.php index 2ec2ea2c5..a597d51d5 100644 --- a/src/Composer/Downloader/FossilDownloader.php +++ b/src/Composer/Downloader/FossilDownloader.php @@ -25,7 +25,6 @@ class FossilDownloader extends VcsDownloader */ protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) { - } /** diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 9adb5875d..3c6342849 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -488,7 +488,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface } /** - * @param string $path + * @param string $path * @throws \RuntimeException */ protected function discardChanges($path) @@ -502,7 +502,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface } /** - * @param string $path + * @param string $path * @throws \RuntimeException */ protected function stashChanges($path) @@ -516,7 +516,7 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface } /** - * @param string $path + * @param string $path * @throws \RuntimeException */ protected function viewDiff($path) diff --git a/src/Composer/Downloader/GzipDownloader.php b/src/Composer/Downloader/GzipDownloader.php index 3ebff597a..04dd5e7ed 100644 --- a/src/Composer/Downloader/GzipDownloader.php +++ b/src/Composer/Downloader/GzipDownloader.php @@ -12,15 +12,9 @@ namespace Composer\Downloader; -use Composer\Config; -use Composer\Cache; -use Composer\EventDispatcher\EventDispatcher; use Composer\Package\PackageInterface; use Composer\Util\Platform; use Composer\Util\ProcessExecutor; -use Composer\Util\HttpDownloader; -use Composer\IO\IOInterface; -use Composer\Util\Filesystem; /** * GZip archive downloader. diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php index 91144a13d..59ced0193 100644 --- a/src/Composer/Downloader/HgDownloader.php +++ b/src/Composer/Downloader/HgDownloader.php @@ -26,7 +26,6 @@ class HgDownloader extends VcsDownloader */ protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) { - } /** diff --git a/src/Composer/Downloader/MaxFileSizeExceededException.php b/src/Composer/Downloader/MaxFileSizeExceededException.php index f50b52e79..b7adad1b6 100644 --- a/src/Composer/Downloader/MaxFileSizeExceededException.php +++ b/src/Composer/Downloader/MaxFileSizeExceededException.php @@ -1,5 +1,15 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer\Downloader; class MaxFileSizeExceededException extends TransportException diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index 77598f71d..33c65b4fb 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -18,16 +18,9 @@ use Composer\Package\PackageInterface; use Composer\Package\Version\VersionGuesser; use Composer\Package\Version\VersionParser; 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\EventDispatcher\EventDispatcher; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem; -use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\InstallOperation; use Composer\DependencyResolver\Operation\UninstallOperation; diff --git a/src/Composer/Downloader/PerforceDownloader.php b/src/Composer/Downloader/PerforceDownloader.php index f5965f0d7..0b9e7a683 100644 --- a/src/Composer/Downloader/PerforceDownloader.php +++ b/src/Composer/Downloader/PerforceDownloader.php @@ -29,7 +29,6 @@ class PerforceDownloader extends VcsDownloader */ protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) { - } /** diff --git a/src/Composer/Downloader/RarDownloader.php b/src/Composer/Downloader/RarDownloader.php index b0484b661..8951d9636 100644 --- a/src/Composer/Downloader/RarDownloader.php +++ b/src/Composer/Downloader/RarDownloader.php @@ -12,15 +12,9 @@ namespace Composer\Downloader; -use Composer\Config; -use Composer\Cache; -use Composer\EventDispatcher\EventDispatcher; use Composer\Util\IniHelper; use Composer\Util\Platform; use Composer\Util\ProcessExecutor; -use Composer\Util\HttpDownloader; -use Composer\Util\Filesystem; -use Composer\IO\IOInterface; use Composer\Package\PackageInterface; use RarArchive; diff --git a/src/Composer/Downloader/SvnDownloader.php b/src/Composer/Downloader/SvnDownloader.php index f73737a7c..2f253b4bd 100644 --- a/src/Composer/Downloader/SvnDownloader.php +++ b/src/Composer/Downloader/SvnDownloader.php @@ -30,7 +30,6 @@ class SvnDownloader extends VcsDownloader */ protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null) { - } /** diff --git a/src/Composer/Downloader/XzDownloader.php b/src/Composer/Downloader/XzDownloader.php index b043af333..9431d4fa0 100644 --- a/src/Composer/Downloader/XzDownloader.php +++ b/src/Composer/Downloader/XzDownloader.php @@ -12,14 +12,8 @@ namespace Composer\Downloader; -use Composer\Config; -use Composer\Cache; -use Composer\EventDispatcher\EventDispatcher; use Composer\Package\PackageInterface; use Composer\Util\ProcessExecutor; -use Composer\Util\HttpDownloader; -use Composer\IO\IOInterface; -use Composer\Util\Filesystem; /** * Xz archive downloader. diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 8376929e4..d496ef446 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -12,16 +12,10 @@ namespace Composer\Downloader; -use Composer\Config; -use Composer\Cache; -use Composer\EventDispatcher\EventDispatcher; use Composer\Package\PackageInterface; use Composer\Util\IniHelper; use Composer\Util\Platform; use Composer\Util\ProcessExecutor; -use Composer\Util\Filesystem; -use Composer\Util\HttpDownloader; -use Composer\IO\IOInterface; use Symfony\Component\Process\ExecutableFinder; use ZipArchive; @@ -75,9 +69,9 @@ class ZipDownloader extends ArchiveDownloader /** * extract $file to $path with "unzip" command * - * @param string $file File to extract - * @param string $path Path where to extract file - * @param bool $isLastChance If true it is called as a fallback and should throw an exception + * @param string $file File to extract + * @param string $path Path where to extract file + * @param bool $isLastChance If true it is called as a fallback and should throw an exception */ private function extractWithSystemUnzip(PackageInterface $package, $file, $path, $isLastChance, $async = false) { @@ -160,9 +154,9 @@ class ZipDownloader extends ArchiveDownloader /** * extract $file to $path with ZipArchive * - * @param string $file File to extract - * @param string $path Path where to extract file - * @param bool $isLastChance If true it is called as a fallback and should throw an exception + * @param string $file File to extract + * @param string $path Path where to extract file + * @param bool $isLastChance If true it is called as a fallback and should throw an exception * * TODO v3 should make this private once we can drop PHP 5.3 support * @protected diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index c28f99bf6..be53cab9d 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -121,10 +121,10 @@ class EventDispatcher /** * Dispatch a installer event. * - * @param string $eventName The constant in InstallerEvents - * @param bool $devMode Whether or not we are in dev mode - * @param bool $executeOperations True if operations will be executed, false in --dry-run - * @param Transaction $transaction The transaction contains the list of operations + * @param string $eventName The constant in InstallerEvents + * @param bool $devMode Whether or not we are in dev mode + * @param bool $executeOperations True if operations will be executed, false in --dry-run + * @param Transaction $transaction The transaction contains the list of operations * * @return int return code of the executed script if any, for php scripts a false return * value is changed to 1, anything else to 0 @@ -158,7 +158,6 @@ class EventDispatcher $return = 0; foreach ($listeners as $callable) { - $this->ensureBinDirIsInPath(); 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'); } 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; } elseif ($this->isComposerScript($callable)) { diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index aa1052887..07211165c 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -427,8 +427,8 @@ class Factory } /** - * @param IOInterface $io IO instance - * @param bool $disablePlugins Whether plugins should not be loaded + * @param IOInterface $io IO instance + * @param bool $disablePlugins Whether plugins should not be loaded * @return Composer|null */ public static function createGlobal(IOInterface $io, $disablePlugins = false) @@ -598,9 +598,9 @@ class Factory /** * If you are calling this in a plugin, you probably should instead use $composer->getLoop()->getHttpDownloader() * - * @param IOInterface $io IO instance - * @param Config $config Config instance - * @param array $options Array of options passed directly to HttpDownloader constructor + * @param IOInterface $io IO instance + * @param Config $config Config instance + * @param array $options Array of options passed directly to HttpDownloader constructor * @return HttpDownloader */ public static function createHttpDownloader(IOInterface $io, Config $config, $options = array()) diff --git a/src/Composer/IO/ConsoleIO.php b/src/Composer/IO/ConsoleIO.php index ebe38f26a..d756d9b9d 100644 --- a/src/Composer/IO/ConsoleIO.php +++ b/src/Composer/IO/ConsoleIO.php @@ -255,7 +255,7 @@ class ConsoleIO extends BaseIO } /** - * @param int $max + * @param int $max * @return ProgressBar */ public function getProgressBar($max = 0) diff --git a/src/Composer/IO/IOInterface.php b/src/Composer/IO/IOInterface.php index 0ba1cf932..fd2a2d503 100644 --- a/src/Composer/IO/IOInterface.php +++ b/src/Composer/IO/IOInterface.php @@ -179,7 +179,7 @@ interface IOInterface extends LoggerInterface * @param bool $multiselect Select more than one value separated by comma * * @throws \InvalidArgumentException - * @return int|string|array|bool The selected value or values (the key of the choices array) + * @return int|string|array|bool The selected value or values (the key of the choices array) */ public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false); diff --git a/src/Composer/InstalledVersions.php b/src/Composer/InstalledVersions.php index 7bf2c0686..e492f988a 100644 --- a/src/Composer/InstalledVersions.php +++ b/src/Composer/InstalledVersions.php @@ -1,5 +1,15 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer; use Composer\Semver\VersionParser; diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 47058694b..2f52de0f3 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -20,19 +20,14 @@ use Composer\DependencyResolver\LockTransaction; use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\InstallOperation; 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\Request; -use Composer\DependencyResolver\Rule; use Composer\DependencyResolver\Solver; use Composer\DependencyResolver\SolverProblemsException; use Composer\Downloader\DownloadManager; use Composer\EventDispatcher\EventDispatcher; use Composer\Installer\InstallationManager; use Composer\Installer\InstallerEvents; -use Composer\Installer\NoopInstaller; use Composer\Installer\SuggestedPackagesReporter; use Composer\IO\IOInterface; use Composer\Package\AliasPackage; @@ -41,7 +36,6 @@ use Composer\Package\BasePackage; use Composer\Package\CompletePackage; use Composer\Package\CompletePackageInterface; use Composer\Package\Link; -use Composer\Package\LinkConstraint\VersionConstraint; use Composer\Package\Loader\ArrayLoader; use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Version\VersionParser; @@ -50,9 +44,7 @@ use Composer\Repository\ArrayRepository; use Composer\Repository\RepositorySet; use Composer\Semver\Constraint\Constraint; use Composer\Package\Locker; -use Composer\Package\PackageInterface; use Composer\Package\RootPackageInterface; -use Composer\Repository\CompositeRepository; use Composer\Repository\InstalledArrayRepository; use Composer\Repository\InstalledRepositoryInterface; use Composer\Repository\InstalledRepository; @@ -376,6 +368,7 @@ class Installer if ($this->updateAllowList) { if (!$lockedRepository) { $this->io->writeError('Cannot update only a partial set of packages without a lock file present.', true, IOInterface::QUIET); + return 1; } } @@ -612,9 +605,9 @@ class Installer } /** - * @param InstalledRepositoryInterface $localRepo - * @param bool $alreadySolved Whether the function is called as part of an update command or independently - * @return int exit code + * @param InstalledRepositoryInterface $localRepo + * @param bool $alreadySolved Whether the function is called as part of an update command or independently + * @return int exit code */ protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false) { @@ -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 if (0 !== count($lockTransaction->getOperations())) { $this->io->writeError('Your lock file cannot be installed on this system without changes. Please run composer update.', true, IOInterface::QUIET); + return 1; } } catch (SolverProblemsException $e) { @@ -743,10 +737,10 @@ class Installer } /** - * @param bool $forUpdate - * @param PlatformRepository $platformRepo - * @param array $rootAliases - * @param RepositoryInterface|null $lockedRepository + * @param bool $forUpdate + * @param PlatformRepository $platformRepo + * @param array $rootAliases + * @param RepositoryInterface|null $lockedRepository * @return RepositorySet */ private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null) @@ -821,9 +815,9 @@ class Installer } /** - * @param RootPackageInterface $rootPackage - * @param PlatformRepository $platformRepo - * @param RepositoryInterface|null $lockedRepository + * @param RootPackageInterface $rootPackage + * @param PlatformRepository $platformRepo + * @param RepositoryInterface|null $lockedRepository * @return Request */ private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, $lockedRepository = null) @@ -858,7 +852,7 @@ class Installer } /** - * @param bool $forUpdate + * @param bool $forUpdate * @return array */ private function getRootAliases($forUpdate) @@ -1176,7 +1170,7 @@ class Installer /** * Update the lock file to the exact same versions and references but use current remote metadata like URLs and mirror info * - * @param bool $updateMirrors + * @param bool $updateMirrors * @return Installer */ public function setUpdateMirrors($updateMirrors) @@ -1206,7 +1200,7 @@ class Installer * Depending on the chosen constant this will either only update the directly named packages, all transitive * dependencies which are not root requirement or all transitive dependencies including root requirements * - * @param int $updateAllowTransitiveDependencies One of the UPDATE_ constants on the Request class + * @param int $updateAllowTransitiveDependencies One of the UPDATE_ constants on the Request class * @return Installer */ public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies) diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index 820749ce4..f8a0e5708 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -25,7 +25,6 @@ use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation; use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation; use Composer\EventDispatcher\EventDispatcher; -use Composer\Util\StreamContextFactory; use Composer\Util\Loop; use React\Promise\PromiseInterface; @@ -293,7 +292,7 @@ class InstallationManager } /** - * @param array $operations List of operations to execute in this batch + * @param array $operations List of operations to execute in this batch * @param array $allOperations Complete list of operations to be executed in the install job, used for event listeners */ private function downloadAndExecuteBatch(RepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations) @@ -370,7 +369,7 @@ class InstallationManager } /** - * @param array $operations List of operations to execute in this batch + * @param array $operations List of operations to execute in this batch * @param array $allOperations Complete list of operations to be executed in the install job, used for event listeners */ private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations) diff --git a/src/Composer/Installer/InstallerEvent.php b/src/Composer/Installer/InstallerEvent.php index 1b8f03de4..ee81754d9 100644 --- a/src/Composer/Installer/InstallerEvent.php +++ b/src/Composer/Installer/InstallerEvent.php @@ -13,13 +13,9 @@ namespace Composer\Installer; use Composer\Composer; -use Composer\DependencyResolver\PolicyInterface; -use Composer\DependencyResolver\Request; -use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Transaction; use Composer\EventDispatcher\Event; use Composer\IO\IOInterface; -use Composer\Repository\RepositorySet; class InstallerEvent extends Event { @@ -51,12 +47,12 @@ class InstallerEvent extends Event /** * Constructor. * - * @param string $eventName - * @param Composer $composer - * @param IOInterface $io - * @param bool $devMode - * @param bool $executeOperations - * @param Transaction $transaction + * @param string $eventName + * @param Composer $composer + * @param IOInterface $io + * @param bool $devMode + * @param bool $executeOperations + * @param Transaction $transaction */ public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction) { diff --git a/src/Composer/Installer/InstallerInterface.php b/src/Composer/Installer/InstallerInterface.php index 2a631e4ed..f664a3ab4 100644 --- a/src/Composer/Installer/InstallerInterface.php +++ b/src/Composer/Installer/InstallerInterface.php @@ -82,9 +82,8 @@ interface InstallerInterface * @param InstalledRepositoryInterface $repo repository in which to check * @param PackageInterface $initial already installed package version * @param PackageInterface $target updated version + * @throws InvalidArgumentException if $initial package is not installed * @return PromiseInterface|null - * - * @throws InvalidArgumentException if $initial package is not installed */ public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target); diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 3c916fc12..fd1848f68 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -139,6 +139,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface $binaryInstaller = $this->binaryInstaller; $installPath = $this->getInstallPath($package); + return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) { $binaryInstaller->installBinaries($package, $installPath); if (!$repo->hasPackage($package)) { @@ -166,6 +167,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface $binaryInstaller = $this->binaryInstaller; $installPath = $this->getInstallPath($target); + return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) { $binaryInstaller->installBinaries($target, $installPath); $repo->removePackage($initial); @@ -192,6 +194,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface $binaryInstaller = $this->binaryInstaller; $downloadPath = $this->getPackageBasePath($package); $filesystem = $this->filesystem; + return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) { $binaryInstaller->removeBinaries($package); $repo->removePackage($package); @@ -252,6 +255,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface protected function installCode(PackageInterface $package) { $downloadPath = $this->getInstallPath($package); + return $this->downloadManager->install($package, $downloadPath); } @@ -271,6 +275,7 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface } $self = $this; + return $promise->then(function () use ($self, $target) { $reflMethod = new \ReflectionMethod($self, 'installCode'); $reflMethod->setAccessible(true); @@ -283,12 +288,14 @@ class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface $this->filesystem->rename($initialDownloadPath, $targetDownloadPath); } + return $this->downloadManager->update($initial, $target, $targetDownloadPath); } protected function removeCode(PackageInterface $package) { $downloadPath = $this->getPackageBasePath($package); + return $this->downloadManager->remove($package, $downloadPath); } diff --git a/src/Composer/Installer/MetapackageInstaller.php b/src/Composer/Installer/MetapackageInstaller.php index fb07e9bb1..e9933cec5 100644 --- a/src/Composer/Installer/MetapackageInstaller.php +++ b/src/Composer/Installer/MetapackageInstaller.php @@ -14,7 +14,6 @@ namespace Composer\Installer; use Composer\Repository\InstalledRepositoryInterface; use Composer\Package\PackageInterface; -use Composer\Package\Version\VersionParser; use Composer\IO\IOInterface; use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\InstallOperation; diff --git a/src/Composer/Installer/PackageEvent.php b/src/Composer/Installer/PackageEvent.php index c8ec333ba..ac9145943 100644 --- a/src/Composer/Installer/PackageEvent.php +++ b/src/Composer/Installer/PackageEvent.php @@ -15,10 +15,7 @@ namespace Composer\Installer; use Composer\Composer; use Composer\IO\IOInterface; use Composer\DependencyResolver\Operation\OperationInterface; -use Composer\DependencyResolver\PolicyInterface; -use Composer\DependencyResolver\Request; use Composer\Repository\RepositoryInterface; -use Composer\Repository\RepositorySet; use Composer\EventDispatcher\Event; /** diff --git a/src/Composer/Installer/PluginInstaller.php b/src/Composer/Installer/PluginInstaller.php index 5a9a8d3bf..ba009ab1b 100644 --- a/src/Composer/Installer/PluginInstaller.php +++ b/src/Composer/Installer/PluginInstaller.php @@ -71,6 +71,7 @@ class PluginInstaller extends LibraryInstaller $pluginManager = $this->composer->getPluginManager(); $self = $this; + return $promise->then(function () use ($self, $pluginManager, $package, $repo) { try { $pluginManager->registerPackage($package, true); @@ -92,6 +93,7 @@ class PluginInstaller extends LibraryInstaller $pluginManager = $this->composer->getPluginManager(); $self = $this; + return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) { try { $pluginManager->deactivatePackage($initial, true); diff --git a/src/Composer/Installer/SuggestedPackagesReporter.php b/src/Composer/Installer/SuggestedPackagesReporter.php index 56fe4599f..1134fb9b6 100644 --- a/src/Composer/Installer/SuggestedPackagesReporter.php +++ b/src/Composer/Installer/SuggestedPackagesReporter.php @@ -182,8 +182,8 @@ class SuggestedPackagesReporter } /** - * @param InstalledRepository|null $installedRepo If passed in, suggested packages which are installed already will be skipped - * @param PackageInterface|null $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown + * @param InstalledRepository|null $installedRepo If passed in, suggested packages which are installed already will be skipped + * @param PackageInterface|null $onlyDependentsOf If passed in, only the suggestions from direct dependents of that package, or from the package itself, will be shown * @return array[] */ private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 1e30690c1..c3279f82e 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -164,7 +164,7 @@ class JsonFile /** * Validates the schema of the current json file according to composer-schema.json rules * - * @param int $schema a JsonFile::*_SCHEMA constant + * @param int $schema a JsonFile::*_SCHEMA constant * @param string|null $schemaFile a path to the schema file * @throws JsonValidationException * @return bool true on success diff --git a/src/Composer/Package/AliasPackage.php b/src/Composer/Package/AliasPackage.php index bd33c4fff..4a304e3dc 100644 --- a/src/Composer/Package/AliasPackage.php +++ b/src/Composer/Package/AliasPackage.php @@ -431,7 +431,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface 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) diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index ecfa7a537..2bf2cc1b4 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -258,7 +258,7 @@ abstract class BasePackage implements PackageInterface * Build a regexp from a package name, expanding * globs as required * * @param string $allowPattern - * @param string $wrap Wrap the cleaned string by the given string + * @param string $wrap Wrap the cleaned string by the given string * @return string */ public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i') diff --git a/src/Composer/Package/Link.php b/src/Composer/Package/Link.php index 03dd652f4..db8e0f4ad 100644 --- a/src/Composer/Package/Link.php +++ b/src/Composer/Package/Link.php @@ -70,12 +70,12 @@ class Link /** * Creates a new package link. * - * @param string $source - * @param string $target - * @param ConstraintInterface $constraint Constraint applying to the target of this link - * @param string $description Used to create a descriptive string representation + * @param string $source + * @param string $target + * @param ConstraintInterface $constraint Constraint applying to the target of this link + * @param string $description Used to create a descriptive string representation * @phpstan-param self::TYPE_* $description - * @param string|null $prettyConstraint + * @param string|null $prettyConstraint */ public function __construct( $source, diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index bbdd35886..f73ebad20 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -295,11 +295,11 @@ class ArrayLoader implements LoaderInterface } /** - * @param string $source source package name - * @param string $sourceVersion source package version (pretty version ideally) - * @param string $description link description (e.g. requires, replaces, ..) + * @param string $source source package name + * @param string $sourceVersion source package version (pretty version ideally) + * @param string $description link description (e.g. requires, replaces, ..) * @phpstan-param Link::TYPE_* $description - * @param array $links array of package name => constraint mappings + * @param array $links array of package name => constraint mappings * @return Link[] */ public function parseLinks($source, $sourceVersion, $description, $links) diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 9ddf6d0fa..5f485fd03 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -15,7 +15,6 @@ namespace Composer\Package; use Composer\Json\JsonFile; use Composer\Installer\InstallationManager; use Composer\Repository\LockArrayRepository; -use Composer\Repository\RepositoryManager; use Composer\Util\ProcessExecutor; use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Loader\ArrayLoader; @@ -334,6 +333,7 @@ class Locker if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) { $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS; } + return $alias; }, $aliases); diff --git a/src/Composer/Package/PackageInterface.php b/src/Composer/Package/PackageInterface.php index bf94efc5c..34dab77c0 100644 --- a/src/Composer/Package/PackageInterface.php +++ b/src/Composer/Package/PackageInterface.php @@ -203,7 +203,7 @@ interface PackageInterface * * @see getPrettyVersion * - * @param bool $truncate If the source reference is a sha1 hash, truncate it + * @param bool $truncate If the source reference is a sha1 hash, truncate it * @param int $displayMode One of the DISPLAY_ constants on this interface determining display of references * @return string version * diff --git a/src/Composer/Package/Version/StabilityFilter.php b/src/Composer/Package/Version/StabilityFilter.php index df8c4bc16..9ea44cdda 100644 --- a/src/Composer/Package/Version/StabilityFilter.php +++ b/src/Composer/Package/Version/StabilityFilter.php @@ -26,9 +26,9 @@ class StabilityFilter * @psalm-param array $acceptableStabilities * @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value * @psalm-param array $stabilityFlags - * @param string[] $names The package name(s) to check for stability flags - * @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev' - * @return bool true if any package name is acceptable + * @param string[] $names The package name(s) to check for stability flags + * @param string $stability one of 'stable', 'RC', 'beta', 'alpha' or 'dev' + * @return bool true if any package name is acceptable */ public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, $names, $stability) { diff --git a/src/Composer/Package/Version/VersionGuesser.php b/src/Composer/Package/Version/VersionGuesser.php index 2cf7c6a5d..ef8a057bb 100644 --- a/src/Composer/Package/Version/VersionGuesser.php +++ b/src/Composer/Package/Version/VersionGuesser.php @@ -21,7 +21,6 @@ use Composer\Util\HttpDownloader; use Composer\Util\ProcessExecutor; use Composer\Util\Svn as SvnUtil; - /** * Try to guess the current version number based on different VCS configuration. * diff --git a/src/Composer/Package/Version/VersionSelector.php b/src/Composer/Package/Version/VersionSelector.php index e4d793e70..44b1d1a80 100644 --- a/src/Composer/Package/Version/VersionSelector.php +++ b/src/Composer/Package/Version/VersionSelector.php @@ -12,10 +12,8 @@ namespace Composer\Package\Version; -use Composer\DependencyResolver\Pool; use Composer\Package\BasePackage; use Composer\Package\PackageInterface; -use Composer\Plugin\PluginInterface; use Composer\Composer; use Composer\Package\Loader\ArrayLoader; use Composer\Package\Dumper\ArrayDumper; @@ -54,10 +52,10 @@ class VersionSelector * Given a package name and optional version, returns the latest PackageInterface * that matches. * - * @param string $packageName - * @param string $targetPackageVersion - * @param string $preferredStability - * @param bool|array $ignorePlatformReqs + * @param string $packageName + * @param string $targetPackageVersion + * @param string $preferredStability + * @param bool|array $ignorePlatformReqs * @return PackageInterface|false */ public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $ignorePlatformReqs = false, $repoSetFlags = 0) diff --git a/src/Composer/Platform/HhvmDetector.php b/src/Composer/Platform/HhvmDetector.php index ac63d047b..a13559e0d 100644 --- a/src/Composer/Platform/HhvmDetector.php +++ b/src/Composer/Platform/HhvmDetector.php @@ -1,4 +1,5 @@ newInstanceArgs($arguments); } @@ -84,7 +85,7 @@ class Runtime } /** - * @param string $extension + * @param string $extension * @return string */ public function getExtensionVersion($extension) @@ -93,7 +94,7 @@ class Runtime } /** - * @param string $extension + * @param string $extension * @return string */ public function getExtensionInfo($extension) diff --git a/src/Composer/Platform/Version.php b/src/Composer/Platform/Version.php index ab7cae0c4..15b2fdb95 100644 --- a/src/Composer/Platform/Version.php +++ b/src/Composer/Platform/Version.php @@ -18,8 +18,8 @@ namespace Composer\Platform; class Version { /** - * @param string $opensslVersion - * @param bool $isFips + * @param string $opensslVersion + * @param bool $isFips * @return string|null */ public static function parseOpenssl($opensslVersion, &$isFips) @@ -38,7 +38,7 @@ class Version } /** - * @param string $libjpegVersion + * @param string $libjpegVersion * @return string|null */ public static function parseLibjpeg($libjpegVersion) @@ -51,7 +51,7 @@ class Version } /** - * @param string $zoneinfoVersion + * @param string $zoneinfoVersion * @return string|null */ public static function parseZoneinfoVersion($zoneinfoVersion) @@ -66,16 +66,16 @@ class Version /** * "" => 0, "a" => 1, "zg" => 33 * - * @param string $alpha + * @param string $alpha * @return int */ 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))); } /** - * @param int $versionId + * @param int $versionId * @return string */ public static function convertLibxpmVersionId($versionId) @@ -84,7 +84,7 @@ class Version } /** - * @param int $versionId + * @param int $versionId * @return string */ public static function convertOpenldapVersionId($versionId) diff --git a/src/Composer/Plugin/PostFileDownloadEvent.php b/src/Composer/Plugin/PostFileDownloadEvent.php index a4bc2ac4a..370f58cd4 100644 --- a/src/Composer/Plugin/PostFileDownloadEvent.php +++ b/src/Composer/Plugin/PostFileDownloadEvent.php @@ -22,7 +22,6 @@ use Composer\Package\PackageInterface; */ class PostFileDownloadEvent extends Event { - /** * @var string */ @@ -46,11 +45,11 @@ class PostFileDownloadEvent extends Event /** * Constructor. * - * @param string $name The event name - * @param string $fileName The file name - * @param string|null $checksum The checksum - * @param string $url The processed url - * @param PackageInterface $package The package. + * @param string $name The event name + * @param string $fileName The file name + * @param string|null $checksum The checksum + * @param string $url The processed url + * @param PackageInterface $package The package. */ public function __construct($name, $fileName, $checksum, $url, PackageInterface $package) { @@ -76,7 +75,8 @@ class PostFileDownloadEvent extends Event * * @return string|null */ - public function getChecksum() { + public function getChecksum() + { return $this->checksum; } @@ -85,18 +85,18 @@ class PostFileDownloadEvent extends Event * * @return string */ - public function getUrl() { + public function getUrl() + { return $this->url; } /** * Get the package. * - * @return \Composer\Package\PackageInterface - * The package. + * @return \Composer\Package\PackageInterface The package. */ - public function getPackage() { + public function getPackage() + { return $this->package; } - } diff --git a/src/Composer/Plugin/PreFileDownloadEvent.php b/src/Composer/Plugin/PreFileDownloadEvent.php index 0f83b3178..b741d4646 100644 --- a/src/Composer/Plugin/PreFileDownloadEvent.php +++ b/src/Composer/Plugin/PreFileDownloadEvent.php @@ -50,11 +50,11 @@ class PreFileDownloadEvent extends Event /** * Constructor. * - * @param string $name The event name - * @param HttpDownloader $httpDownloader - * @param string $processedUrl - * @param string $type - * @param mixed $context + * @param string $name The event name + * @param HttpDownloader $httpDownloader + * @param string $processedUrl + * @param string $type + * @param mixed $context */ public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null) { diff --git a/src/Composer/Plugin/PrePoolCreateEvent.php b/src/Composer/Plugin/PrePoolCreateEvent.php index d23a644e3..b3d3079d6 100644 --- a/src/Composer/Plugin/PrePoolCreateEvent.php +++ b/src/Composer/Plugin/PrePoolCreateEvent.php @@ -13,7 +13,6 @@ namespace Composer\Plugin; use Composer\EventDispatcher\Event; -use Symfony\Component\Console\Input\InputInterface; use Composer\Repository\RepositoryInterface; use Composer\DependencyResolver\Request; use Composer\Package\PackageInterface; diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 24a7a38d8..b0d8443c6 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -31,8 +31,8 @@ class ArrayRepository implements RepositoryInterface protected $packages; /** - * @var PackageInterface[] indexed by package unique name and used to cache hasPackage calls - */ + * @var PackageInterface[] indexed by package unique name and used to cache hasPackage calls + */ protected $packageMap; public function __construct(array $packages = array()) diff --git a/src/Composer/Repository/ArtifactRepository.php b/src/Composer/Repository/ArtifactRepository.php index 4f03fc7eb..0ea1ef71c 100644 --- a/src/Composer/Repository/ArtifactRepository.php +++ b/src/Composer/Repository/ArtifactRepository.php @@ -94,7 +94,7 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION); if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) { $fileType = 'tar'; - } else if ($fileExtension === 'zip') { + } elseif ($fileExtension === 'zip') { $fileType = 'zip'; } else { throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.'); diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 1d9e29a91..cf0d501c3 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -76,7 +76,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito * TODO v3 should make this private once we can drop PHP 5.3 support * @private * @var array list of package names which are fresh and can be loaded from the cache directly in case loadPackage is called several times - * useful for v2 metadata repositories with lazy providers + * useful for v2 metadata repositories with lazy providers */ public $freshMetadataUrls = array(); @@ -84,7 +84,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito * TODO v3 should make this private once we can drop PHP 5.3 support * @private * @var array list of package names which returned a 404 and should not be re-fetched in case loadPackage is called several times - * useful for v2 metadata repositories with lazy providers + * useful for v2 metadata repositories with lazy providers */ public $packagesNotFoundCache = array(); /** @@ -527,7 +527,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito } /** - * @param string $name package name + * @param string $name package name * @return array|mixed */ private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array()) @@ -1244,19 +1244,21 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $io = $this->io; $url = $this->url; $cache = $this->cache; - $degradedMode =& $this->degradedMode; + $degradedMode = &$this->degradedMode; $repo = $this; $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) { // package not found is acceptable for a v2 protocol repository if ($response->getStatusCode() === 404) { $repo->packagesNotFoundCache[$filename] = true; + return array('packages' => array()); } $json = $response->getBody(); if ($json === '' && $response->getStatusCode() === 304) { $repo->freshMetadataUrls[$filename] = 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) { if ($e instanceof TransportException && $e->getStatusCode() === 404) { $repo->packagesNotFoundCache[$filename] = true; + return false; } @@ -1333,8 +1336,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito /** * Checks if the package name is present in this lazy providers repo * - * @param string $name - * @return bool true if the package name is present in availablePackages or matched by availablePackagePatterns + * @param string $name + * @return bool true if the package name is present in availablePackages or matched by availablePackagePatterns */ protected function lazyProvidersRepoContains($name) { diff --git a/src/Composer/Repository/CompositeRepository.php b/src/Composer/Repository/CompositeRepository.php index eaa70db2b..53d1fa9d9 100644 --- a/src/Composer/Repository/CompositeRepository.php +++ b/src/Composer/Repository/CompositeRepository.php @@ -41,7 +41,9 @@ class CompositeRepository implements RepositoryInterface 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)).')'; } /** diff --git a/src/Composer/Repository/FilesystemRepository.php b/src/Composer/Repository/FilesystemRepository.php index 85e3532e9..88b292ffb 100644 --- a/src/Composer/Repository/FilesystemRepository.php +++ b/src/Composer/Repository/FilesystemRepository.php @@ -35,9 +35,9 @@ class FilesystemRepository extends WritableArrayRepository /** * Initializes filesystem repository. * - * @param JsonFile $repositoryFile repository json file - * @param bool $dumpVersions - * @param ?RootPackageInterface $rootPackage Must be provided if $dumpVersions is true + * @param JsonFile $repositoryFile repository json file + * @param bool $dumpVersions + * @param ?RootPackageInterface $rootPackage Must be provided if $dumpVersions is true */ public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null) { diff --git a/src/Composer/Repository/InstalledRepository.php b/src/Composer/Repository/InstalledRepository.php index 25edbf733..d7ffe92d1 100644 --- a/src/Composer/Repository/InstalledRepository.php +++ b/src/Composer/Repository/InstalledRepository.php @@ -16,11 +16,9 @@ use Composer\Package\Version\VersionParser; use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\MatchAllConstraint; -use Composer\Package\AliasPackage; use Composer\Package\RootPackageInterface; use Composer\Package\Link; - /** * Installed repository is a composite of all installed repo types. * @@ -231,7 +229,9 @@ class InstalledRepository extends CompositeRepository 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())).')'; } /** diff --git a/src/Composer/Repository/LockArrayRepository.php b/src/Composer/Repository/LockArrayRepository.php index b485e79ec..7e3b92b03 100644 --- a/src/Composer/Repository/LockArrayRepository.php +++ b/src/Composer/Repository/LockArrayRepository.php @@ -26,4 +26,3 @@ class LockArrayRepository extends ArrayRepository return 'lock repo'; } } - diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index 02b955360..5b4ea969c 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -12,17 +12,6 @@ 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. * diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 000735198..72ae71ba9 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -186,7 +186,7 @@ class PlatformRepository extends ArrayRepository $library = strtolower($sslMatches['library']); if ($library === 'openssl') { $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 { $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl')); } @@ -315,7 +315,7 @@ class PlatformRepository extends ArrayRepository case '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'; }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter'))); $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides); @@ -441,7 +441,7 @@ class PlatformRepository extends ArrayRepository case 'zip': 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; @@ -549,7 +549,7 @@ class PlatformRepository extends ArrayRepository if ($name === 'uuid') { $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()), )); } @@ -557,7 +557,7 @@ class PlatformRepository extends ArrayRepository } /** - * @param string $name + * @param string $name * @return string */ private function buildPackageName($name) @@ -599,7 +599,7 @@ class PlatformRepository extends ArrayRepository /** * Check if a package name is a platform package. * - * @param string $name + * @param string $name * @return bool */ public static function isPlatformPackage($name) diff --git a/src/Composer/Repository/RepositoryInterface.php b/src/Composer/Repository/RepositoryInterface.php index 54e6e04a6..d54057b9f 100644 --- a/src/Composer/Repository/RepositoryInterface.php +++ b/src/Composer/Repository/RepositoryInterface.php @@ -70,8 +70,8 @@ interface RepositoryInterface extends \Countable * - The packages returned are the packages found which match the constraints, acceptable stability and stability flags provided * - The namesFound returned are names which should be considered as canonically found in this repository, that should not be looked up in any further lower priority repositories * - * @param ConstraintInterface[] $packageNameMap package names pointing to constraints - * @param int[] $acceptableStabilities array of stability => BasePackage::STABILITY_* value + * @param ConstraintInterface[] $packageNameMap package names pointing to constraints + * @param int[] $acceptableStabilities array of stability => BasePackage::STABILITY_* value * @psalm-param array $acceptableStabilities * @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value * @psalm-param array $stabilityFlags diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index 782e3e647..1ef60a719 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -20,12 +20,6 @@ use Composer\IO\IOInterface; use Composer\IO\NullIO; use Composer\Package\BasePackage; 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\Package\Version\StabilityFilter; @@ -83,7 +77,7 @@ class RepositorySet * aliases, pinned references and other special cases. * * @param string $minimumStability - * @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value + * @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value * @psalm-param array $stabilityFlags * @param array[] $rootAliases * @psalm-param list $rootAliases @@ -126,7 +120,7 @@ class RepositorySet * The first repos added have a higher priority. As soon as a package is found in any * repository the search for that package ends, and following repos will not be consulted. * - * @param RepositoryInterface $repo A package repository + * @param RepositoryInterface $repo A package repository */ public function addRepository(RepositoryInterface $repo) { @@ -150,9 +144,9 @@ class RepositorySet * * Returned in the order of repositories, matching priority * - * @param string $name - * @param ConstraintInterface|null $constraint - * @param int $flags any of the ALLOW_* constants from this class to tweak what is returned + * @param string $name + * @param ConstraintInterface|null $constraint + * @param int $flags any of the ALLOW_* constants from this class to tweak what is returned * @return array */ public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0) @@ -262,7 +256,6 @@ class RepositorySet $aliasPackage->setRootPackageAlias(true); $packages[] = $aliasPackage; } - } } diff --git a/src/Composer/Repository/Vcs/BitbucketDriver.php b/src/Composer/Repository/Vcs/BitbucketDriver.php index 61dc37f8e..aa6c9a2f8 100644 --- a/src/Composer/Repository/Vcs/BitbucketDriver.php +++ b/src/Composer/Repository/Vcs/BitbucketDriver.php @@ -144,7 +144,7 @@ abstract class BitbucketDriver extends VcsDriver $hash = $branches[$label]; } - if (! isset($hash)) { + if (!isset($hash)) { $composer['support']['source'] = sprintf( 'https://%s/%s/%s/src', $this->originUrl, diff --git a/src/Composer/Repository/Vcs/FossilDriver.php b/src/Composer/Repository/Vcs/FossilDriver.php index 92fa316f4..12218b2d7 100644 --- a/src/Composer/Repository/Vcs/FossilDriver.php +++ b/src/Composer/Repository/Vcs/FossilDriver.php @@ -165,7 +165,7 @@ class FossilDriver extends VcsDriver public function getChangeDate($identifier) { $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')); } diff --git a/src/Composer/Repository/Vcs/GitBitbucketDriver.php b/src/Composer/Repository/Vcs/GitBitbucketDriver.php index 08dbe9233..482fb1537 100644 --- a/src/Composer/Repository/Vcs/GitBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/GitBitbucketDriver.php @@ -30,7 +30,7 @@ class GitBitbucketDriver extends BitbucketDriver } if (null === $this->rootIdentifier) { - if (! $this->getRepoData()) { + if (!$this->getRepoData()) { return $this->fallbackDriver->getRootIdentifier(); } diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 47e3da9b0..46f7ef2ed 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -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->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); return; @@ -150,7 +150,7 @@ class GitHubDriver extends VcsDriver if (!isset($this->infoCache[$identifier])) { if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) { - $composer = JsonFile::parseJson($res); + $composer = JsonFile::parseJson($res); } else { $composer = $this->getBaseComposerInformation($identifier); @@ -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) { - try { $response = $this->httpDownloader->get($file, array( 'retry-auth-failure' => false, diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php index 12e7b14c3..4f3c35cd2 100644 --- a/src/Composer/Repository/Vcs/GitLabDriver.php +++ b/src/Composer/Repository/Vcs/GitLabDriver.php @@ -132,7 +132,7 @@ class GitLabDriver extends VcsDriver if (!isset($this->infoCache[$identifier])) { if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) { - $composer = JsonFile::parseJson($res); + $composer = JsonFile::parseJson($res); } else { $composer = $this->getBaseComposerInformation($identifier); @@ -563,6 +563,7 @@ class GitLabDriver extends VcsDriver if ($portNumber) { return $guessedDomain.':'.$portNumber; } + return $guessedDomain; } diff --git a/src/Composer/Repository/Vcs/HgBitbucketDriver.php b/src/Composer/Repository/Vcs/HgBitbucketDriver.php index 2d0596467..9706e2a00 100644 --- a/src/Composer/Repository/Vcs/HgBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/HgBitbucketDriver.php @@ -30,7 +30,7 @@ class HgBitbucketDriver extends BitbucketDriver } if (null === $this->rootIdentifier) { - if (! $this->getRepoData()) { + if (!$this->getRepoData()) { return $this->fallbackDriver->getRootIdentifier(); } diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index f174f8527..4e92658d7 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -15,7 +15,6 @@ namespace Composer\Repository\Vcs; use Composer\Cache; use Composer\Downloader\TransportException; use Composer\Config; -use Composer\Factory; use Composer\IO\IOInterface; use Composer\Json\JsonFile; use Composer\Util\ProcessExecutor; @@ -52,11 +51,11 @@ abstract class VcsDriver implements VcsDriverInterface /** * Constructor. * - * @param array $repoConfig The repository configuration - * @param IOInterface $io The IO instance - * @param Config $config The composer configuration - * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking - * @param ProcessExecutor $process Process instance, injectable for mocking + * @param array $repoConfig The repository configuration + * @param IOInterface $io The IO instance + * @param Config $config The composer configuration + * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking + * @param ProcessExecutor $process Process instance, injectable for mocking */ final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process) { diff --git a/src/Composer/Repository/Vcs/VcsDriverInterface.php b/src/Composer/Repository/Vcs/VcsDriverInterface.php index e59bcf647..22cb33007 100644 --- a/src/Composer/Repository/Vcs/VcsDriverInterface.php +++ b/src/Composer/Repository/Vcs/VcsDriverInterface.php @@ -36,8 +36,8 @@ interface VcsDriverInterface /** * Return the content of $file or null if the file does not exist. * - * @param string $file - * @param string $identifier + * @param string $file + * @param string $identifier * @return string|null */ public function getFileContent($file, $identifier); @@ -45,7 +45,7 @@ interface VcsDriverInterface /** * Get the changedate for $identifier. * - * @param string $identifier + * @param string $identifier * @return \DateTime|null */ public function getChangeDate($identifier); @@ -72,8 +72,8 @@ interface VcsDriverInterface public function getTags(); /** - * @param string $identifier Any identifier to a specific branch/tag/commit - * @return array|null With type, url reference and shasum keys. + * @param string $identifier Any identifier to a specific branch/tag/commit + * @return array|null With type, url reference and shasum keys. */ public function getDist($identifier); diff --git a/src/Composer/Repository/VersionCacheInterface.php b/src/Composer/Repository/VersionCacheInterface.php index 41d485c64..3b05fb8ff 100644 --- a/src/Composer/Repository/VersionCacheInterface.php +++ b/src/Composer/Repository/VersionCacheInterface.php @@ -15,8 +15,8 @@ namespace Composer\Repository; interface VersionCacheInterface { /** - * @param string $version - * @param string $identifier + * @param string $version + * @param string $identifier * @return array|null|false Package version data if found, false to indicate the identifier is known but has no package, null for an unknown identifier */ public function getVersionPackage($version, $identifier); diff --git a/src/Composer/Script/Event.php b/src/Composer/Script/Event.php index 937dc2f01..5ab431e75 100644 --- a/src/Composer/Script/Event.php +++ b/src/Composer/Script/Event.php @@ -105,7 +105,7 @@ class Event extends BaseEvent /** * Set the originating event. * - * @param \Composer\EventDispatcher\Event $event + * @param \Composer\EventDispatcher\Event $event * @return $this */ public function setOriginatingEvent(BaseEvent $event) @@ -118,7 +118,7 @@ class Event extends BaseEvent /** * Returns the upper-most event in chain. * - * @param \Composer\EventDispatcher\Event $event + * @param \Composer\EventDispatcher\Event $event * @return \Composer\EventDispatcher\Event */ private function calculateOriginatingEvent(BaseEvent $event) diff --git a/src/Composer/SelfUpdate/Versions.php b/src/Composer/SelfUpdate/Versions.php index 21b48d9e5..45bc4272f 100644 --- a/src/Composer/SelfUpdate/Versions.php +++ b/src/Composer/SelfUpdate/Versions.php @@ -14,7 +14,6 @@ namespace Composer\SelfUpdate; use Composer\Util\HttpDownloader; use Composer\Config; -use Composer\Json\JsonFile; /** * @author Jordi Boggiano diff --git a/src/Composer/Util/AuthHelper.php b/src/Composer/Util/AuthHelper.php index 2341fc517..096c73008 100644 --- a/src/Composer/Util/AuthHelper.php +++ b/src/Composer/Util/AuthHelper.php @@ -32,7 +32,7 @@ class AuthHelper } /** - * @param string $origin + * @param string $origin * @param string|bool $storeAuth */ public function storeAuth($origin, $storeAuth) @@ -68,13 +68,13 @@ class AuthHelper } /** - * @param string $url - * @param string $origin - * @param int $statusCode HTTP status code that triggered this call - * @param string|null $reason a message/description explaining why this was called - * @param string[] $headers - * @return array|null containing retry (bool) and storeAuth (string|bool) keys, if retry is true the request should be - * retried, if storeAuth is true then on a successful retry the authentication should be persisted to auth.json + * @param string $url + * @param string $origin + * @param int $statusCode HTTP status code that triggered this call + * @param string|null $reason a message/description explaining why this was called + * @param string[] $headers + * @return array|null containing retry (bool) and storeAuth (string|bool) keys, if retry is true the request should be + * retried, if storeAuth is true then on a successful retry the authentication should be persisted to auth.json */ public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array()) { @@ -145,8 +145,8 @@ class AuthHelper 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'); $bitBucketUtil = new Bitbucket($this->io, $this->config); - if (! $bitBucketUtil->authorizeOAuth($origin) - && (! $this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message)) + if (!$bitBucketUtil->authorizeOAuth($origin) + && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message)) ) { throw new TransportException('Could not authenticate against ' . $origin, 401); } @@ -185,10 +185,10 @@ class AuthHelper } /** - * @param array $headers - * @param string $origin - * @param string $url - * @return array updated headers array + * @param array $headers + * @param string $origin + * @param string $url + * @return array updated headers array */ public function addAuthenticationHeader(array $headers, $origin, $url) { diff --git a/src/Composer/Util/Bitbucket.php b/src/Composer/Util/Bitbucket.php index c88c8311e..ea082806d 100644 --- a/src/Composer/Util/Bitbucket.php +++ b/src/Composer/Util/Bitbucket.php @@ -40,11 +40,11 @@ class Bitbucket /** * Constructor. * - * @param IOInterface $io The IO instance - * @param Config $config The composer configuration - * @param ProcessExecutor $process Process instance, injectable for mocking - * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking - * @param int $time Timestamp, injectable for mocking + * @param IOInterface $io The IO instance + * @param Config $config The composer configuration + * @param ProcessExecutor $process Process instance, injectable for mocking + * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking + * @param int $time Timestamp, injectable for mocking */ public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null) { diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index 7ba530f53..dd2cbcb0d 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -141,7 +141,6 @@ class ConfigValidator } } - // check for meaningless provide/replace satisfying requirements foreach (array('provide', 'replace') as $linkType) { if (isset($manifest[$linkType])) { diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 61491df4c..b940ced48 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -277,8 +277,8 @@ class Filesystem /** * Copies a file or directory from $source to $target. * - * @param string $source - * @param string $target + * @param string $source + * @param string $target * @return bool */ public function copy($source, $target) @@ -564,7 +564,7 @@ class Filesystem protected function getProcess() { if (!$this->processExecutor) { - $this->processExecutor = new ProcessExecutor(); + $this->processExecutor = new ProcessExecutor(); } return $this->processExecutor; diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index f752f9597..4eafc24e0 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -139,7 +139,7 @@ class Git //We already have an access_token from a previous request. if ($auth['username'] !== 'x-token-auth') { $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']); - if (! empty($accessToken)) { + if (!empty($accessToken)) { $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken); } } diff --git a/src/Composer/Util/GitHub.php b/src/Composer/Util/GitHub.php index d6bfb62ca..b081afeff 100644 --- a/src/Composer/Util/GitHub.php +++ b/src/Composer/Util/GitHub.php @@ -34,10 +34,10 @@ class GitHub /** * Constructor. * - * @param IOInterface $io The IO instance - * @param Config $config The composer configuration - * @param ProcessExecutor $process Process instance, injectable for mocking - * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking + * @param IOInterface $io The IO instance + * @param Config $config The composer configuration + * @param ProcessExecutor $process Process instance, injectable for mocking + * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking */ public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null) { diff --git a/src/Composer/Util/GitLab.php b/src/Composer/Util/GitLab.php index ded2393b6..1ff2fbb96 100644 --- a/src/Composer/Util/GitLab.php +++ b/src/Composer/Util/GitLab.php @@ -16,7 +16,6 @@ use Composer\IO\IOInterface; use Composer\Config; use Composer\Factory; use Composer\Downloader\TransportException; -use Composer\Json\JsonFile; /** * @author Roshan Gautam @@ -35,10 +34,10 @@ class GitLab /** * Constructor. * - * @param IOInterface $io The IO instance - * @param Config $config The composer configuration - * @param ProcessExecutor $process Process instance, injectable for mocking - * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking + * @param IOInterface $io The IO instance + * @param Config $config The composer configuration + * @param ProcessExecutor $process Process instance, injectable for mocking + * @param HttpDownloader $httpDownloader Remote Filesystem, injectable for mocking */ public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null) { @@ -88,8 +87,8 @@ class GitLab if (isset($authTokens[$bcOriginUrl])) { $token = $authTokens[$bcOriginUrl]; } - - if(isset($token)){ + + if (isset($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'; $this->io->setAuthentication($originUrl, $username, $password); diff --git a/src/Composer/Util/Http/CurlDownloader.php b/src/Composer/Util/Http/CurlDownloader.php index 22386e0e1..2d1d1a3f0 100644 --- a/src/Composer/Util/Http/CurlDownloader.php +++ b/src/Composer/Util/Http/CurlDownloader.php @@ -16,7 +16,6 @@ use Composer\Config; use Composer\Downloader\MaxFileSizeExceededException; use Composer\IO\IOInterface; use Composer\Downloader\TransportException; -use Composer\CaBundle\CaBundle; use Composer\Util\StreamContextFactory; use Composer\Util\AuthHelper; use Composer\Util\Url; @@ -45,10 +44,10 @@ class CurlDownloader private $proxyManager; private $supportsSecureProxy; protected $multiErrors = array( - 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_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_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!'), ); private static $options = array( @@ -165,7 +164,7 @@ class CurlDownloader curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle); curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle); 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')) { curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle); } @@ -513,7 +512,8 @@ class CurlDownloader private function checkCurlResult($code) { 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]}" : 'Unexpected cURL error: ' . $code ); diff --git a/src/Composer/Util/Http/ProxyHelper.php b/src/Composer/Util/Http/ProxyHelper.php index 2f03de735..4ca7a4bc8 100644 --- a/src/Composer/Util/Http/ProxyHelper.php +++ b/src/Composer/Util/Http/ProxyHelper.php @@ -24,7 +24,7 @@ class ProxyHelper * Returns proxy environment values * * @throws \RuntimeException on malformed url - * @return array httpProxy, httpsProxy, noProxy values + * @return array httpProxy, httpsProxy, noProxy values */ public static function getProxyData() { @@ -59,7 +59,7 @@ class ProxyHelper /** * Returns http context options for the proxy url * - * @param string $proxyUrl + * @param string $proxyUrl * @return array */ public static function getContextOptions($proxyUrl) @@ -91,7 +91,7 @@ class ProxyHelper * Sets/unsets request_fulluri value in http context options array * * @param string $requestUrl - * @param array $options Set by method + * @param array $options Set by method */ public static function setRequestFullUri($requestUrl, array &$options) { @@ -105,8 +105,8 @@ class ProxyHelper /** * Searches $_SERVER for case-sensitive values * - * @param array $names Names to search for - * @param mixed $name Name of any found value + * @param array $names Names to search for + * @param mixed $name Name of any found value * @return string|null The found value */ private static function getProxyEnv(array $names, &$name) @@ -121,10 +121,10 @@ class ProxyHelper /** * Checks and formats a proxy url from the environment * - * @param string $proxyUrl - * @param string $envName + * @param string $proxyUrl + * @param string $envName * @throws \RuntimeException on malformed url - * @return string The formatted proxy url + * @return string The formatted proxy url */ private static function checkProxy($proxyUrl, $envName) { @@ -147,8 +147,8 @@ class ProxyHelper /** * Formats a url from its component parts * - * @param array $proxy Values from parse_url - * @param bool $includeAuth Whether to include authorization values + * @param array $proxy Values from parse_url + * @param bool $includeAuth Whether to include authorization values * @return string The formatted value */ private static function formatParsedUrl(array $proxy, $includeAuth) diff --git a/src/Composer/Util/Http/ProxyManager.php b/src/Composer/Util/Http/ProxyManager.php index 6861c8833..693ef92ad 100644 --- a/src/Composer/Util/Http/ProxyManager.php +++ b/src/Composer/Util/Http/ProxyManager.php @@ -51,7 +51,7 @@ class ProxyManager } /** - * @return ProxyManager * + * @return ProxyManager */ public static function getInstance() { @@ -73,7 +73,7 @@ class ProxyManager /** * Returns a RequestProxy instance for the request url * - * @param string $requestUrl + * @param string $requestUrl * @return RequestProxy */ public function getProxyForRequest($requestUrl) @@ -130,6 +130,7 @@ class ProxyManager list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData(); } catch (\RuntimeException $e) { $this->error = $e->getMessage(); + return; } @@ -152,7 +153,7 @@ class ProxyManager /** * Sets initial data * - * @param string $url Proxy url + * @param string $url Proxy url * @param string $scheme Environment variable scheme */ private function setData($url, $scheme) @@ -169,7 +170,7 @@ class ProxyManager /** * Returns true if a url matches no_proxy value * - * @param string $requestUrl + * @param string $requestUrl * @return bool */ private function noProxy($requestUrl) @@ -177,6 +178,7 @@ class ProxyManager if ($this->noProxyHandler) { if (call_user_func($this->noProxyHandler, $requestUrl)) { $this->lastProxy = 'excluded by no_proxy'; + return true; } } diff --git a/src/Composer/Util/Http/RequestProxy.php b/src/Composer/Util/Http/RequestProxy.php index abaa3e2ce..67555c9b1 100644 --- a/src/Composer/Util/Http/RequestProxy.php +++ b/src/Composer/Util/Http/RequestProxy.php @@ -27,7 +27,7 @@ class RequestProxy /** * @param string $url - * @param array $contextOptions + * @param array $contextOptions * @param string $formattedUrl */ public function __construct($url, array $contextOptions, $formattedUrl) @@ -51,8 +51,8 @@ class RequestProxy /** * Returns the safe proxy url from the last request * - * @param string|null $format Output format specifier - * @return string Safe proxy, no proxy or empty + * @param string|null $format Output format specifier + * @return string Safe proxy, no proxy or empty */ public function getFormattedUrl($format = '') { diff --git a/src/Composer/Util/HttpDownloader.php b/src/Composer/Util/HttpDownloader.php index 07eb22c24..9bd1cb6f0 100644 --- a/src/Composer/Util/HttpDownloader.php +++ b/src/Composer/Util/HttpDownloader.php @@ -15,7 +15,6 @@ namespace Composer\Util; use Composer\Config; use Composer\IO\IOInterface; use Composer\Downloader\TransportException; -use Composer\CaBundle\CaBundle; use Composer\Util\Http\Response; use Composer\Composer; use Composer\Package\Version\VersionParser; @@ -231,7 +230,7 @@ class HttpDownloader throw $e; }); - $this->jobs[$job['id']] =& $job; + $this->jobs[$job['id']] = &$job; if ($this->runningJobs < $this->maxJobs) { $this->startJob($job['id']); @@ -242,7 +241,7 @@ class HttpDownloader private function startJob($id) { - $job =& $this->jobs[$id]; + $job = &$this->jobs[$id]; if ($job['status'] !== self::STATUS_QUEUED) { return; } @@ -265,6 +264,7 @@ class HttpDownloader $e->setStatusCode(499); $reject($e); } + return; } @@ -395,17 +395,17 @@ class HttpDownloader Silencer::suppress(); $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array( 'ssl' => array('verify_peer' => false), - 'http' => array('follow_location' => false, 'ignore_errors' => true) + 'http' => array('follow_location' => false, 'ignore_errors' => true), ))); Silencer::restore(); if (false !== $testConnectivity) { return array( - 'The following exception probably indicates you have misconfigured DNS resolver(s)' + 'The following exception probably indicates you have misconfigured DNS resolver(s)', ); } return array( - 'The following exception probably indicates you are offline or have misconfigured DNS resolver(s)' + 'The following exception probably indicates you are offline or have misconfigured DNS resolver(s)', ); } } diff --git a/src/Composer/Util/Loop.php b/src/Composer/Util/Loop.php index 3f85434de..a75888a8c 100644 --- a/src/Composer/Util/Loop.php +++ b/src/Composer/Util/Loop.php @@ -12,7 +12,6 @@ namespace Composer\Util; -use Composer\Util\HttpDownloader; use React\Promise\Promise; use Symfony\Component\Console\Helper\ProgressBar; @@ -63,7 +62,8 @@ class Loop $uncaught = null; \React\Promise\all($promises)->then( - function () { }, + function () { + }, function ($e) use (&$uncaught) { $uncaught = $e; } diff --git a/src/Composer/Util/NoProxyPattern.php b/src/Composer/Util/NoProxyPattern.php index 0ddf371b2..f74ab7cf0 100644 --- a/src/Composer/Util/NoProxyPattern.php +++ b/src/Composer/Util/NoProxyPattern.php @@ -108,7 +108,7 @@ class NoProxyPattern /** * Returns true if the url is matched by a rule * - * @param int $index + * @param int $index * @param string $hostName * @param string $url * @@ -134,7 +134,7 @@ class NoProxyPattern $match = $rule->ipdata->ip === $url->ipdata->ip; } else { // Match host and port - $haystack = substr($url->name, - strlen($rule->name)); + $haystack = substr($url->name, -strlen($rule->name)); $match = stripos($haystack, $rule->name) === 0; } @@ -171,7 +171,7 @@ class NoProxyPattern /** * Finds or creates rule data for a hostname * - * @param int $index + * @param int $index * @param string $hostName * * @return null|stdClass Null if the hostname is invalid @@ -197,9 +197,9 @@ class NoProxyPattern /** * Creates an object containing IP data if the host is an IP address * - * @param string $host - * @param null|stdclass $ipdata Set by method if IP address found - * @param bool $allowPrefix Whether a CIDR prefix-length is expected + * @param string $host + * @param null|stdclass $ipdata Set by method if IP address found + * @param bool $allowPrefix Whether a CIDR prefix-length is expected * * @return bool False if the host contains invalid data */ @@ -265,7 +265,7 @@ class NoProxyPattern * Returns the binary network mask mapped to IPv6 * * @param string $prefix CIDR prefix-length - * @param int $size Byte size of in_addr + * @param int $size Byte size of in_addr * * @return string */ @@ -290,8 +290,8 @@ class NoProxyPattern * Calculates and returns the network and mask * * @param string $rangeIp IP in_addr - * @param int $size Byte size of in_addr - * @param string $prefix CIDR prefix-length + * @param int $size Byte size of in_addr + * @param string $prefix CIDR prefix-length * * @return string[] network in_addr, binary mask */ @@ -315,7 +315,7 @@ class NoProxyPattern * Maps an IPv4 address to IPv6 * * @param string $binary in_addr - * @param int $size Byte size of in_addr + * @param int $size Byte size of in_addr * * @return string Mapped or existing in_addr */ @@ -332,8 +332,8 @@ class NoProxyPattern /** * Creates a rule data object * - * @param string $host - * @param int $port + * @param string $host + * @param int $port * @param null|stdclass $ipdata * * @return stdclass @@ -351,8 +351,8 @@ class NoProxyPattern /** * Creates an ip data object * - * @param string $ip in_addr - * @param int $size Byte size of in_addr + * @param string $ip in_addr + * @param int $size Byte size of in_addr * @param null|string $netmask Network mask * * @return stdclass @@ -392,8 +392,7 @@ class NoProxyPattern $ip6 = substr($hostName, 1, $index - 1); $hostName = substr($hostName, $index + 1); - if (strpbrk($hostName, '[]') !== false - || substr_count($hostName, ':') > 1) { + if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) { return $error; } } @@ -419,15 +418,16 @@ class NoProxyPattern * Wrapper around filter_var FILTER_VALIDATE_INT * * @param string $int - * @param int $min - * @param int $max + * @param int $min + * @param int $max */ private function validateInt($int, $min, $max) { $options = array( 'options' => array( 'min_range' => $min, - 'max_range' => $max) + 'max_range' => $max, + ), ); return false !== filter_var($int, FILTER_VALIDATE_INT, $options); diff --git a/src/Composer/Util/PackageSorter.php b/src/Composer/Util/PackageSorter.php index 204a35b51..ae3728077 100644 --- a/src/Composer/Util/PackageSorter.php +++ b/src/Composer/Util/PackageSorter.php @@ -1,5 +1,14 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Composer\Util; @@ -16,7 +25,8 @@ class PackageSorter * @param array $packages * @return array */ - public static function sortPackages(array $packages) { + public static function sortPackages(array $packages) + { $usageList = array(); foreach ($packages as $package) { /** @var PackageInterface $package */ @@ -87,6 +97,7 @@ class PackageSorter foreach (array_keys($weightList) as $index) { $sortedPackages[] = $packages[$index]; } + return $sortedPackages; } } diff --git a/src/Composer/Util/Perforce.php b/src/Composer/Util/Perforce.php index 712e2b818..d399e4c78 100644 --- a/src/Composer/Util/Perforce.php +++ b/src/Composer/Util/Perforce.php @@ -514,7 +514,7 @@ class Perforce } /** - * @param string $reference + * @param string $reference * @return mixed|null */ protected function getChangeList($reference) @@ -536,8 +536,8 @@ class Perforce } /** - * @param string $fromReference - * @param string $toReference + * @param string $fromReference + * @param string $toReference * @return mixed|null */ public function getCommitLogs($fromReference, $toReference) diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index 930974b06..f940f49a9 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -136,8 +136,8 @@ class ProcessExecutor /** * starts a process on the commandline in async mode * - * @param string $command the command to execute - * @param string $cwd the working directory + * @param string $command the command to execute + * @param string $cwd the working directory * @return Promise */ public function executeAsync($command, $cwd = null) @@ -198,7 +198,7 @@ class ProcessExecutor throw $e; }); - $this->jobs[$job['id']] =& $job; + $this->jobs[$job['id']] = &$job; if ($this->runningJobs < $this->maxJobs) { $this->startJob($job['id']); @@ -209,7 +209,7 @@ class ProcessExecutor private function startJob($id) { - $job =& $this->jobs[$id]; + $job = &$this->jobs[$id]; if ($job['status'] !== self::STATUS_QUEUED) { return; } diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 61d77523f..ea899b312 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -550,7 +550,6 @@ class RemoteFilesystem // passing `null` to file_get_contents will convert `null` to `0` and return 0 bytes $result = file_get_contents($fileUrl, false, $context); } - } catch (\Throwable $e) { } catch (\Exception $e) { } diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index f9b5a0040..50ecaca6f 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -29,7 +29,7 @@ final class StreamContextFactory /** * Creates a context supporting HTTP proxies * - * @param string $url URL the context is to be used for + * @param string $url URL the context is to be used for * @psalm-param array{http: array{follow_location?: int, max_redirects?: int, header?: string|array}} $defaultOptions * @param array $defaultOptions Options to merge with the default * @param array $defaultParams Parameters to specify on the context @@ -57,8 +57,8 @@ final class StreamContextFactory /** * @param string $url - * @param array $options - * @param bool $forCurl When true, will not add proxy values as these are handled separately + * @param array $options + * @param bool $forCurl When true, will not add proxy values as these are handled separately * @psalm-return array{http:{header: string[], proxy?: string, request_fulluri: bool}, ssl: array} * @return array formatted as a stream context array */ @@ -236,7 +236,7 @@ final class StreamContextFactory * This method fixes the array by moving the content-type header to the end * * @link https://bugs.php.net/bug.php?id=61548 - * @param string|array $header + * @param string|array $header * @return array */ private static function fixHttpHeaderField($header) diff --git a/src/Composer/Util/SyncHelper.php b/src/Composer/Util/SyncHelper.php index 964a78cd1..27685693b 100644 --- a/src/Composer/Util/SyncHelper.php +++ b/src/Composer/Util/SyncHelper.php @@ -1,5 +1,15 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer\Util; use Composer\Downloader\DownloaderInterface; diff --git a/src/Composer/Util/Url.php b/src/Composer/Util/Url.php index 0dcc8319a..bbe6c67a7 100644 --- a/src/Composer/Util/Url.php +++ b/src/Composer/Util/Url.php @@ -20,9 +20,9 @@ use Composer\Config; class Url { /** - * @param Config $config - * @param string $url - * @param string $ref + * @param Config $config + * @param string $url + * @param string $ref * @return string the updated URL */ public static function updateDistReference(Config $config, $url, $ref) @@ -60,7 +60,7 @@ class Url } /** - * @param string $url + * @param string $url * @return string */ public static function getOrigin(Config $config, $url) diff --git a/src/Composer/Util/Zip.php b/src/Composer/Util/Zip.php index 3cb634eab..2e4bc3774 100644 --- a/src/Composer/Util/Zip.php +++ b/src/Composer/Util/Zip.php @@ -64,8 +64,8 @@ class Zip /** * Find a file by name, returning the one that has the shortest path. * - * @param \ZipArchive $zip - * @param string $filename + * @param \ZipArchive $zip + * @param string $filename * @throws \RuntimeException * * @return int diff --git a/tests/Composer/Test/AllFunctionalTest.php b/tests/Composer/Test/AllFunctionalTest.php index bd8e7b853..a38eda193 100644 --- a/tests/Composer/Test/AllFunctionalTest.php +++ b/tests/Composer/Test/AllFunctionalTest.php @@ -12,7 +12,6 @@ namespace Composer\Test; -use Composer\Test\TestCase; use Composer\Util\Filesystem; use Symfony\Component\Finder\Finder; use Symfony\Component\Process\Process; @@ -196,8 +195,8 @@ class AllFunctionalTest extends TestCase throw new \RuntimeException(sprintf( 'Unknown section "%s". Allowed sections: "RUN", "EXPECT", "EXPECT-ERROR", "EXPECT-EXIT-CODE", "EXPECT-REGEX", "EXPECT-ERROR-REGEX". ' .'Section headers must be written as "--HEADER_NAME--".', - $section - )); + $section + )); } $data[$section] = $sectionData; diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php index 18138d399..7e78ee68f 100644 --- a/tests/Composer/Test/ApplicationTest.php +++ b/tests/Composer/Test/ApplicationTest.php @@ -13,7 +13,6 @@ namespace Composer\Test; use Composer\Console\Application; -use Composer\Test\TestCase; use Symfony\Component\Console\Output\OutputInterface; class ApplicationTest extends TestCase diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index e41c5040b..0b8334464 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -500,7 +500,7 @@ class AutoloadGeneratorTest extends TestCase { $package = new RootPackage('root/a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a', new MatchAllConstraint()) + new Link('a', 'a/a', new MatchAllConstraint()), )); $packages = array(); @@ -511,18 +511,18 @@ class AutoloadGeneratorTest extends TestCase $packages[] = $e = new Package('e/e', '1.0', '1.0'); $a->setAutoload(array('classmap' => array('src/A.php'))); $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->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->setReplaces(array( - new Link('c/c', 'b/b', new MatchAllConstraint()) + new Link('c/c', 'b/b', new MatchAllConstraint()), )); $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'))); $e->setAutoload(array('classmap' => array('src/E.php'))); @@ -1740,63 +1740,63 @@ EOF; array( new Link('a', 'php', $versionParser->parseConstraints('^7.2')), 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( array( new Link('a', 'php', $versionParser->parseConstraints('< 8')), ), - null + null, ), 'No PHP upper bound' => array( array( new Link('a', 'php', $versionParser->parseConstraints('>= 7.2')), ), - 'no_php_upper_bound' + 'no_php_upper_bound', ), 'Specific PHP release version' => array( array( new Link('a', 'php', $versionParser->parseConstraints('^7.2.8')), ), - 'specific_php_release' + 'specific_php_release', ), 'No PHP required' => array( array( 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( array( new Link('a', 'php', $versionParser->parseConstraints('^7.2')), new Link('a', 'ext-xml', $versionParser->parseConstraints('*')), - new Link('a', 'ext-json', $versionParser->parseConstraints('*')) + new Link('a', 'ext-json', $versionParser->parseConstraints('*')), ), null, array(), array(), - true + true, ), 'Ignored platform requirements are not checked for' => array( array( new Link('a', 'php', $versionParser->parseConstraints('^7.2.8')), new Link('a', 'ext-xml', $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', array(), array(), - array('php', 'ext-pdo') + array('php', 'ext-pdo'), ), 'No extensions required' => array( array( 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( array( diff --git a/tests/Composer/Test/CacheTest.php b/tests/Composer/Test/CacheTest.php index d2a655f3a..fbf188d29 100644 --- a/tests/Composer/Test/CacheTest.php +++ b/tests/Composer/Test/CacheTest.php @@ -12,7 +12,6 @@ namespace Composer\Test; -use Composer\Test\TestCase; use Composer\Cache; use Composer\Util\Filesystem; diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index 06d8a004b..d1c3b62fd 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -59,7 +59,7 @@ class InitCommandTest extends TestCase { $command = new InitCommand; $author = $command->parseAuthorString( - 'Johnathon "Johnny" Smith ' + 'Johnathon "Johnny" Smith ' ); $this->assertEquals('Johnathon "Johnny" Smith', $author['name']); $this->assertEquals('john@example.com', $author['email']); @@ -73,7 +73,7 @@ class InitCommandTest extends TestCase { $command = new InitCommand; $author = $command->parseAuthorString( - 'Johnathon (Johnny) Smith ' + 'Johnathon (Johnny) Smith ' ); $this->assertEquals('Johnathon (Johnny) Smith', $author['name']); $this->assertEquals('john@example.com', $author['email']); diff --git a/tests/Composer/Test/ComposerTest.php b/tests/Composer/Test/ComposerTest.php index 87270baae..1ba78abea 100644 --- a/tests/Composer/Test/ComposerTest.php +++ b/tests/Composer/Test/ComposerTest.php @@ -13,7 +13,6 @@ namespace Composer\Test; use Composer\Composer; -use Composer\Test\TestCase; class ComposerTest extends TestCase { diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php index 750dd627d..4a4bf011b 100644 --- a/tests/Composer/Test/ConfigTest.php +++ b/tests/Composer/Test/ConfigTest.php @@ -13,7 +13,6 @@ namespace Composer\Test; use Composer\Config; -use Composer\Test\TestCase; class ConfigTest extends TestCase { diff --git a/tests/Composer/Test/DefaultConfigTest.php b/tests/Composer/Test/DefaultConfigTest.php index 04298e5a1..2aeeb783e 100644 --- a/tests/Composer/Test/DefaultConfigTest.php +++ b/tests/Composer/Test/DefaultConfigTest.php @@ -13,7 +13,6 @@ namespace Composer\Test; use Composer\Config; -use Composer\Test\TestCase; class DefaultConfigTest extends TestCase { diff --git a/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php b/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php index 0341dba81..42a8f2da5 100644 --- a/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php +++ b/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php @@ -14,9 +14,7 @@ namespace Composer\Test\DependencyResolver; use Composer\Repository\ArrayRepository; use Composer\Repository\LockArrayRepository; -use Composer\Repository\RepositoryInterface; use Composer\DependencyResolver\DefaultPolicy; -use Composer\DependencyResolver\Pool; use Composer\Package\Link; use Composer\Package\AliasPackage; use Composer\Repository\RepositorySet; diff --git a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php index a72e42c96..88ea4c029 100644 --- a/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php @@ -16,21 +16,14 @@ use Composer\IO\NullIO; use Composer\Repository\ArrayRepository; use Composer\Repository\FilterRepository; use Composer\Repository\LockArrayRepository; -use Composer\DependencyResolver\DefaultPolicy; -use Composer\DependencyResolver\Pool; -use Composer\DependencyResolver\PoolBuilder; use Composer\DependencyResolver\Request; -use Composer\DependencyResolver\Solver; -use Composer\DependencyResolver\SolverProblemsException; use Composer\Package\BasePackage; use Composer\Package\AliasPackage; use Composer\Json\JsonFile; use Composer\Package\Loader\ArrayLoader; use Composer\Package\Version\VersionParser; -use Composer\Repository\InstalledArrayRepository; use Composer\Repository\RepositorySet; use Composer\Test\TestCase; -use Composer\Semver\Constraint\MultiConstraint; class PoolBuilderTest extends TestCase { diff --git a/tests/Composer/Test/DependencyResolver/PoolTest.php b/tests/Composer/Test/DependencyResolver/PoolTest.php index ceeb928ba..da5385589 100644 --- a/tests/Composer/Test/DependencyResolver/PoolTest.php +++ b/tests/Composer/Test/DependencyResolver/PoolTest.php @@ -13,8 +13,6 @@ namespace Composer\Test\DependencyResolver; use Composer\DependencyResolver\Pool; -use Composer\Repository\ArrayRepository; -use Composer\Package\BasePackage; use Composer\Test\TestCase; class PoolTest extends TestCase @@ -31,7 +29,6 @@ class PoolTest extends TestCase public function testWhatProvidesPackageWithConstraint() { - $firstPackage = $this->getPackage('foo', '1'); $secondPackage = $this->getPackage('foo', '2'); diff --git a/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php b/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php index ffcae5668..379fcf49e 100644 --- a/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php @@ -17,7 +17,6 @@ use Composer\DependencyResolver\Rule; use Composer\DependencyResolver\RuleSet; use Composer\DependencyResolver\RuleSetIterator; use Composer\DependencyResolver\Pool; -use Composer\Package\BasePackage; use Composer\Test\TestCase; class RuleSetIteratorTest extends TestCase diff --git a/tests/Composer/Test/DependencyResolver/RuleSetTest.php b/tests/Composer/Test/DependencyResolver/RuleSetTest.php index cbb41464c..9ccb25c09 100644 --- a/tests/Composer/Test/DependencyResolver/RuleSetTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleSetTest.php @@ -16,8 +16,6 @@ use Composer\DependencyResolver\GenericRule; use Composer\DependencyResolver\Rule; use Composer\DependencyResolver\RuleSet; use Composer\DependencyResolver\Pool; -use Composer\Package\BasePackage; -use Composer\Repository\ArrayRepository; use Composer\Test\TestCase; class RuleSetTest extends TestCase diff --git a/tests/Composer/Test/DependencyResolver/RuleTest.php b/tests/Composer/Test/DependencyResolver/RuleTest.php index ebf15fcac..3ff69c8ce 100644 --- a/tests/Composer/Test/DependencyResolver/RuleTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleTest.php @@ -16,9 +16,7 @@ use Composer\DependencyResolver\GenericRule; use Composer\DependencyResolver\Rule; use Composer\DependencyResolver\RuleSet; use Composer\DependencyResolver\Pool; -use Composer\Package\BasePackage; use Composer\Package\Link; -use Composer\Repository\ArrayRepository; use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Test\TestCase; diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 303e295cb..25992e58b 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -16,12 +16,10 @@ use Composer\IO\NullIO; use Composer\Repository\ArrayRepository; use Composer\Repository\LockArrayRepository; use Composer\DependencyResolver\DefaultPolicy; -use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Request; use Composer\DependencyResolver\Solver; use Composer\DependencyResolver\SolverProblemsException; use Composer\Package\Link; -use Composer\Repository\InstalledArrayRepository; use Composer\Repository\RepositorySet; use Composer\Test\TestCase; use Composer\Semver\Constraint\MultiConstraint; diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index 0063d1f14..989478386 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/tests/Composer/Test/Downloader/FileDownloaderTest.php @@ -188,7 +188,7 @@ class FileDownloaderTest extends TestCase ->method('getConfig') ->will($this->returnValue($config)); - $expectedUrl = 'foobar'; + $expectedUrl = 'foobar'; $expectedCacheKey = '/'.sha1($expectedUrl).'.'; $dispatcher = new EventDispatcher( @@ -196,7 +196,7 @@ class FileDownloaderTest extends TestCase $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock() ); - $dispatcher->addListener(PluginEvents::PRE_FILE_DOWNLOAD, function ( PreFileDownloadEvent $event ) use ($expectedUrl) { + $dispatcher->addListener(PluginEvents::PRE_FILE_DOWNLOAD, function (PreFileDownloadEvent $event) use ($expectedUrl) { $event->setProcessedUrl($expectedUrl); }); @@ -281,8 +281,8 @@ class FileDownloaderTest extends TestCase ->method('getConfig') ->will($this->returnValue($config)); - $expectedUrl = 'url'; - $customCacheKey = 'xyzzy'; + $expectedUrl = 'url'; + $customCacheKey = 'xyzzy'; $expectedCacheKey = '/'.sha1($customCacheKey).'.'; $dispatcher = new EventDispatcher( @@ -290,7 +290,7 @@ class FileDownloaderTest extends TestCase $this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock() ); - $dispatcher->addListener(PluginEvents::PRE_FILE_DOWNLOAD, function ( PreFileDownloadEvent $event ) use ($customCacheKey) { + $dispatcher->addListener(PluginEvents::PRE_FILE_DOWNLOAD, function (PreFileDownloadEvent $event) use ($customCacheKey) { $event->setCustomCacheKey($customCacheKey); }); diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index c1aeda651..2de8f329f 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -18,8 +18,6 @@ use Composer\Test\TestCase; use Composer\Util\Filesystem; use Composer\Util\Platform; use Prophecy\Argument; -use Composer\Util\ProcessExecutor; -use Composer\Util\Git as GitUtil; class GitDownloaderTest extends TestCase { diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php index 3f8bcc7d3..bbf3e6b98 100644 --- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php +++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php @@ -14,7 +14,6 @@ namespace Composer\Test\EventDispatcher; use Composer\EventDispatcher\Event; use Composer\EventDispatcher\EventDispatcher; -use Composer\EventDispatcher\ScriptExecutionException; use Composer\Installer\InstallerEvents; use Composer\Config; use Composer\Composer; @@ -282,11 +281,11 @@ class EventDispatcherTest extends TestCase public function testDispatcherAppendsDirBinOnPathForEveryListener() { $currentDirectoryBkp = getcwd(); - $composerBinDirBkp = getenv('COMPOSER_BIN_DIR'); + $composerBinDirBkp = getenv('COMPOSER_BIN_DIR'); chdir(__DIR__); putenv('COMPOSER_BIN_DIR=' . __DIR__ . sprintf('%svendor%sbin', DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR)); - $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); + $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock(); $dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->setConstructorArgs(array( $this->createComposerInstance(), $io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE), @@ -310,7 +309,7 @@ class EventDispatcherTest extends TestCase putenv('COMPOSER_BIN_DIR' . ($composerBinDirBkp === false ? '' : '=' . $composerBinDirBkp)); } - static public function createsVendorBinFolderChecksEnvDoesNotContainsBin() + public static function createsVendorBinFolderChecksEnvDoesNotContainsBin() { mkdir(__DIR__ . sprintf('%svendor%sbin', DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), 0700, true); $val = getenv('PATH'); @@ -322,7 +321,7 @@ class EventDispatcherTest extends TestCase self::assertFalse(strpos($val, __DIR__ . sprintf('%svendor%sbin', DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR))); } - static public function createsVendorBinFolderChecksEnvContainsBin() + public static function createsVendorBinFolderChecksEnvContainsBin() { $val = getenv('PATH'); @@ -333,7 +332,8 @@ class EventDispatcherTest extends TestCase self::assertNotFalse(strpos($val, __DIR__ . sprintf('%svendor%sbin', DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR))); } - static public function getTestEnv() { + public static function getTestEnv() + { $val = getenv('ABC'); if ($val !== '123') { throw new \Exception('getenv() did not return the expected value. expected 123 got '. var_export($val, true)); @@ -392,10 +392,10 @@ class EventDispatcherTest extends TestCase ->setConstructorArgs(array( $composer = $this->createComposerInstance(), $io = new BufferIO('', OutputInterface::VERBOSITY_VERBOSE), - $process + $process, )) ->setMethods(array( - 'getListeners' + 'getListeners', )) ->getMock(); @@ -406,11 +406,11 @@ class EventDispatcherTest extends TestCase $dispatcher->expects($this->atLeastOnce()) ->method('getListeners') ->will($this->returnCallback(function (Event $event) { - if($event->getName() === 'hello') { + if ($event->getName() === 'hello') { return array('echo Hello'); } - if($event->getName() === 'helloWorld') { + if ($event->getName() === 'helloWorld') { return array('@hello World'); } diff --git a/tests/Composer/Test/InstalledVersionsTest.php b/tests/Composer/Test/InstalledVersionsTest.php index c136e1584..c1f4bb122 100644 --- a/tests/Composer/Test/InstalledVersionsTest.php +++ b/tests/Composer/Test/InstalledVersionsTest.php @@ -12,7 +12,6 @@ namespace Composer\Test; -use Composer\Test\TestCase; use Composer\InstalledVersions; use Composer\Semver\VersionParser; diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 39bfc730f..0d503a479 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -86,7 +86,7 @@ class InstallerTest extends TestCase $lockJsonMock = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock(); $lockJsonMock->expects($this->any()) ->method('read') - ->will($this->returnCallback(function() use (&$lockData) { + ->will($this->returnCallback(function () use (&$lockData) { return json_decode($lockData, true); })); $lockJsonMock->expects($this->any()) @@ -133,6 +133,7 @@ class InstallerTest extends TestCase foreach ($packages as $package) { $comparable[] = $dumper->dump($package); } + return $comparable; } @@ -229,11 +230,11 @@ class InstallerTest extends TestCase $repositoryManager->setLocalRepository(new InstalledFilesystemRepositoryMock($jsonMock)); // emulate a writable lock file - $lockData = $lock ? json_encode($lock, JsonFile::JSON_PRETTY_PRINT): null; + $lockData = $lock ? json_encode($lock, JsonFile::JSON_PRETTY_PRINT) : null; $lockJsonMock = $this->getMockBuilder('Composer\Json\JsonFile')->disableOriginalConstructor()->getMock(); $lockJsonMock->expects($this->any()) ->method('read') - ->will($this->returnCallback(function() use (&$lockData) { + ->will($this->returnCallback(function () use (&$lockData) { return json_decode($lockData, true); })); $lockJsonMock->expects($this->any()) diff --git a/tests/Composer/Test/Json/ComposerSchemaTest.php b/tests/Composer/Test/Json/ComposerSchemaTest.php index c5ea2e70b..687c1137a 100644 --- a/tests/Composer/Test/Json/ComposerSchemaTest.php +++ b/tests/Composer/Test/Json/ComposerSchemaTest.php @@ -27,7 +27,7 @@ class ComposerSchemaTest extends TestCase 'property' => 'name', 'message' => 'Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$', 'constraint' => 'pattern', - 'pattern' => '^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$' + 'pattern' => '^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$', ), ); diff --git a/tests/Composer/Test/Json/JsonManipulatorTest.php b/tests/Composer/Test/Json/JsonManipulatorTest.php index 9f3b9e7fe..0df2545f5 100644 --- a/tests/Composer/Test/Json/JsonManipulatorTest.php +++ b/tests/Composer/Test/Json/JsonManipulatorTest.php @@ -1814,7 +1814,8 @@ class JsonManipulatorTest extends TestCase ', $manipulator->getContents()); } - public function testAddConfigWithPackage() { + public function testAddConfigWithPackage() + { $manipulator = new JsonManipulator('{ "repositories": [ { diff --git a/tests/Composer/Test/Mock/InstallationManagerMock.php b/tests/Composer/Test/Mock/InstallationManagerMock.php index 1a5f2c99b..adf94b9f4 100644 --- a/tests/Composer/Test/Mock/InstallationManagerMock.php +++ b/tests/Composer/Test/Mock/InstallationManagerMock.php @@ -18,7 +18,6 @@ use Composer\Repository\InstalledRepositoryInterface; use Composer\Package\PackageInterface; use Composer\IO\IOInterface; use Composer\DependencyResolver\Operation\InstallOperation; -use Composer\DependencyResolver\Operation\OperationInterface; use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation; @@ -33,7 +32,6 @@ class InstallationManagerMock extends InstallationManager public function __construct() { - } public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true) diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index 2c633e76b..88706414f 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -76,10 +76,10 @@ class ValidatingArrayLoaderTest extends TestCase 'funding' => array( array( 'type' => 'example', - 'url' => 'https://example.org/fund' + 'url' => 'https://example.org/fund', ), array( - 'url' => 'https://example.org/fund' + 'url' => 'https://example.org/fund', ), ), 'require' => array( @@ -259,7 +259,7 @@ class ValidatingArrayLoaderTest extends TestCase 'foo/-bar', ); $invalidNaming = array(); - foreach($invalidNames as $invalidName) { + foreach ($invalidNames as $invalidName) { $invalidNaming[] = array( array( 'name' => $invalidName, @@ -334,7 +334,7 @@ class ValidatingArrayLoaderTest extends TestCase 'foo/bar---baz', ); $invalidNaming = array(); - foreach($invalidNames as $invalidName) { + foreach ($invalidNames as $invalidName) { $invalidNaming[] = array( array( 'name' => $invalidName, diff --git a/tests/Composer/Test/Platform/HhvmDetectorTest.php b/tests/Composer/Test/Platform/HhvmDetectorTest.php index 600ef7193..68dc4a879 100644 --- a/tests/Composer/Test/Platform/HhvmDetectorTest.php +++ b/tests/Composer/Test/Platform/HhvmDetectorTest.php @@ -32,6 +32,7 @@ class HhvmDetectorTest extends TestCase { if (!defined('HHVM_VERSION_ID')) { self::markTestSkipped('Not running with HHVM'); + return; } $version = $this->hhvmDetector->getVersion(); @@ -42,14 +43,17 @@ class HhvmDetectorTest extends TestCase { if (defined('HHVM_VERSION_ID')) { self::markTestSkipped('Running with HHVM'); + return; } if (PHP_VERSION_ID < 50400) { self::markTestSkipped('Test only works on PHP 5.4+'); + return; } if (Platform::isWindows()) { self::markTestSkipped('Test does not run on Windows'); + return; } $finder = new ExecutableFinder(); diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index ec854ce25..fd6f182bb 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -19,7 +19,6 @@ use Composer\Package\CompletePackage; use Composer\Package\Loader\JsonLoader; use Composer\Package\Loader\ArrayLoader; use Composer\Plugin\PluginManager; -use Symfony\Component\Console\Output\OutputInterface; use Composer\IO\BufferIO; use Composer\EventDispatcher\EventDispatcher; use Composer\Autoload\AutoloadGenerator; diff --git a/tests/Composer/Test/PolyfillTestCase.php b/tests/Composer/Test/PolyfillTestCase.php index 344175ac5..dd40a196b 100644 --- a/tests/Composer/Test/PolyfillTestCase.php +++ b/tests/Composer/Test/PolyfillTestCase.php @@ -12,14 +12,13 @@ namespace Composer\Test { use PHPUnit\Framework\TestCase; - use PHPUnit\Framework\Constraint\IsEqual; use PHPUnit\Framework\Constraint\LogicalNot; - use PHPUnit\Framework\Constraint\RegularExpression; use PHPUnit\Framework\Constraint\StringContains; - use PHPUnit\Framework\Constraint\TraversableContains; if (method_exists('PHPUnit\Framework\TestCase', 'assertStringContainsString')) { - abstract class PolyfillTestCase extends TestCase {} + abstract class PolyfillTestCase extends TestCase + { + } } else { abstract class PolyfillTestCase extends TestCase { @@ -497,7 +496,6 @@ namespace Composer\Test { } } - namespace { foreach (array( 'PHPUnit\Framework\Constraint\IsEqual', @@ -531,8 +529,8 @@ namespace { * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ + namespace PHPUnit\Framework\Constraint { - use Countable; use PHPUnit\Framework\ExpectationFailedException; if (!class_exists('PHPUnit\Framework\Constraint\RegularExpression')) { @@ -631,7 +629,7 @@ namespace PHPUnit\Framework\Constraint { 'starts with ', 'ends with ', 'reference ', - 'not not ' + 'not not ', ); $negatives = array( @@ -644,7 +642,7 @@ namespace PHPUnit\Framework\Constraint { 'starts not with ', 'ends not with ', 'don\'t reference ', - 'not ' + 'not ', ); \preg_match('/(\'[\w\W]*\')([\w\W]*)("[\w\W]*")/i', $string, $matches); @@ -686,9 +684,8 @@ namespace PHPUnit\Framework\Constraint { * @param string $description Additional information about the test * @param bool $returnResult Whether to return a result or throw an exception * - * @return mixed - * * @throws ExpectationFailedException + * @return mixed */ public function evaluate($other, $description = '', $returnResult = false) { diff --git a/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php b/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php index 1f2454599..59e2ea9d8 100644 --- a/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php +++ b/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php @@ -14,7 +14,6 @@ namespace Composer\Test\Question; use Composer\Question\StrictConfirmationQuestion; use Composer\Test\TestCase; -use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\StreamableInputInterface; diff --git a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php index ad7a69009..b164a43d6 100644 --- a/tests/Composer/Test/Repository/ArtifactRepositoryTest.php +++ b/tests/Composer/Test/Repository/ArtifactRepositoryTest.php @@ -15,7 +15,6 @@ namespace Composer\Test\Repository; use Composer\Repository\ArtifactRepository; use Composer\Test\TestCase; use Composer\IO\NullIO; -use Composer\Config; use Composer\Package\BasePackage; class ArtifactRepositoryTest extends TestCase diff --git a/tests/Composer/Test/Repository/ComposerRepositoryTest.php b/tests/Composer/Test/Repository/ComposerRepositoryTest.php index 01e3be4ce..b000088a2 100644 --- a/tests/Composer/Test/Repository/ComposerRepositoryTest.php +++ b/tests/Composer/Test/Repository/ComposerRepositoryTest.php @@ -38,7 +38,7 @@ class ComposerRepositoryTest extends TestCase new NullIO, FactoryMock::createConfig(), $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock(), - $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock() + $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(), )) ->getMock(); @@ -104,7 +104,7 @@ class ComposerRepositoryTest extends TestCase new NullIO, FactoryMock::createConfig(), $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock(), - $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock() + $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(), )) ->setMethods(array('fetchFile')) ->getMock(); @@ -304,7 +304,7 @@ class ComposerRepositoryTest extends TestCase 'packages' => array('foo/bar' => array( 'dev-branch' => array('name' => 'foo/bar'), 'v1.0.0' => array('name' => 'foo/bar'), - )) + )), )))); $repository = new ComposerRepository( diff --git a/tests/Composer/Test/Repository/FilterRepositoryTest.php b/tests/Composer/Test/Repository/FilterRepositoryTest.php index a4e52f4ca..645d5cb09 100644 --- a/tests/Composer/Test/Repository/FilterRepositoryTest.php +++ b/tests/Composer/Test/Repository/FilterRepositoryTest.php @@ -39,7 +39,9 @@ class FilterRepositoryTest extends TestCase $repo = new FilterRepository($this->arrayRepo, $config); $packages = $repo->getPackages(); - $this->assertSame($expected, array_map(function ($p) { return $p->getName(); }, $packages)); + $this->assertSame($expected, array_map(function ($p) { + return $p->getName(); + }, $packages)); } public static function repoMatchingTests() diff --git a/tests/Composer/Test/Repository/Fixtures/installed.php b/tests/Composer/Test/Repository/Fixtures/installed.php index 567414a66..38a4f7192 100644 --- a/tests/Composer/Test/Repository/Fixtures/installed.php +++ b/tests/Composer/Test/Repository/Fixtures/installed.php @@ -1,4 +1,16 @@ - + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return array( 'root' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', @@ -35,13 +47,13 @@ 'pretty_version' => '2.2', 'version' => '2.2.0.0', 'aliases' => array(), - 'reference' => NULL, + 'reference' => null, ), 'c/c' => array( 'pretty_version' => '3.0', 'version' => '3.0.0.0', 'aliases' => array(), - 'reference' => NULL, + 'reference' => null, ), 'foo/impl' => array( 'provided' => array( @@ -49,7 +61,7 @@ '1.2', '1.4', '2.0', - ) + ), ), 'foo/impl2' => array( 'provided' => array( diff --git a/tests/Composer/Test/Repository/PathRepositoryTest.php b/tests/Composer/Test/Repository/PathRepositoryTest.php index 5833913e7..1d654c02f 100644 --- a/tests/Composer/Test/Repository/PathRepositoryTest.php +++ b/tests/Composer/Test/Repository/PathRepositoryTest.php @@ -12,10 +12,8 @@ namespace Composer\Test\Repository; -use Composer\Package\Loader\ArrayLoader; use Composer\Repository\PathRepository; use Composer\Test\TestCase; -use Composer\Package\Version\VersionParser; class PathRepositoryTest extends TestCase { diff --git a/tests/Composer/Test/Repository/PlatformRepositoryTest.php b/tests/Composer/Test/Repository/PlatformRepositoryTest.php index caa5174db..faec2f8d5 100644 --- a/tests/Composer/Test/Repository/PlatformRepositoryTest.php +++ b/tests/Composer/Test/Repository/PlatformRepositoryTest.php @@ -4,7 +4,7 @@ * This file is part of Composer. * * (c) Nils Adermann - * Jordi Boggiano + * Jordi Boggiano * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -42,8 +42,8 @@ class PlatformRepositoryTest extends TestCase 'PHP_VERSION' => '7.1.33', ), array( - 'php' => '7.1.33' - ) + 'php' => '7.1.33', + ), ), array( array( @@ -121,14 +121,14 @@ class PlatformRepositoryTest extends TestCase $runtime ->method('hasConstant') ->willReturnMap( - array_map(function($constant) { + array_map(function ($constant) { return array($constant, null, true); }, array_keys($constants)) ); $runtime ->method('getConstant') ->willReturnMap( - array_map(function($constant, $value) { + array_map(function ($constant, $value) { return array($constant, null, $value); }, array_keys($constants), array_values($constants)) ); @@ -197,7 +197,7 @@ Default heartbeats interval => 0', array( 'lib-amqp-protocol' => '0.9.1', 'lib-amqp-librabbitmq' => '0.9.0', - ) + ), ), 'bz2' => array( 'bz2', @@ -208,7 +208,7 @@ BZip2 Support => Enabled Stream Wrapper support => compress.bzip2:// Stream Filter support => bzip2.decompress, bzip2.compress BZip2 Version => 1.0.5, 6-Sept-2010', - array('lib-bz2' => '1.0.5') + array('lib-bz2' => '1.0.5'), ), 'curl' => array( 'curl', @@ -250,7 +250,7 @@ curl.cainfo => no value => no value', 'lib-curl-zlib' => '1.2.8', 'lib-curl-libssh2' => '1.4.3', ), - array(array('curl_version', array(), array('version' => '2.0.0'))) + array(array('curl_version', array(), array('version' => '2.0.0'))), ), 'curl: OpenSSL fips version' => array( @@ -293,7 +293,7 @@ curl.cainfo => no value => no value', 'lib-curl-zlib' => '1.2.8', 'lib-curl-libssh2' => '1.4.3', ), - array(array('curl_version', array(), array('version' => '2.0.0'))) + array(array('curl_version', array(), array('version' => '2.0.0'))), ), 'curl: gnutls' => array( 'curl', @@ -328,7 +328,7 @@ ZLib Version => 1.2.3.4', 'lib-curl-zlib' => '1.2.3.4', 'lib-curl-gnutls' => array('2.12.14', array('lib-curl-openssl')), ), - array(array('curl_version', array(), array('version' => '7.22.0'))) + array(array('curl_version', array(), array('version' => '7.22.0'))), ), 'curl: NSS' => array( 'curl', @@ -363,7 +363,7 @@ libSSH Version => libssh2/1.4.1', 'lib-curl-zlib' => '1.2.5', 'lib-curl-libssh2' => '1.4.1', ), - array(array('curl_version', array(), array('version' => '7.24.0'))) + array(array('curl_version', array(), array('version' => '7.24.0'))), ), 'curl: libssh not libssh2' => array( 'curl', @@ -424,7 +424,7 @@ Default timezone => Europe/Berlin', array( 'lib-date-timelib' => '2018.03', 'lib-date-zoneinfo' => '2020.1', - ) + ), ), 'date: before timelib was extracted' => array( 'date', @@ -438,7 +438,7 @@ Default timezone => Europe/Amsterdam', array( 'lib-date-zoneinfo' => '2013.2', 'lib-date-timelib' => false, - ) + ), ), 'date: internal zoneinfo' => array( array('date', 'timezonedb'), @@ -449,7 +449,7 @@ date/time support => enabled "Olson" Timezone Database Version => 2020.1 Timezone Database => internal Default timezone => UTC', - array('lib-date-zoneinfo' => '2020.1') + array('lib-date-zoneinfo' => '2020.1'), ), 'date: external zoneinfo' => array( array('date', 'timezonedb'), @@ -460,7 +460,7 @@ date/time support => enabled "Olson" Timezone Database Version => 2020.1 Timezone Database => external Default timezone => UTC', - array('lib-timezonedb-zoneinfo' => array('2020.1', array('lib-date-zoneinfo'))) + array('lib-timezonedb-zoneinfo' => array('2020.1', array('lib-date-zoneinfo'))), ), 'date: zoneinfo 0.system' => array( 'date', @@ -482,7 +482,7 @@ date.sunrise_zenith => 90.583333 => 90.583333', array( 'lib-date-zoneinfo' => '0', 'lib-date-timelib' => '2018.03', - ) + ), ), 'fileinfo' => array( 'fileinfo', @@ -491,7 +491,7 @@ fileinfo fileinfo support => enabled libmagic => 537', - array('lib-fileinfo-libmagic' => '537') + array('lib-fileinfo-libmagic' => '537'), ), 'gd' => array( 'gd', @@ -522,7 +522,7 @@ gd.jpeg_ignore_warning => 1 => 1', 'lib-gd-libpng' => '1.6.34', ), array(), - array(array('GD_VERSION', null, '1.2.3')) + array(array('GD_VERSION', null, '1.2.3')), ), 'gd: libjpeg version variation' => array( 'gd', @@ -553,7 +553,7 @@ gd.jpeg_ignore_warning => 1 => 1', 'lib-gd-libpng' => '1.6.35', ), array(), - array(array('GD_VERSION', null, '1.2.3')) + array(array('GD_VERSION', null, '1.2.3')), ), 'gd: libxpm' => array( 'gd', @@ -588,21 +588,21 @@ gd.jpeg_ignore_warning => 1 => 1', 'lib-gd-libxpm' => '3.4.11', ), array(), - array(array('GD_VERSION', null, '2.2.5')) + array(array('GD_VERSION', null, '2.2.5')), ), 'iconv' => array( 'iconv', null, array('lib-iconv' => '1.2.4'), array(), - array(array('ICONV_VERSION', null, '1.2.4')) + array(array('ICONV_VERSION', null, '1.2.4')), ), 'gmp' => array( 'gmp', null, array('lib-gmp' => '6.1.0'), array(), - array(array('GMP_VERSION', null, '6.1.0')) + array(array('GMP_VERSION', null, '6.1.0')), ), 'intl' => array( 'intl', @@ -633,7 +633,7 @@ intl.use_exceptions => 0 => 0', array( array('ResourceBundle'), array('IntlChar'), - ) + ), ), 'intl: INTL_ICU_VERSION not defined' => array( 'intl', @@ -652,7 +652,7 @@ ICU Data version => 57.1', array('lib-imagick-imagemagick' => array('6.2.9', array('lib-imagick'))), array(), array(), - array(array('Imagick', array(), new ImagickStub('ImageMagick 6.2.9 Q16 x86_64 2018-05-18 http://www.imagemagick.org'))) + array(array('Imagick', array(), new ImagickStub('ImageMagick 6.2.9 Q16 x86_64 2018-05-18 http://www.imagemagick.org'))), ), 'imagick: 7.x' => array( 'imagick', @@ -660,7 +660,7 @@ ICU Data version => 57.1', array('lib-imagick-imagemagick' => array('7.0.8.34', array('lib-imagick'))), array(), array(), - array(array('Imagick', array(), new ImagickStub('ImageMagick 7.0.8-34 Q16 x86_64 2019-03-23 https://imagemagick.org'))) + array(array('Imagick', array(), new ImagickStub('ImageMagick 7.0.8-34 Q16 x86_64 2019-03-23 https://imagemagick.org'))), ), 'ldap' => array( 'ldap', @@ -677,21 +677,21 @@ SASL Support => Enabled Directive => Local Value => Master Value ldap.max_links => Unlimited => Unlimited', - array('lib-ldap-openldap' => '2.4.50') + array('lib-ldap-openldap' => '2.4.50'), ), 'libxml' => array( 'libxml', null, array('lib-libxml' => '2.1.5'), array(), - array(array('LIBXML_DOTTED_VERSION', null, '2.1.5')) + array(array('LIBXML_DOTTED_VERSION', null, '2.1.5')), ), 'libxml: related extensions' => array( array('libxml', 'dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter'), null, array('lib-libxml' => array('2.1.5', array(), array('lib-dom-libxml', 'lib-simplexml-libxml', 'lib-xml-libxml', 'lib-xmlreader-libxml', 'lib-xmlwriter-libxml'))), array(), - array(array('LIBXML_DOTTED_VERSION', null, '2.1.5')) + array(array('LIBXML_DOTTED_VERSION', null, '2.1.5')), ), 'mbstring' => array( 'mbstring', @@ -712,7 +712,7 @@ Multibyte regex (oniguruma) version => 6.1.3', 'lib-mbstring-oniguruma' => '7.0.0', ), array(), - array(array('MB_ONIGURUMA_VERSION', null, '7.0.0')) + array(array('MB_ONIGURUMA_VERSION', null, '7.0.0')), ), 'mbstring: no MB_ONIGURUMA constant' => array( 'mbstring', @@ -731,7 +731,7 @@ Multibyte regex (oniguruma) version => 6.1.3', array( 'lib-mbstring-libmbfl' => '1.3.2', 'lib-mbstring-oniguruma' => '6.1.3', - ) + ), ), 'mbstring: no MB_ONIGURUMA constant <7.40' => array( 'mbstring', @@ -766,63 +766,63 @@ Session support => yes igbinary support => yes json support => yes msgpack support => yes', - array('lib-memcached-libmemcached' => '1.0.18') + array('lib-memcached-libmemcached' => '1.0.18'), ), 'openssl' => array( 'openssl', null, array('lib-openssl' => '1.1.1.7'), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g 21 Apr 2020')) + array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g 21 Apr 2020')), ), 'openssl: two letters suffix' => array( 'openssl', null, array('lib-openssl' => '0.9.8.33'), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 0.9.8zg 21 Apr 2020')) + array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 0.9.8zg 21 Apr 2020')), ), 'openssl: pre release is treated as alpha' => array( 'openssl', null, array('lib-openssl' => '1.1.1.7-alpha1'), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-pre1 21 Apr 2020')) + array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-pre1 21 Apr 2020')), ), 'openssl: beta release' => array( 'openssl', null, array('lib-openssl' => '1.1.1.7-beta2'), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-beta2 21 Apr 2020')) + array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-beta2 21 Apr 2020')), ), 'openssl: alpha release' => array( 'openssl', null, array('lib-openssl' => '1.1.1.7-alpha4'), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-alpha4 21 Apr 2020')) + array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-alpha4 21 Apr 2020')), ), 'openssl: rc release' => array( 'openssl', null, array('lib-openssl' => '1.1.1.7-rc2'), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-rc2 21 Apr 2020')) + array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-rc2 21 Apr 2020')), ), 'openssl: fips' => array( 'openssl', null, array('lib-openssl-fips' => array('1.1.1.7', array(), array('lib-openssl'))), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-fips 21 Apr 2020')) + array(array('OPENSSL_VERSION_TEXT', null, 'OpenSSL 1.1.1g-fips 21 Apr 2020')), ), 'openssl: LibreSSL' => array( 'openssl', null, array('lib-openssl' => '2.0.1.0'), array(), - array(array('OPENSSL_VERSION_TEXT', null, 'LibreSSL 2.0.1')) + array(array('OPENSSL_VERSION_TEXT', null, 'LibreSSL 2.0.1')), ), 'mysqlnd' => array( 'mysqlnd', @@ -842,7 +842,7 @@ Collecting memory statistics => Yes Tracing => n/a Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_sha256_password API Extensions => pdo_mysql,mysqli', - array('lib-mysqlnd-mysqlnd' => '5.0.11-dev') + array('lib-mysqlnd-mysqlnd' => '5.0.11-dev'), ), 'pdo_mysql' => array( 'pdo_mysql', @@ -854,7 +854,7 @@ Client API version => mysqlnd 5.0.10-dev - 20150407 - $Id: 38fea24f2847fa7519001 Directive => Local Value => Master Value pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock', - array('lib-pdo_mysql-mysqlnd' => '5.0.10-dev') + array('lib-pdo_mysql-mysqlnd' => '5.0.10-dev'), ), 'mongodb' => array( 'mongodb', @@ -882,7 +882,7 @@ mongodb.debug => no value => no value', array( 'lib-mongodb-libmongoc' => '1.15.2', 'lib-mongodb-libbson' => '1.15.2', - ) + ), ), 'pcre' => array( 'pcre', @@ -899,7 +899,7 @@ PCRE JIT Target => x86 64bit (little endian + unaligned)', 'lib-pcre-unicode' => '11.0.0', ), array(), - array(array('PCRE_VERSION', null, '10.33 2019-04-16')) + array(array('PCRE_VERSION', null, '10.33 2019-04-16')), ), 'pcre: no unicode version included' => array( 'pcre', @@ -917,7 +917,7 @@ pcre.recursion_limit => 100000 => 100000 'lib-pcre' => '8.38', ), array(), - array(array('PCRE_VERSION', null, '8.38 2015-11-23')) + array(array('PCRE_VERSION', null, '8.38 2015-11-23')), ), 'pgsql' => array( 'pgsql', @@ -939,7 +939,7 @@ pgsql.max_links => Unlimited => Unlimited pgsql.auto_reset_persistent => Off => Off pgsql.ignore_notice => Off => Off pgsql.log_notice => Off => Off', - array('lib-pgsql-libpq' => '12.2') + array('lib-pgsql-libpq' => '12.2'), ), 'pdo_pgsql' => array( 'pdo_pgsql', @@ -950,21 +950,21 @@ PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version => 12.1 Module version => 7.1.33 Revision => $Id: 9c5f356c77143981d2e905e276e439501fe0f419 $', - array('lib-pdo_pgsql-libpq' => '12.1') + array('lib-pdo_pgsql-libpq' => '12.1'), ), 'libsodium' => array( 'libsodium', null, array('lib-libsodium' => '1.0.17'), array(), - array(array('SODIUM_LIBRARY_VERSION', null, '1.0.17')) + array(array('SODIUM_LIBRARY_VERSION', null, '1.0.17')), ), 'libsodium: different extension name' => array( 'sodium', null, array('lib-libsodium' => '1.0.15'), array(), - array(array('SODIUM_LIBRARY_VERSION', null, '1.0.15')) + array(array('SODIUM_LIBRARY_VERSION', null, '1.0.15')), ), 'pdo_sqlite' => array( 'pdo_sqlite', @@ -974,7 +974,7 @@ pdo_sqlite PDO Driver for SQLite 3.x => enabled SQLite Library => 3.32.3 ', - array('lib-pdo_sqlite-sqlite' => '3.32.3') + array('lib-pdo_sqlite-sqlite' => '3.32.3'), ), 'sqlite3' => array( 'sqlite3', @@ -988,7 +988,7 @@ SQLite Library => 3.31.0 Directive => Local Value => Master Value sqlite3.extension_dir => no value => no value sqlite3.defensive => 1 => 1', - array('lib-sqlite3-sqlite' => '3.31.0') + array('lib-sqlite3-sqlite' => '3.31.0'), ), 'ssh2' => array( 'ssh2', @@ -999,7 +999,7 @@ SSH2 support => enabled extension version => 1.2 libssh2 version => 1.8.0 banner => SSH-2.0-libssh2_1.8.0', - array('lib-ssh2-libssh2' => '1.8.0') + array('lib-ssh2-libssh2' => '1.8.0'), ), 'yaml' => array( 'yaml', @@ -1017,7 +1017,7 @@ yaml.decode_php => 0 => 0 yaml.output_canonical => 0 => 0 yaml.output_indent => 2 => 2 yaml.output_width => 80 => 80', - array('lib-yaml-libyaml' => '0.2.2') + array('lib-yaml-libyaml' => '0.2.2'), ), 'xsl' => array( 'xsl', @@ -1034,7 +1034,7 @@ libexslt Version => 1.1.29', 'lib-libxslt-libxml' => '2.9.8', ), array(), - array(array('LIBXSLT_DOTTED_VERSION', null, '1.1.29')) + array(array('LIBXSLT_DOTTED_VERSION', null, '1.1.29')), ), 'zip' => array( 'zip', @@ -1068,11 +1068,11 @@ Linked Version => 1.2.11', /** * @dataProvider getLibraryTestCases * - * @param string|string[] $extensions - * @param string|null $info + * @param string|string[] $extensions + * @param string|null $info * @param array $expectations - * @param array $functions - * @param array $constants + * @param array $functions + * @param array $constants * @param array $classDefinitions */ public function testLibraryInformation( @@ -1082,9 +1082,8 @@ Linked Version => 1.2.11', array $functions = array(), array $constants = array(), array $classDefinitions = array() - ) - { - $extensions = (array)$extensions; + ) { + $extensions = (array) $extensions; $extensionVersion = '100.200.300'; @@ -1093,11 +1092,10 @@ Linked Version => 1.2.11', ->method('getExtensions') ->willReturn($extensions); - $runtime ->method('getExtensionVersion') ->willReturnMap( - array_map(function($extension) use ($extensionVersion) { + array_map(function ($extension) use ($extensionVersion) { return array($extension, $extensionVersion); }, $extensions) ); @@ -1119,7 +1117,9 @@ Linked Version => 1.2.11', ->method('hasConstant') ->willReturnMap( array_map( - function ($constantDefintion) { return array($constantDefintion[0], $constantDefintion[1], true); }, + function ($constantDefintion) { + return array($constantDefintion[0], $constantDefintion[1], true); + }, $constants ) ); @@ -1131,7 +1131,9 @@ Linked Version => 1.2.11', ->method('hasClass') ->willReturnMap( array_map( - function ($classDefinition) { return array($classDefinition[0], true); }, + function ($classDefinition) { + return array($classDefinition[0], true); + }, $classDefinitions ) ); @@ -1142,25 +1144,28 @@ Linked Version => 1.2.11', $platformRepository = new PlatformRepository(array(), array(), $runtime); $expectations = array_map(function ($expectation) { - return array_replace(array(null, array(), array()), (array) $expectation); - }, $expectations); + return array_replace(array(null, array(), array()), (array) $expectation); + }, $expectations); $libraries = array_map( function ($package) { return $package['name']; - }, array_filter( - $platformRepository->search('lib', PlatformRepository::SEARCH_NAME), - function ($package) { - return strpos($package['name'], 'lib-') === 0; - } - ) + }, + array_filter( + $platformRepository->search('lib', PlatformRepository::SEARCH_NAME), + function ($package) { + return strpos($package['name'], 'lib-') === 0; + } + ) ); - $expectedLibraries = array_merge(array_keys(array_filter($expectations,function($expectation) { return $expectation[0] !== false; }))); + $expectedLibraries = array_merge(array_keys(array_filter($expectations, function ($expectation) { + return $expectation[0] !== false; + }))); self::assertCount(count(array_filter($expectedLibraries)), $libraries, sprintf('Expected: %s, got %s', var_export($expectedLibraries, true), var_export($libraries, true))); - $expectations = array_merge($expectations, array_combine(array_map(function($extension) { - return 'ext-'.$extension; - }, $extensions), array_fill(0, count($extensions), array($extensionVersion, array(), array())))); + $expectations = array_merge($expectations, array_combine(array_map(function ($extension) { + return 'ext-'.$extension; + }, $extensions), array_fill(0, count($extensions), array($extensionVersion, array(), array())))); foreach ($expectations as $packageName => $expectation) { list($expectedVersion, $expectedReplaces, $expectedProvides) = $expectation; @@ -1189,10 +1194,12 @@ Linked Version => 1.2.11', } } -class ResourceBundleStub { +class ResourceBundleStub +{ const STUB_VERSION = '32.0.1'; - public static function create($locale, $bundleName, $fallback) { + public static function create($locale, $bundleName, $fallback) + { Assert::assertSame(3, func_num_args()); Assert::assertSame('root', $locale); Assert::assertSame('ICUDATA', $bundleName); @@ -1201,7 +1208,8 @@ class ResourceBundleStub { return new self(); } - public function get($field) { + public function get($field) + { Assert::assertSame(1, func_num_args()); Assert::assertSame('Version', $field); @@ -1209,14 +1217,17 @@ class ResourceBundleStub { } } -class ImagickStub { +class ImagickStub +{ private $versionString; - public function __construct($versionString) { + public function __construct($versionString) + { $this->versionString = $versionString; } - public function getVersion() { + public function getVersion() + { Assert::assertSame(0, func_num_args()); return array('versionString' => $this->versionString); diff --git a/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php b/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php index f39a3b8f7..a6953f834 100644 --- a/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php @@ -16,7 +16,6 @@ use Composer\Repository\Vcs\FossilDriver; use Composer\Config; use Composer\Test\TestCase; use Composer\Util\Filesystem; -use Composer\Util\Platform; class FossilDriverTest extends TestCase { diff --git a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php index 713d1f43d..2dae0ab21 100644 --- a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php @@ -116,22 +116,22 @@ class GitBitbucketDriverTest extends TestCase ->method('get') ->withConsecutive( array( - $urls[0], array() + $urls[0], array(), ), array( - $urls[1], array() + $urls[1], array(), ), array( - $urls[2], array() + $urls[2], array(), ), array( - $urls[3], array() + $urls[3], array(), ), array( - $urls[4], array() + $urls[4], array(), ), array( - $urls[5], array() + $urls[5], array(), ) ) ->willReturnOnConsecutiveCalls( diff --git a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php index 29c153d4b..7c2727c20 100644 --- a/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php @@ -205,7 +205,7 @@ class GitHubDriverTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config,$httpDownloader, $process); + $gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, $httpDownloader, $process); $gitHubDriver->initialize(); $this->setAttribute($gitHubDriver, 'tags', array($identifier => $sha)); diff --git a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php index 41ee56ff6..9c61c3105 100644 --- a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php @@ -16,7 +16,6 @@ use Composer\Repository\Vcs\SvnDriver; use Composer\Config; use Composer\Test\TestCase; use Composer\Util\Filesystem; -use Composer\Util\Platform; class SvnDriverTest extends TestCase { diff --git a/tests/Composer/Test/TestCase.php b/tests/Composer/Test/TestCase.php index ab115a474..4f8fcc48c 100644 --- a/tests/Composer/Test/TestCase.php +++ b/tests/Composer/Test/TestCase.php @@ -13,7 +13,6 @@ namespace Composer\Test; use Composer\Semver\VersionParser; -use Composer\Package\AliasPackage; use Composer\Package\RootPackageInterface; use Composer\Package\PackageInterface; use Composer\Semver\Constraint\Constraint; diff --git a/tests/Composer/Test/Util/AuthHelperTest.php b/tests/Composer/Test/Util/AuthHelperTest.php index d198b26f2..33f64382a 100644 --- a/tests/Composer/Test/Util/AuthHelperTest.php +++ b/tests/Composer/Test/Util/AuthHelperTest.php @@ -16,7 +16,6 @@ use Composer\IO\IOInterface; use Composer\Test\TestCase; use Composer\Util\AuthHelper; use Composer\Util\Bitbucket; -use RuntimeException; /** * @author Michael Chekin @@ -48,7 +47,7 @@ class AuthHelperTest extends TestCase { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $origin = 'http://example.org'; $url = 'file://' . __FILE__; @@ -68,13 +67,13 @@ class AuthHelperTest extends TestCase { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $origin = 'http://example.org'; $url = 'file://' . __FILE__; $auth = array( 'username' => 'my_username', - 'password' => 'bearer' + 'password' => 'bearer', ); $this->expectsAuthentication($origin, $auth); @@ -91,13 +90,13 @@ class AuthHelperTest extends TestCase { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $origin = 'github.com'; $url = 'https://api.github.com/'; $auth = array( 'username' => 'my_username', - 'password' => 'x-oauth-basic' + 'password' => 'x-oauth-basic', ); $this->expectsAuthentication($origin, $auth); @@ -118,13 +117,13 @@ class AuthHelperTest extends TestCase { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $origin = 'gitlab.com'; $url = 'https://api.gitlab.com/'; $auth = array( 'username' => 'my_username', - 'password' => 'oauth2' + 'password' => 'oauth2', ); $this->expectsAuthentication($origin, $auth); @@ -163,13 +162,13 @@ class AuthHelperTest extends TestCase { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $origin = 'gitlab.com'; $url = 'https://api.gitlab.com/'; $auth = array( 'username' => 'my_username', - 'password' => $password + 'password' => $password, ); $this->expectsAuthentication($origin, $auth); @@ -195,13 +194,13 @@ class AuthHelperTest extends TestCase { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $origin = 'bitbucket.org'; $url = 'https://bitbucket.org/site/oauth2/authorize'; $auth = array( 'username' => 'x-token-auth', - 'password' => 'my_password' + 'password' => 'my_password', ); $this->expectsAuthentication($origin, $auth); @@ -240,12 +239,12 @@ class AuthHelperTest extends TestCase { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $origin = 'bitbucket.org'; $auth = array( 'username' => 'x-token-auth', - 'password' => 'my_password' + 'password' => 'my_password', ); $this->expectsAuthentication($origin, $auth); @@ -269,24 +268,24 @@ class AuthHelperTest extends TestCase 'bitbucket.org', array( 'username' => 'x-token-auth', - 'password' => 'my_password' - ) + 'password' => 'my_password', + ), ), array( 'https://some-api.url.com', 'some-api.url.com', array( 'username' => 'my_username', - 'password' => 'my_password' - ) + 'password' => 'my_password', + ), ), array( 'https://gitlab.com', 'gitlab.com', array( 'username' => 'my_username', - 'password' => 'my_password' - ) + 'password' => 'my_password', + ), ), ); } @@ -296,13 +295,13 @@ class AuthHelperTest extends TestCase * * @param string $url * @param string $origin - * @param array $auth + * @param array $auth */ public function testAddAuthenticationHeaderWithBasicHttpAuthentication($url, $origin, $auth) { $headers = array( 'Accept-Encoding: gzip', - 'Connection: close' + 'Connection: close', ); $this->expectsAuthentication($origin, $auth); @@ -343,8 +342,10 @@ class AuthHelperTest extends TestCase public function testIsPublicBitBucketDownloadWithNonBitbucketPublicUrl() { - $this->assertFalse($this->authHelper->isPublicBitBucketDownload( - 'https://bitbucket.org/site/oauth2/authorize') + $this->assertFalse( + $this->authHelper->isPublicBitBucketDownload( + 'https://bitbucket.org/site/oauth2/authorize' + ) ); } @@ -354,7 +355,7 @@ class AuthHelperTest extends TestCase $storeAuth = true; $auth = array( 'username' => 'my_username', - 'password' => 'my_password' + 'password' => 'my_password', ); /** @var \Composer\Config\ConfigSourceInterface|\PHPUnit_Framework_MockObject_MockObject $configSource */ @@ -386,7 +387,7 @@ class AuthHelperTest extends TestCase $storeAuth = 'prompt'; $auth = array( 'username' => 'my_username', - 'password' => 'my_password' + 'password' => 'my_password', ); $answer = 'y'; $configSourceName = 'https://api.gitlab.com/source'; @@ -414,7 +415,6 @@ class AuthHelperTest extends TestCase 'y' ) ->willReturnCallback(function ($question, $validator, $attempts, $default) use ($answer) { - $validator($answer); return $answer; @@ -463,7 +463,6 @@ class AuthHelperTest extends TestCase 'y' ) ->willReturnCallback(function ($question, $validator, $attempts, $default) use ($answer) { - $validator($answer); return $answer; @@ -504,7 +503,6 @@ class AuthHelperTest extends TestCase 'y' ) ->willReturnCallback(function ($question, $validator, $attempts, $default) use ($answer) { - $validator($answer); return $answer; @@ -515,7 +513,7 @@ class AuthHelperTest extends TestCase /** * @param string $origin - * @param array $auth + * @param array $auth */ private function expectsAuthentication($origin, $auth) { diff --git a/tests/Composer/Test/Util/BitbucketTest.php b/tests/Composer/Test/Util/BitbucketTest.php index 539918c63..3262c2fe8 100644 --- a/tests/Composer/Test/Util/BitbucketTest.php +++ b/tests/Composer/Test/Util/BitbucketTest.php @@ -240,8 +240,7 @@ class BitbucketTest extends TestCase ->method('writeError') ->withConsecutive( array('Invalid OAuth consumer provided.'), - array( - 'You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org "') + array('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org "') ); $this->httpDownloader->expects($this->once()) @@ -256,7 +255,7 @@ class BitbucketTest extends TestCase ), ) ) - ->willThrowException(new \Composer\Downloader\TransportException('HTTP/1.1 401 UNAUTHORIZED',401)); + ->willThrowException(new \Composer\Downloader\TransportException('HTTP/1.1 401 UNAUTHORIZED', 401)); $this->assertEquals('', $this->bitbucket->requestToken($this->origin, $this->username, $this->password)); } @@ -273,7 +272,7 @@ class BitbucketTest extends TestCase ->method('setAuthentication') ->with($this->origin, $this->username, $this->password); - $exception = new \Composer\Downloader\TransportException('HTTP/1.1 404 NOT FOUND',404); + $exception = new \Composer\Downloader\TransportException('HTTP/1.1 404 NOT FOUND', 404); $this->httpDownloader->expects($this->once()) ->method('get') ->with( @@ -452,7 +451,7 @@ class BitbucketTest extends TestCase public function testAuthorizeOAuthWithWrongOriginUrl() { - $this->assertFalse($this->bitbucket->authorizeOAuth('non-' . $this->origin)); + $this->assertFalse($this->bitbucket->authorizeOAuth('non-' . $this->origin)); } public function testAuthorizeOAuthWithoutAvailableGitConfigToken() diff --git a/tests/Composer/Test/Util/GitTest.php b/tests/Composer/Test/Util/GitTest.php index e7f46d55a..66ad8ffa0 100644 --- a/tests/Composer/Test/Util/GitTest.php +++ b/tests/Composer/Test/Util/GitTest.php @@ -1,5 +1,15 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer\Test\Util; use Composer\Config; diff --git a/tests/Composer/Test/Util/Http/ProxyHelperTest.php b/tests/Composer/Test/Util/Http/ProxyHelperTest.php index 2b31fb470..c79ad2503 100644 --- a/tests/Composer/Test/Util/Http/ProxyHelperTest.php +++ b/tests/Composer/Test/Util/Http/ProxyHelperTest.php @@ -78,8 +78,8 @@ class ProxyHelperTest extends TestCase // url, expected return array( 'lowercases-scheme' => array('HTTP://proxy.com:8888', 'http://proxy.com:8888'), - 'adds-http-port' => array('http://proxy.com', 'http://proxy.com:80'), - 'adds-https-port' => array('https://proxy.com', 'https://proxy.com:443'), + 'adds-http-port' => array('http://proxy.com', 'http://proxy.com:80'), + 'adds-https-port' => array('https://proxy.com', 'https://proxy.com:443'), ); } @@ -117,7 +117,7 @@ class ProxyHelperTest extends TestCase public function dataCGIOverrides() { - // server, expected, list index + // server, expected, list index return array( array(array('http_proxy' => 'http://http.com', 'CGI_HTTP_PROXY' => 'http://cgi.com'), 'http://cgi.com:80', 0), array(array('http_proxy' => 'http://http.com', 'cgi_http_proxy' => 'http://cgi.com'), 'http://http.com:80', 0), @@ -182,8 +182,8 @@ class ProxyHelperTest extends TestCase // $requestUrl, expected return array( - 'http' => array('http://repo.org', $options), - 'https' => array('https://repo.org', array()), + 'http' => array('http://repo.org', $options), + 'https' => array('https://repo.org', array()), 'no-scheme' => array('repo.org', array()), ); } diff --git a/tests/Composer/Test/Util/Http/ProxyManagerTest.php b/tests/Composer/Test/Util/Http/ProxyManagerTest.php index 492eed126..1a2cc4e84 100644 --- a/tests/Composer/Test/Util/Http/ProxyManagerTest.php +++ b/tests/Composer/Test/Util/Http/ProxyManagerTest.php @@ -12,7 +12,6 @@ namespace Composer\Test\Util\Http; -use Composer\Util\Http\ProxyHelper; use Composer\Util\Http\ProxyManager; use Composer\Test\TestCase; @@ -109,8 +108,7 @@ class ProxyManagerTest extends TestCase 'proxy' => 'tcp://proxy.com:80', 'header' => 'Proxy-Authorization: Basic dXNlcjpwQHNz', 'request_fulluri' => true, - ) - ), + )), false, 'http://user:***@proxy.com:80', ), @@ -118,8 +116,7 @@ class ProxyManagerTest extends TestCase $server, 'https://repo.org', 'https://proxy.com:443', array('http' => array( 'proxy' => 'ssl://proxy.com:443', - ) - ), + )), true, 'https://proxy.com:443', ), @@ -156,12 +153,12 @@ class ProxyManagerTest extends TestCase array( array('http_proxy' => 'http://user:p%40ss@proxy.com:80'), true, - 'http=http://user:***@proxy.com:80' + 'http=http://user:***@proxy.com:80', ), array( array('http_proxy' => 'proxy.com:80', 'https_proxy' => 'proxy.com:80'), true, - 'http=proxy.com:80, https=proxy.com:80' + 'http=proxy.com:80, https=proxy.com:80', ), ); } diff --git a/tests/Composer/Test/Util/Http/RequestProxyTest.php b/tests/Composer/Test/Util/Http/RequestProxyTest.php index 6f571eb20..59996d87b 100644 --- a/tests/Composer/Test/Util/Http/RequestProxyTest.php +++ b/tests/Composer/Test/Util/Http/RequestProxyTest.php @@ -31,9 +31,9 @@ class RequestProxyTest extends TestCase { // url, secure return array( - 'basic' => array('http://proxy.com:80', false), - 'secure' => array('https://proxy.com:443', true), - 'none' => array('', false), + 'basic' => array('http://proxy.com:80', false), + 'secure' => array('https://proxy.com:443', true), + 'none' => array('', false), ); } diff --git a/tests/Composer/Test/Util/PackageSorterTest.php b/tests/Composer/Test/Util/PackageSorterTest.php index 8704a3af0..3dc1535ec 100644 --- a/tests/Composer/Test/Util/PackageSorterTest.php +++ b/tests/Composer/Test/Util/PackageSorterTest.php @@ -110,7 +110,9 @@ class PackageSorterTest extends TestCase public function testSortingOrdersDependenciesHigherThanPackage($packages, $expectedOrderedList) { $sortedPackages = PackageSorter::sortPackages($packages); - $sortedPackageNames = array_map(function ($package) { return $package->getName(); }, $sortedPackages); + $sortedPackageNames = array_map(function ($package) { + return $package->getName(); + }, $sortedPackages); self::assertSame($expectedOrderedList, $sortedPackageNames); } diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index be4af49f1..988682c01 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -122,9 +122,9 @@ class ProcessExecutorTest extends TestCase $start = microtime(true); /** @var Promise $promise */ $promise = $process->executeAsync('sleep 2'); - $this->assertEquals(1, $process->countActiveJobs()); + $this->assertEquals(1, $process->countActiveJobs()); $promise->cancel(); - $this->assertEquals(0, $process->countActiveJobs()); + $this->assertEquals(0, $process->countActiveJobs()); $end = microtime(true); $this->assertTrue($end - $start < 0.5, 'Canceling took longer than it should, lasted '.($end - $start)); } diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index f51dd1942..98f0114db 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -176,14 +176,11 @@ class RemoteFilesystemTest extends TestCase $fs->expects($this->once())->method('getRemoteContents') ->willReturnCallback(function ($originUrl, $fileUrl, $ctx, &$http_response_header) { - $http_response_header = array('http/1.1 401 unauthorized'); return ''; - }); - $file = tempnam(sys_get_temp_dir(), 'z'); unlink($file); @@ -205,30 +202,25 @@ class RemoteFilesystemTest extends TestCase ->method('promptAuthIfNeeded') ->willReturn(array( 'storeAuth' => true, - 'retry' => true + 'retry' => true, )); $fs->expects($this->at(0)) ->method('getRemoteContents') ->willReturnCallback(function ($originUrl, $fileUrl, $ctx, &$http_response_header) { - $http_response_header = array('http/1.1 401 unauthorized'); return ''; - }); $fs->expects($this->at(1)) ->method('getRemoteContents') ->willReturnCallback(function ($originUrl, $fileUrl, $ctx, &$http_response_header) { - $http_response_header = array('http/1.1 200 OK'); return 'copy( @@ -411,7 +403,7 @@ class RemoteFilesystemTest extends TestCase } /** - * @param array $mockedMethods + * @param array $mockedMethods * @param AuthHelper $authHelper * * @return RemoteFilesystem|MockObject @@ -424,7 +416,7 @@ class RemoteFilesystemTest extends TestCase $this->getConfigMock(), array(), false, - $authHelper + $authHelper, )) ->setMethods($mockedMethods) ->getMock(); @@ -440,7 +432,7 @@ class RemoteFilesystemTest extends TestCase return $this->getMockBuilder('Composer\Util\AuthHelper') ->setConstructorArgs(array( $this->getIOInterfaceMock(), - $this->getConfigMock() + $this->getConfigMock(), )) ->setMethods($mockedMethods) ->getMock(); diff --git a/tests/Composer/Test/Util/ZipTest.php b/tests/Composer/Test/Util/ZipTest.php index 2b0129bc8..16fc5827d 100644 --- a/tests/Composer/Test/Util/ZipTest.php +++ b/tests/Composer/Test/Util/ZipTest.php @@ -35,6 +35,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; } @@ -47,6 +48,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; } @@ -59,6 +61,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; } @@ -71,6 +74,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; } @@ -83,6 +87,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; } @@ -95,6 +100,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; } @@ -106,6 +112,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; } @@ -118,6 +125,7 @@ class ZipTest extends TestCase { if (!extension_loaded('zip')) { $this->markTestSkipped('The PHP zip extension is not loaded.'); + return; }