From ff59bbdab0fb5bef212f291bbf9f152c7467fd7d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 24 Jul 2018 14:32:52 +0200 Subject: [PATCH] CS fixer --- .php_cs | 8 +++--- src/Composer/Autoload/AutoloadGenerator.php | 5 ++-- src/Composer/Command/AboutCommand.php | 6 +++-- src/Composer/Command/ArchiveCommand.php | 3 ++- .../Command/BaseDependencyCommand.php | 7 +++-- .../Command/CheckPlatformReqsCommand.php | 3 ++- src/Composer/Command/ClearCacheCommand.php | 3 ++- src/Composer/Command/ConfigCommand.php | 5 ++-- src/Composer/Command/CreateProjectCommand.php | 3 ++- src/Composer/Command/DependsCommand.php | 3 ++- src/Composer/Command/DiagnoseCommand.php | 3 ++- src/Composer/Command/DumpAutoloadCommand.php | 3 ++- src/Composer/Command/ExecCommand.php | 6 +++-- src/Composer/Command/GlobalCommand.php | 3 ++- src/Composer/Command/HomeCommand.php | 3 ++- src/Composer/Command/InitCommand.php | 20 +++++++++----- src/Composer/Command/InstallCommand.php | 3 ++- src/Composer/Command/LicensesCommand.php | 3 ++- src/Composer/Command/OutdatedCommand.php | 3 ++- src/Composer/Command/ProhibitsCommand.php | 3 ++- src/Composer/Command/RemoveCommand.php | 3 ++- src/Composer/Command/RequireCommand.php | 3 ++- src/Composer/Command/RunScriptCommand.php | 3 ++- src/Composer/Command/ScriptAliasCommand.php | 3 ++- src/Composer/Command/SearchCommand.php | 3 ++- src/Composer/Command/SelfUpdateCommand.php | 16 +++++++---- src/Composer/Command/ShowCommand.php | 3 ++- src/Composer/Command/StatusCommand.php | 4 +-- src/Composer/Command/SuggestsCommand.php | 3 ++- src/Composer/Command/UpdateCommand.php | 3 ++- src/Composer/Command/ValidateCommand.php | 3 ++- src/Composer/Config.php | 2 ++ src/Composer/DependencyResolver/Problem.php | 1 + .../DependencyResolver/SolverBugException.php | 3 ++- src/Composer/Downloader/DownloadManager.php | 5 +++- src/Composer/Downloader/HgDownloader.php | 4 +-- src/Composer/Downloader/PathDownloader.php | 8 ++++-- .../EventDispatcher/EventDispatcher.php | 27 ++++++++++++++----- src/Composer/Installer.php | 8 +++--- src/Composer/Json/JsonManipulator.php | 3 +-- .../Package/Archiver/GitExcludeFilter.php | 3 ++- .../Package/Archiver/PharArchiver.php | 3 ++- src/Composer/Package/Archiver/ZipArchiver.php | 3 ++- src/Composer/Package/Locker.php | 3 ++- src/Composer/Repository/PathRepository.php | 4 +-- src/Composer/Repository/Vcs/HgDriver.php | 2 +- src/Composer/Repository/Vcs/SvnDriver.php | 2 +- src/Composer/Util/Filesystem.php | 8 +++--- src/Composer/Util/Hg.php | 11 +++----- src/Composer/Util/Svn.php | 5 ++-- .../Test/Autoload/AutoloadGeneratorTest.php | 20 +++++++------- .../Composer/Test/Command/InitCommandTest.php | 6 +++-- .../Test/DependencyResolver/RequestTest.php | 6 +++-- tests/Composer/Test/IO/ConsoleIOTest.php | 1 - .../Installer/InstallationManagerTest.php | 3 ++- .../Archiver/ArchivableFilesFinderTest.php | 6 +++-- tests/Composer/Test/Package/LockerTest.php | 9 +++++-- .../Test/Repository/PearRepositoryTest.php | 6 +++-- tests/Composer/Test/Util/UrlTest.php | 2 +- 59 files changed, 196 insertions(+), 111 deletions(-) diff --git a/.php_cs b/.php_cs index c3fe1e894..ac954ab5e 100644 --- a/.php_cs +++ b/.php_cs @@ -25,11 +25,11 @@ return PhpCsFixer\Config::create() '@PSR2' => true, 'array_syntax' => array('syntax' => 'long'), 'binary_operator_spaces' => true, - 'blank_line_before_return' => true, - 'cast_spaces' => true, + 'blank_line_before_statement' => array('statements' => array('declare', 'return')), + 'cast_spaces' => array('space' => 'single'), 'header_comment' => array('header' => $header), 'include' => true, - 'method_separation' => true, + 'class_attributes_separation' => array('elements' => array('method')), 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, 'no_empty_statement' => true, @@ -38,7 +38,6 @@ return PhpCsFixer\Config::create() 'no_leading_namespace_whitespace' => true, 'no_trailing_comma_in_singleline_array' => true, 'no_unused_imports' => true, - 'no_useless_else' => true, 'no_whitespace_in_blank_line' => true, 'object_operator_without_whitespace' => true, 'phpdoc_align' => true, @@ -50,7 +49,6 @@ return PhpCsFixer\Config::create() 'phpdoc_trim' => true, 'phpdoc_types' => true, 'psr0' => true, - 'short_scalar_cast' => true, 'single_blank_line_before_namespace' => true, 'standardize_not_equals' => true, 'ternary_operator_spaces' => true, diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index f7dfdef0d..8f03d330a 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -903,8 +903,8 @@ INITIALIZER; /** * Filters out dev-dependencies when not in dev-mode * - * @param array $packageMap - * @param PackageInterface $mainPackage + * @param array $packageMap + * @param PackageInterface $mainPackage * @return array */ protected function filterPackageMap(array $packageMap, PackageInterface $mainPackage) @@ -940,6 +940,7 @@ INITIALIZER; function ($item) use ($include) { $package = $item[0]; $name = $package->getName(); + return isset($include[$name]); } ); diff --git a/src/Composer/Command/AboutCommand.php b/src/Composer/Command/AboutCommand.php index fac42c312..8fbad05a8 100644 --- a/src/Composer/Command/AboutCommand.php +++ b/src/Composer/Command/AboutCommand.php @@ -25,7 +25,8 @@ class AboutCommand extends BaseCommand $this ->setName('about') ->setDescription('Shows the short information about Composer.') - ->setHelp(<<setHelp( + <<php composer.phar about EOT ) @@ -34,7 +35,8 @@ EOT protected function execute(InputInterface $input, OutputInterface $output) { - $this->getIO()->write(<<getIO()->write( + <<Composer - Package Management for PHP Composer is a dependency manager tracking local dependencies of your projects and libraries. See https://getcomposer.org/ for more information. diff --git a/src/Composer/Command/ArchiveCommand.php b/src/Composer/Command/ArchiveCommand.php index 4ab1e4905..29858c6fc 100644 --- a/src/Composer/Command/ArchiveCommand.php +++ b/src/Composer/Command/ArchiveCommand.php @@ -48,7 +48,8 @@ class ArchiveCommand extends BaseCommand .' Note that the format will be appended.'), new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'), )) - ->setHelp(<<setHelp( + <<archive command creates an archive of the specified format containing the files and directories of the Composer project or the specified package in the specified version and writes it to the specified directory. diff --git a/src/Composer/Command/BaseDependencyCommand.php b/src/Composer/Command/BaseDependencyCommand.php index a0c358add..4c8766ba3 100644 --- a/src/Composer/Command/BaseDependencyCommand.php +++ b/src/Composer/Command/BaseDependencyCommand.php @@ -129,8 +129,11 @@ class BaseDependencyCommand extends BaseCommand $results = $repository->getDependents($needles, $constraint, $inverted, $recursive); if (empty($results)) { $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : ''; - $this->getIO()->writeError(sprintf('There is no installed package depending on "%s"%s', - $needle, $extra)); + $this->getIO()->writeError(sprintf( + 'There is no installed package depending on "%s"%s', + $needle, + $extra + )); } elseif ($renderTree) { $this->initStyles($output); $root = $packages[0]; diff --git a/src/Composer/Command/CheckPlatformReqsCommand.php b/src/Composer/Command/CheckPlatformReqsCommand.php index 6a75ab4dc..5a68661cc 100644 --- a/src/Composer/Command/CheckPlatformReqsCommand.php +++ b/src/Composer/Command/CheckPlatformReqsCommand.php @@ -26,7 +26,8 @@ class CheckPlatformReqsCommand extends BaseCommand { $this->setName('check-platform-reqs') ->setDescription('Check that platform requirements are satisfied.') - ->setHelp(<<setHelp( + <<php composer.phar check-platform-reqs diff --git a/src/Composer/Command/ClearCacheCommand.php b/src/Composer/Command/ClearCacheCommand.php index 362d28500..2514f6330 100644 --- a/src/Composer/Command/ClearCacheCommand.php +++ b/src/Composer/Command/ClearCacheCommand.php @@ -28,7 +28,8 @@ class ClearCacheCommand extends BaseCommand ->setName('clear-cache') ->setAliases(array('clearcache')) ->setDescription('Clears composer\'s internal package cache.') - ->setHelp(<<setHelp( + <<clear-cache deletes all cached packages from composer's cache directory. EOT diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 4e0232844..b002fd3a7 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -75,7 +75,8 @@ class ConfigCommand extends BaseCommand new InputArgument('setting-key', null, 'Setting key'), new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'), )) - ->setHelp(<<setHelp( + <<getOption('unset')) { return $this->configSource->removeProperty($settingKey); } diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 289b8909c..a7cc6650b 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -80,7 +80,8 @@ class CreateProjectCommand extends BaseCommand new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'), )) - ->setHelp(<<setHelp( + <<create-project command creates a new project from a given package into a new directory. If executed without params and in a directory with a composer.json file it installs the packages for the current project. diff --git a/src/Composer/Command/DependsCommand.php b/src/Composer/Command/DependsCommand.php index cbf75f736..acbc89a70 100644 --- a/src/Composer/Command/DependsCommand.php +++ b/src/Composer/Command/DependsCommand.php @@ -31,7 +31,8 @@ class DependsCommand extends BaseDependencyCommand ->setName('depends') ->setAliases(array('why')) ->setDescription('Shows which packages cause the given package to be installed.') - ->setHelp(<<setHelp( + <<php composer.phar depends composer/composer diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index b15cd35b1..ada5faa87 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -48,7 +48,8 @@ class DiagnoseCommand extends BaseCommand $this ->setName('diagnose') ->setDescription('Diagnoses the system to identify common errors.') - ->setHelp(<<setHelp( + <<diagnose command checks common errors to help debugging problems. The process exit code will be 1 in case of warnings and 2 for errors. diff --git a/src/Composer/Command/DumpAutoloadCommand.php b/src/Composer/Command/DumpAutoloadCommand.php index 6c79ef13f..fe80e3760 100644 --- a/src/Composer/Command/DumpAutoloadCommand.php +++ b/src/Composer/Command/DumpAutoloadCommand.php @@ -36,7 +36,8 @@ class DumpAutoloadCommand extends BaseCommand new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'), new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules.'), )) - ->setHelp(<<setHelp( + <<php composer.phar dump-autoload EOT ) diff --git a/src/Composer/Command/ExecCommand.php b/src/Composer/Command/ExecCommand.php index 2ab36f802..f07bc9d28 100644 --- a/src/Composer/Command/ExecCommand.php +++ b/src/Composer/Command/ExecCommand.php @@ -53,7 +53,8 @@ class ExecCommand extends BaseCommand throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)"); } - $this->getIO()->write(<<getIO()->write( + <<Available binaries: EOT ); @@ -66,7 +67,8 @@ EOT $previousBin = $bin; $bin = basename($bin); - $this->getIO()->write(<<getIO()->write( + <<- $bin EOT ); diff --git a/src/Composer/Command/GlobalCommand.php b/src/Composer/Command/GlobalCommand.php index d189f44d5..9e87c7e17 100644 --- a/src/Composer/Command/GlobalCommand.php +++ b/src/Composer/Command/GlobalCommand.php @@ -32,7 +32,8 @@ class GlobalCommand extends BaseCommand new InputArgument('command-name', InputArgument::REQUIRED, ''), new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''), )) - ->setHelp(<<setHelp( + <<setHelp(<<setHelp( + <<setHelp(<<setHelp( + <<init command creates a basic composer.json file in the current directory. @@ -676,7 +677,7 @@ EOT * @param string|null $requiredVersion * @param string $minimumStability * @throws \InvalidArgumentException - * @return array name version + * @return array name version */ private function findBestVersionAndNameForPackage(InputInterface $input, $name, $phpVersion, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null) { @@ -694,19 +695,26 @@ EOT // Check whether the PHP version was the problem if ($phpVersion && $versionSelector->findBestCandidate($name, $requiredVersion, null, $preferredStability)) { throw new \InvalidArgumentException(sprintf( - 'Package %s at version %s has a PHP requirement incompatible with your PHP version (%s)', $name, $requiredVersion, $phpVersion + 'Package %s at version %s has a PHP requirement incompatible with your PHP version (%s)', + $name, + $requiredVersion, + $phpVersion )); } // Check whether the required version was the problem if ($requiredVersion && $versionSelector->findBestCandidate($name, null, $phpVersion, $preferredStability)) { throw new \InvalidArgumentException(sprintf( - 'Could not find package %s in a version matching %s', $name, $requiredVersion + 'Could not find package %s in a version matching %s', + $name, + $requiredVersion )); } // Check whether the PHP version was the problem if ($phpVersion && $versionSelector->findBestCandidate($name)) { throw new \InvalidArgumentException(sprintf( - 'Could not find package %s in any version matching your PHP version (%s)', $name, $phpVersion + 'Could not find package %s in any version matching your PHP version (%s)', + $name, + $phpVersion )); } @@ -738,7 +746,7 @@ EOT return array( $package->getPrettyName(), - $versionSelector->findRecommendedRequireVersion($package) + $versionSelector->findRecommendedRequireVersion($package), ); } diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 7a8980cc4..cc590d8c9 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -52,7 +52,8 @@ class InstallCommand extends BaseCommand new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'), new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'), )) - ->setHelp(<<setHelp( + <<install command reads the composer.lock file from the current directory, processes it, and downloads and installs all the libraries and dependencies outlined in that file. If the file does not diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php index f3a71eb39..9dec45e1b 100644 --- a/src/Composer/Command/LicensesCommand.php +++ b/src/Composer/Command/LicensesCommand.php @@ -36,7 +36,8 @@ class LicensesCommand extends BaseCommand new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'), new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'), )) - ->setHelp(<<setHelp( + <<setHelp(<<setHelp( + <<setName('prohibits') ->setAliases(array('why-not')) ->setDescription('Shows which packages prevent the given package from being installed.') - ->setHelp(<<setHelp( + <<php composer.phar prohibits composer/composer diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index 200340e9e..c97130c3a 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -48,7 +48,8 @@ class RemoveCommand extends BaseCommand new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'), new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'), )) - ->setHelp(<<setHelp( + <<remove command removes a package from the current list of installed packages diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 37cec85c7..01439207f 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -57,7 +57,8 @@ class RequireCommand extends InitCommand new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'), new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'), )) - ->setHelp(<<setHelp( + <<setHelp(<<setHelp( + <<run-script command runs scripts defined in composer.json: php composer.phar run-script post-update-cmd diff --git a/src/Composer/Command/ScriptAliasCommand.php b/src/Composer/Command/ScriptAliasCommand.php index 81f1454da..1aba0b074 100644 --- a/src/Composer/Command/ScriptAliasCommand.php +++ b/src/Composer/Command/ScriptAliasCommand.php @@ -43,7 +43,8 @@ class ScriptAliasCommand extends BaseCommand new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'), new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''), )) - ->setHelp(<<setHelp( + <<run-script command runs scripts defined in composer.json: php composer.phar run-script post-update-cmd diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index cdcc00dc4..8fa6b02b7 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -44,7 +44,8 @@ class SearchCommand extends BaseCommand new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'), new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'), )) - ->setHelp(<<setHelp( + <<php composer.phar search symfony composer diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 52f7b87f0..2641a922b 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -53,7 +53,8 @@ class SelfUpdateCommand extends BaseCommand new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'), new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'), )) - ->setHelp(<<setHelp( + <<self-update command checks getcomposer.org for newer versions of composer and if found, installs the latest. @@ -176,7 +177,9 @@ EOT $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub'); if (!file_exists($sigFile)) { - file_put_contents($home.'/keys.dev.pub', <<setHelp(<<setHelp( + <<setHelp(<<setHelp( + <<%command.name% command shows a sorted list of suggested packages. diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 1d67f1f9b..34420b747 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -61,7 +61,8 @@ class UpdateCommand extends BaseCommand new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'), new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'), )) - ->setHelp(<<setHelp( + <<update command reads the composer.json file from the current directory, processes it, and updates, removes or installs all the dependencies. diff --git a/src/Composer/Command/ValidateCommand.php b/src/Composer/Command/ValidateCommand.php index c4f78d2df..d884febe8 100644 --- a/src/Composer/Command/ValidateCommand.php +++ b/src/Composer/Command/ValidateCommand.php @@ -46,7 +46,8 @@ class ValidateCommand extends BaseCommand new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'), new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'), )) - ->setHelp(<<setHelp( + <<getInstallationSource()) { throw new \LogicException(sprintf( 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s', - get_class($downloader), $downloader->getInstallationSource(), $installationSource, $package + get_class($downloader), + $downloader->getInstallationSource(), + $installationSource, + $package )); } diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php index 8660ec61d..2921cc4b7 100644 --- a/src/Composer/Downloader/HgDownloader.php +++ b/src/Composer/Downloader/HgDownloader.php @@ -28,7 +28,7 @@ class HgDownloader extends VcsDownloader { $hgUtils = new HgUtils($this->io, $this->config, $this->process); - $cloneCommand = function($url) use ($path) { + $cloneCommand = function ($url) use ($path) { return sprintf('hg clone %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path)); }; @@ -55,7 +55,7 @@ class HgDownloader extends VcsDownloader throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); } - $command = function($url) use ($ref) { + $command = function ($url) use ($ref) { return sprintf('hg pull %s && hg up %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref)); }; diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index 250a01c3f..456ce4115 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -43,7 +43,9 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter $realUrl = realpath($url); if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) { throw new \RuntimeException(sprintf( - 'Source path "%s" is not found for package %s', $url, $package->getName() + 'Source path "%s" is not found for package %s', + $url, + $package->getName() )); } @@ -54,7 +56,9 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter // for previous attempts that were shut down because they did not work well enough or introduced too many risks. throw new \RuntimeException(sprintf( 'Package %s cannot install to "%s" inside its source at "%s"', - $package->getName(), realpath($path), $realUrl + $package->getName(), + realpath($path), + $realUrl )); } diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 7f7a2cd86..145944b07 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -325,22 +325,37 @@ class EventDispatcher if (!$event instanceof $expected && $expected === 'Composer\Script\CommandEvent') { trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED); $event = new \Composer\Script\CommandEvent( - $event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), $event->getArguments() + $event->getName(), + $event->getComposer(), + $event->getIO(), + $event->isDevMode(), + $event->getArguments() ); } if (!$event instanceof $expected && $expected === 'Composer\Script\PackageEvent') { trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED); $event = new \Composer\Script\PackageEvent( - $event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), - $event->getPolicy(), $event->getPool(), $event->getInstalledRepo(), $event->getRequest(), - $event->getOperations(), $event->getOperation() + $event->getName(), + $event->getComposer(), + $event->getIO(), + $event->isDevMode(), + $event->getPolicy(), + $event->getPool(), + $event->getInstalledRepo(), + $event->getRequest(), + $event->getOperations(), + $event->getOperation() ); } if (!$event instanceof $expected && $expected === 'Composer\Script\Event') { trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED); $event = new \Composer\Script\Event( - $event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), - $event->getArguments(), $event->getFlags() + $event->getName(), + $event->getComposer(), + $event->getIO(), + $event->isDevMode(), + $event->getArguments(), + $event->getFlags() ); } diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index f6f78a4d9..a729710c0 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -521,15 +521,15 @@ class Installer } } - $this->io->writeError( - sprintf("Package operations: %d install%s, %d update%s, %d removal%s", + $this->io->writeError(sprintf( + "Package operations: %d install%s, %d update%s, %d removal%s", count($installs), 1 === count($installs) ? '' : 's', count($updates), 1 === count($updates) ? '' : 's', count($uninstalls), - 1 === count($uninstalls) ? '' : 's') - ); + 1 === count($uninstalls) ? '' : 's' + )); if ($installs) { $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE); } diff --git a/src/Composer/Json/JsonManipulator.php b/src/Composer/Json/JsonManipulator.php index b9dc24bb5..40c0c09a2 100644 --- a/src/Composer/Json/JsonManipulator.php +++ b/src/Composer/Json/JsonManipulator.php @@ -510,8 +510,7 @@ class JsonManipulator if (PHP_VERSION_ID > 70000) { throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6); } - // fallthrough - + // no break default: throw new \RuntimeException('Failed to execute regex: Unknown error'); } diff --git a/src/Composer/Package/Archiver/GitExcludeFilter.php b/src/Composer/Package/Archiver/GitExcludeFilter.php index 894a45a84..0cdc98c81 100644 --- a/src/Composer/Package/Archiver/GitExcludeFilter.php +++ b/src/Composer/Package/Archiver/GitExcludeFilter.php @@ -42,7 +42,8 @@ class GitExcludeFilter extends BaseExcludeFilter $this->parseLines( file($sourcePath.'/.gitattributes'), array($this, 'parseGitAttributesLine') - )); + ) + ); } } diff --git a/src/Composer/Package/Archiver/PharArchiver.php b/src/Composer/Package/Archiver/PharArchiver.php index cbab4ba23..f9a392353 100644 --- a/src/Composer/Package/Archiver/PharArchiver.php +++ b/src/Composer/Package/Archiver/PharArchiver.php @@ -76,7 +76,8 @@ class PharArchiver implements ArchiverInterface return $target; } catch (\UnexpectedValueException $e) { - $message = sprintf("Could not create archive '%s' from '%s': %s", + $message = sprintf( + "Could not create archive '%s' from '%s': %s", $target, $sources, $e->getMessage() diff --git a/src/Composer/Package/Archiver/ZipArchiver.php b/src/Composer/Package/Archiver/ZipArchiver.php index aaa41aea3..d1d7573f3 100644 --- a/src/Composer/Package/Archiver/ZipArchiver.php +++ b/src/Composer/Package/Archiver/ZipArchiver.php @@ -50,7 +50,8 @@ class ZipArchiver implements ArchiverInterface return $target; } } - $message = sprintf("Could not create archive '%s' from '%s': %s", + $message = sprintf( + "Could not create archive '%s' from '%s': %s", $target, $sources, $zip->getStatusString() diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 7fbe536f2..57ec74233 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -360,7 +360,8 @@ class Locker if (!$name || !$version) { throw new \LogicException(sprintf( - 'Package "%s" has no version or name and can not be locked', $package + 'Package "%s" has no version or name and can not be locked', + $package )); } diff --git a/src/Composer/Repository/PathRepository.php b/src/Composer/Repository/PathRepository.php index 5d50c2473..61ebc8d8c 100644 --- a/src/Composer/Repository/PathRepository.php +++ b/src/Composer/Repository/PathRepository.php @@ -175,13 +175,13 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn private function getUrlMatches() { $flags = GLOB_MARK | GLOB_ONLYDIR; - + if (defined('GLOB_BRACE')) { $flags |= GLOB_BRACE; } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) { throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url); } - + // Ensure environment-specific path separators are normalized to URL separators return array_map(function ($val) { return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/'); diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 8141f453b..2db995e2e 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -61,7 +61,7 @@ class HgDriver extends VcsDriver // clean up directory and do a fresh clone into it $fs->removeDirectory($this->repoDir); - $command = function($url) { + $command = function ($url) { return sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($this->repoDir)); }; diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index 822510601..96434517a 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -135,7 +135,7 @@ class SvnDriver extends VcsDriver try { $composer = $this->getBaseComposerInformation($identifier); - } catch(TransportException $e) { + } catch (TransportException $e) { $message = $e->getMessage(); if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) { throw $e; diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index f262432ff..04df84ecd 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -634,9 +634,11 @@ class Filesystem if (!is_dir($target)) { throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target); } - $cmd = sprintf('mklink /J %s %s', - ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)), - ProcessExecutor::escape(realpath($target))); + $cmd = sprintf( + 'mklink /J %s %s', + ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)), + ProcessExecutor::escape(realpath($target)) + ); if ($this->getProcess()->execute($cmd, $output) !== 0) { throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target); } diff --git a/src/Composer/Util/Hg.php b/src/Composer/Util/Hg.php index 5afe7b3f4..48d0b3687 100644 --- a/src/Composer/Util/Hg.php +++ b/src/Composer/Util/Hg.php @@ -20,7 +20,6 @@ use Composer\IO\IOInterface; */ class Hg { - /** * @var \Composer\IO\IOInterface */ @@ -43,20 +42,21 @@ class Hg $this->process = $process; } - public function runCommand($commandCallable, $url, $cwd) { + public function runCommand($commandCallable, $url, $cwd) + { $this->config->prohibitUrlByConfig($url, $this->io); // Try as is $command = call_user_func($commandCallable, $url); - if (0 === $this->process->execute($command, $ignoredOutput, $cwd)){ + if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } // Try with the authentication informations available if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) { $auth = $this->io->getAuthentication($match[5]); - $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6])? $match[6]: null); + $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null); $command = call_user_func($commandCallable, $authenticatedUrl); @@ -69,10 +69,7 @@ class Hg $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)'; } - - $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url); - } public static function sanitizeUrl($message) diff --git a/src/Composer/Util/Svn.php b/src/Composer/Util/Svn.php index 898fadce0..df31ccbbf 100644 --- a/src/Composer/Util/Svn.php +++ b/src/Composer/Util/Svn.php @@ -66,7 +66,7 @@ class Svn /** * @var string|null */ - static private $version; + private static $version; /** * @param string $url @@ -223,7 +223,8 @@ class Svn */ protected function getCommand($cmd, $url, $path = null) { - $cmd = sprintf('%s %s%s %s', + $cmd = sprintf( + '%s %s%s %s', $cmd, '--non-interactive ', $this->getCredentialString(), diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index dd99bfd59..b8eec2f43 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -362,7 +362,7 @@ class AutoloadGeneratorTest extends TestCase $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( new Link('a', 'a/a'), - new Link('a', 'b/b') + new Link('a', 'b/b'), )); $packages = array(); @@ -445,7 +445,7 @@ class AutoloadGeneratorTest extends TestCase $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( new Link('a', 'a/a'), - new Link('a', 'b/b') + new Link('a', 'b/b'), )); $packages = array(); @@ -484,7 +484,7 @@ class AutoloadGeneratorTest extends TestCase $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( new Link('a', 'a/a'), - new Link('a', 'b/b') + new Link('a', 'b/b'), )); $packages = array(); @@ -524,7 +524,7 @@ class AutoloadGeneratorTest extends TestCase $package->setRequires(array( new Link('a', 'a/a'), new Link('a', 'b/b'), - new Link('a', 'c/c') + new Link('a', 'c/c'), )); $packages = array(); @@ -568,7 +568,7 @@ class AutoloadGeneratorTest extends TestCase $package->setRequires(array( new Link('a', 'a/a'), new Link('a', 'b/b'), - new Link('a', 'c/c') + new Link('a', 'c/c'), )); $packages = array(); @@ -617,7 +617,7 @@ class AutoloadGeneratorTest extends TestCase $package->setRequires(array( new Link('a', 'a/a'), new Link('a', 'b/b'), - new Link('a', 'c/c') + new Link('a', 'c/c'), )); $packages = array(); @@ -667,7 +667,7 @@ class AutoloadGeneratorTest extends TestCase $requires = array( new Link('a', 'a/a'), new Link('a', 'b/b'), - new Link('a', 'c/c') + new Link('a', 'c/c'), ); $autoloadPackage->setRequires($requires); $notAutoloadPackage->setRequires($requires); @@ -739,7 +739,7 @@ class AutoloadGeneratorTest extends TestCase new Link('a', 'z/foo'), new Link('a', 'b/bar'), new Link('a', 'd/d'), - new Link('a', 'e/e') + new Link('a', 'e/e'), )); $packages = array(); @@ -809,7 +809,7 @@ class AutoloadGeneratorTest extends TestCase )); $mainPackage->setRequires(array( new Link('z', 'a/a'), - new Link('z', 'b/b') + new Link('z', 'b/b'), )); $packages = array(); @@ -1068,7 +1068,7 @@ EOF; 'files' => array('test.php'), )); $package->setRequires(array( - new Link('a', 'b/b') + new Link('a', 'b/b'), )); $vendorPackage = new Package('b/b', '1.0', '1.0'); diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index 81aaf0d17..d355b6cd1 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -59,7 +59,8 @@ 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']); } @@ -72,7 +73,8 @@ 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/DependencyResolver/RequestTest.php b/tests/Composer/Test/DependencyResolver/RequestTest.php index e16ca6e11..08e0cae96 100644 --- a/tests/Composer/Test/DependencyResolver/RequestTest.php +++ b/tests/Composer/Test/DependencyResolver/RequestTest.php @@ -40,7 +40,8 @@ class RequestTest extends TestCase array('cmd' => 'install', 'packageName' => 'bar', 'constraint' => null, 'fixed' => true), array('cmd' => 'remove', 'packageName' => 'foobar', 'constraint' => null, 'fixed' => false), ), - $request->getJobs()); + $request->getJobs() + ); } public function testRequestInstallSamePackageFromDifferentRepositories() @@ -73,6 +74,7 @@ class RequestTest extends TestCase $this->assertEquals( array(array('cmd' => 'update-all')), - $request->getJobs()); + $request->getJobs() + ); } } diff --git a/tests/Composer/Test/IO/ConsoleIOTest.php b/tests/Composer/Test/IO/ConsoleIOTest.php index f44369dba..57809769c 100644 --- a/tests/Composer/Test/IO/ConsoleIOTest.php +++ b/tests/Composer/Test/IO/ConsoleIOTest.php @@ -241,7 +241,6 @@ class ConsoleIOTest extends TestCase $this->isInstanceOf('Symfony\Component\Console\Question\Question') ) ->will($this->returnValue(array('item2'))); - ; $setMock ->expects($this->once()) diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php index beb4e4bf5..86e860bc2 100644 --- a/tests/Composer/Test/Installer/InstallationManagerTest.php +++ b/tests/Composer/Test/Installer/InstallationManagerTest.php @@ -86,7 +86,8 @@ class InstallationManagerTest extends TestCase $installOperation = new InstallOperation($this->createPackageMock()); $removeOperation = new UninstallOperation($this->createPackageMock()); $updateOperation = new UpdateOperation( - $this->createPackageMock(), $this->createPackageMock() + $this->createPackageMock(), + $this->createPackageMock() ); $manager diff --git a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php index 669ec7a3f..5856efbf5 100644 --- a/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchivableFilesFinderTest.php @@ -185,7 +185,8 @@ class ArchivableFilesFinderTest extends TestCase $this->finder = new ArchivableFilesFinder($this->sources, array()); - $this->assertArchivableFiles($this->getArchivedFiles('git init && '. + $this->assertArchivableFiles($this->getArchivedFiles( + 'git init && '. 'git config user.email "you@example.com" && '. 'git config user.name "Your Name" && '. 'git add .git* && '. @@ -222,7 +223,8 @@ class ArchivableFilesFinderTest extends TestCase $this->finder = new ArchivableFilesFinder($this->sources, array()); - $expectedFiles = $this->getArchivedFiles('hg init && '. + $expectedFiles = $this->getArchivedFiles( + 'hg init && '. 'hg add && '. 'hg commit -m "init" && '. 'hg archive archive.zip' diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index b5692b009..c20c21466 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -21,8 +21,13 @@ class LockerTest extends TestCase public function testIsLocked() { $json = $this->createJsonFileMock(); - $locker = new Locker(new NullIO, $json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), - $this->getJsonContent()); + $locker = new Locker( + new NullIO, + $json, + $this->createRepositoryManagerMock(), + $this->createInstallationManagerMock(), + $this->getJsonContent() + ); $json ->expects($this->any()) diff --git a/tests/Composer/Test/Repository/PearRepositoryTest.php b/tests/Composer/Test/Repository/PearRepositoryTest.php index 62c0ce822..c484820b6 100644 --- a/tests/Composer/Test/Repository/PearRepositoryTest.php +++ b/tests/Composer/Test/Repository/PearRepositoryTest.php @@ -48,7 +48,8 @@ class PearRepositoryTest extends TestCase foreach ($expectedPackages as $expectedPackage) { $package = $this->repository->findPackage($expectedPackage['name'], $expectedPackage['version']); - $this->assertInstanceOf('Composer\Package\PackageInterface', + $this->assertInstanceOf( + 'Composer\Package\PackageInterface', $package, 'Expected package ' . $expectedPackage['name'] . ', version ' . $expectedPackage['version'] . ' not found in pear channel ' . $url @@ -74,7 +75,8 @@ class PearRepositoryTest extends TestCase $this->createRepository($repoConfig); foreach ($expectedPackages as $expectedPackage) { - $this->assertInstanceOf('Composer\Package\PackageInterface', + $this->assertInstanceOf( + 'Composer\Package\PackageInterface', $this->repository->findPackage($expectedPackage['name'], $expectedPackage['version']), 'Expected package ' . $expectedPackage['name'] . ', version ' . $expectedPackage['version'] . ' not found in pear channel ' . $url diff --git a/tests/Composer/Test/Util/UrlTest.php b/tests/Composer/Test/Util/UrlTest.php index 96e71d10e..7772582a5 100644 --- a/tests/Composer/Test/Util/UrlTest.php +++ b/tests/Composer/Test/Util/UrlTest.php @@ -55,7 +55,7 @@ class UrlTest extends TestCase // gitlab enterprise array('https://mygitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=abcd', 'https://mygitlab.com/api/v4/projects/foo%2Fbar/repository/archive.tar.gz?sha=newref', array('gitlab-domains' => array('mygitlab.com'))), array('https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=abcd', 'https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=newref', array('gitlab-domains' => array('mygitlab.com'))), - array('https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=abcd', 'https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=65', array('gitlab-domains' => array('mygitlab.com')), '65'), + array('https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=abcd', 'https://mygitlab.com/api/v3/projects/foo%2Fbar/repository/archive.tar.bz2?sha=65', array('gitlab-domains' => array('mygitlab.com')), '65'), ); } }