From 3b0a1c6f702d81600e1ac2c8fa7cbaf816e88d12 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 11 Apr 2016 15:06:57 +0100 Subject: [PATCH] Run cs fixer and update config to latest master --- .php_cs | 8 +++--- src/Composer/Command/LicensesCommand.php | 6 ++-- src/Composer/Command/RemoveCommand.php | 2 +- src/Composer/Command/SelfUpdateCommand.php | 9 +++--- src/Composer/Config.php | 4 +-- src/Composer/DependencyResolver/Request.php | 4 +-- src/Composer/Downloader/PathDownloader.php | 4 +-- .../EventDispatcher/EventDispatcher.php | 6 ++-- src/Composer/Installer.php | 2 +- src/Composer/Installer/BinaryInstaller.php | 6 ++-- src/Composer/Installer/LibraryInstaller.php | 10 +++---- src/Composer/Installer/PluginInstaller.php | 2 +- .../Installer/SuggestedPackagesReporter.php | 10 +++---- src/Composer/Json/JsonFile.php | 4 +-- .../Archiver/ArchivableFilesFinder.php | 1 + .../Package/Archiver/GitExcludeFilter.php | 1 + .../Package/Loader/RootPackageLoader.php | 6 ++-- src/Composer/Repository/ArrayRepository.php | 1 + .../Repository/ComposerRepository.php | 6 ++-- src/Composer/Repository/RepositoryFactory.php | 28 +++++++++---------- src/Composer/Repository/RepositoryManager.php | 1 + src/Composer/Util/Bitbucket.php | 12 ++++---- src/Composer/Util/Git.php | 2 +- src/Composer/Util/TlsHelper.php | 1 + tests/Composer/Test/ConfigTest.php | 9 +++--- 25 files changed, 76 insertions(+), 69 deletions(-) diff --git a/.php_cs b/.php_cs index e1fc7d559..1c75b193a 100644 --- a/.php_cs +++ b/.php_cs @@ -10,7 +10,7 @@ For the full copyright and license information, please view the LICENSE file that was distributed with this source code. EOF; -$finder = Symfony\CS\Finder::create() +$finder = PhpCsFixer\Finder::create() ->files() ->name('*.php') ->exclude('Fixtures') @@ -18,7 +18,7 @@ $finder = Symfony\CS\Finder::create() ->in(__DIR__.'/tests') ; -return Symfony\CS\Config::create() +return PhpCsFixer\Config::create() ->setUsingCache(true) //->setUsingLinter(false) ->setRiskyAllowed(true) @@ -26,6 +26,7 @@ return Symfony\CS\Config::create() '@PSR2' => true, 'binary_operator_spaces' => true, 'blank_line_before_return' => true, + 'cast_spaces' => true, 'header_comment' => array('header' => $header), 'include' => true, 'long_array_syntax' => true, @@ -39,6 +40,7 @@ return Symfony\CS\Config::create() 'no_leading_namespace_whitespace' => true, 'no_trailing_comma_in_singleline_array' => true, 'no_unused_imports' => true, + 'no_whitespace_in_blank_lines' => true, 'object_operator_without_whitespace' => true, 'phpdoc_align' => true, 'phpdoc_indent' => true, @@ -50,11 +52,9 @@ return Symfony\CS\Config::create() 'phpdoc_type_to_var' => true, 'psr0' => true, 'single_blank_line_before_namespace' => true, - 'spaces_cast' => true, 'standardize_not_equals' => true, 'ternary_operator_spaces' => true, 'trailing_comma_in_multiline_array' => true, - 'whitespacy_lines' => true, )) ->finder($finder) ; diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php index 889a2920b..fb1079d42 100644 --- a/src/Composer/Command/LicensesCommand.php +++ b/src/Composer/Command/LicensesCommand.php @@ -112,9 +112,9 @@ EOT /** * Find package requires and child requires * - * @param RepositoryInterface $repo - * @param PackageInterface $package - * @param array $bucket + * @param RepositoryInterface $repo + * @param PackageInterface $package + * @param array $bucket * @return array */ private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array()) diff --git a/src/Composer/Command/RemoveCommand.php b/src/Composer/Command/RemoveCommand.php index d7d7f6d7f..f6b5b88e3 100644 --- a/src/Composer/Command/RemoveCommand.php +++ b/src/Composer/Command/RemoveCommand.php @@ -117,7 +117,7 @@ EOT ->setClassMapAuthoritative($authoritative) ->setUpdate(true) ->setUpdateWhitelist($packages) - ->setWhitelistDependencies( ! $input->getOption('no-update-with-dependencies')) + ->setWhitelistDependencies(!$input->getOption('no-update-with-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) ; diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index 2b3166e4b..69f844103 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -302,11 +302,11 @@ TAGSPUBKEY } /** - * @param string $localFilename - * @param string $newFilename - * @param string $backupTarget - * @return \UnexpectedValueException|\PharException|null + * @param string $localFilename + * @param string $newFilename + * @param string $backupTarget * @throws \Exception + * @return \UnexpectedValueException|\PharException|null */ protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null) { @@ -325,6 +325,7 @@ TAGSPUBKEY } rename($newFilename, $localFilename); + return null; } catch (\Exception $e) { if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) { diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 5c05970b0..4a4790c4a 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -80,8 +80,8 @@ class Config private $useEnvironment; /** - * @param bool $useEnvironment Use COMPOSER_ environment variables to replace config settings - * @param string $baseDir Optional base directory of the config + * @param bool $useEnvironment Use COMPOSER_ environment variables to replace config settings + * @param string $baseDir Optional base directory of the config */ public function __construct($useEnvironment = true, $baseDir = null) { diff --git a/src/Composer/DependencyResolver/Request.php b/src/Composer/DependencyResolver/Request.php index d5c47954b..85dc9c4d0 100644 --- a/src/Composer/DependencyResolver/Request.php +++ b/src/Composer/DependencyResolver/Request.php @@ -46,8 +46,8 @@ class Request * * These jobs will not be tempered with by the solver * - * @param string $packageName - * @param ConstraintInterface|null $constraint + * @param string $packageName + * @param ConstraintInterface|null $constraint */ public function fix($packageName, ConstraintInterface $constraint = null) { diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index 66bb5c32d..e7e934544 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -80,11 +80,11 @@ class PathDownloader extends FileDownloader $this->io->writeError(sprintf(' Junctioned from %s', $url)); } else { $absolutePath = $path; - if ( ! $this->filesystem->isAbsolutePath($absolutePath)) { + if (!$this->filesystem->isAbsolutePath($absolutePath)) { $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path; } $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl); - $path = rtrim($path,"/"); + $path = rtrim($path, "/"); $fileSystem->symlink($shortestPath, $path); $this->io->writeError(sprintf(' Symlinked from %s', $url)); } diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index a4c9d3061..17f952ea2 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -136,10 +136,10 @@ class EventDispatcher /** * Triggers the listeners of an event. * - * @param Event $event The event object to pass to the event handlers/listeners. - * @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 + * @param Event $event The event object to pass to the event handlers/listeners. * @throws \RuntimeException|\Exception + * @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 */ protected function doDispatch(Event $event) { diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 4f118fa89..73056d854 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -1488,7 +1488,7 @@ class Installer } /** - * @param SuggestedPackagesReporter $suggestedPackagesReporter + * @param SuggestedPackagesReporter $suggestedPackagesReporter * @return Installer */ public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter) diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index b9f5b64e2..a02477bba 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -35,9 +35,9 @@ class BinaryInstaller /** * @param IOInterface $io - * @param string $binDir - * @param string $binCompat - * @param Filesystem $filesystem + * @param string $binDir + * @param string $binCompat + * @param Filesystem $filesystem */ public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null) { diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 241d55eea..61beab5c3 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -40,11 +40,11 @@ class LibraryInstaller implements InstallerInterface /** * Initializes library installer. * - * @param IOInterface $io - * @param Composer $composer - * @param string $type - * @param Filesystem $filesystem - * @param BinaryInstaller $binaryInstaller + * @param IOInterface $io + * @param Composer $composer + * @param string $type + * @param Filesystem $filesystem + * @param BinaryInstaller $binaryInstaller */ public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null) { diff --git a/src/Composer/Installer/PluginInstaller.php b/src/Composer/Installer/PluginInstaller.php index 3eaa62b0d..e2ae07956 100644 --- a/src/Composer/Installer/PluginInstaller.php +++ b/src/Composer/Installer/PluginInstaller.php @@ -61,7 +61,7 @@ class PluginInstaller extends LibraryInstaller parent::install($repo, $package); try { $this->composer->getPluginManager()->registerPackage($package, true); - } catch(\Exception $e) { + } catch (\Exception $e) { // Rollback installation $this->io->writeError('Plugin installation failed, rolling back'); parent::uninstall($repo, $package); diff --git a/src/Composer/Installer/SuggestedPackagesReporter.php b/src/Composer/Installer/SuggestedPackagesReporter.php index 2d5ab2d63..935ec50cf 100644 --- a/src/Composer/Installer/SuggestedPackagesReporter.php +++ b/src/Composer/Installer/SuggestedPackagesReporter.php @@ -52,9 +52,9 @@ class SuggestedPackagesReporter * Could be used to add suggested packages both from the installer * or from CreateProjectCommand. * - * @param string $source Source package which made the suggestion - * @param string $target Target package to be suggested - * @param string $reason Reason the target package to be suggested + * @param string $source Source package which made the suggestion + * @param string $target Target package to be suggested + * @param string $reason Reason the target package to be suggested * @return SuggestedPackagesReporter */ public function addPackage($source, $target, $reason) @@ -71,7 +71,7 @@ class SuggestedPackagesReporter /** * Add all suggestions from a package. * - * @param PackageInterface $package + * @param PackageInterface $package * @return SuggestedPackagesReporter */ public function addSuggestionsFromPackage(PackageInterface $package) @@ -92,7 +92,7 @@ class SuggestedPackagesReporter * Output suggested packages. * Do not list the ones already installed if installed repository provided. * - * @param RepositoryInterface $installedRepo Installed packages + * @param RepositoryInterface $installedRepo Installed packages * @return SuggestedPackagesReporter */ public function output(RepositoryInterface $installedRepo = null) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 2a59e592f..32e6d129e 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -104,8 +104,8 @@ class JsonFile /** * Writes json file. * - * @param array $hash writes hash into json file - * @param int $options json_encode options (defaults to JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) + * @param array $hash writes hash into json file + * @param int $options json_encode options (defaults to JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) * @throws \UnexpectedValueException|\Exception */ public function write(array $hash, $options = 448) diff --git a/src/Composer/Package/Archiver/ArchivableFilesFinder.php b/src/Composer/Package/Archiver/ArchivableFilesFinder.php index 92e281a2a..f80724da7 100644 --- a/src/Composer/Package/Archiver/ArchivableFilesFinder.php +++ b/src/Composer/Package/Archiver/ArchivableFilesFinder.php @@ -94,6 +94,7 @@ class ArchivableFilesFinder extends \FilterIterator } $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS); + return !$iterator->valid(); } } diff --git a/src/Composer/Package/Archiver/GitExcludeFilter.php b/src/Composer/Package/Archiver/GitExcludeFilter.php index 004ceb8ca..894a45a84 100644 --- a/src/Composer/Package/Archiver/GitExcludeFilter.php +++ b/src/Composer/Package/Archiver/GitExcludeFilter.php @@ -72,6 +72,7 @@ class GitExcludeFilter extends BaseExcludeFilter if (count($parts) == 2 && $parts[1] === 'export-ignore') { return $this->generatePattern($parts[0]); } + return null; } } diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index 64352f961..76ae63488 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -56,9 +56,9 @@ class RootPackageLoader extends ArrayLoader } /** - * @param array $config package data - * @param string $class FQCN to be instantiated - * @param string $cwd cwd of the root package to be used to guess the version if it is not provided + * @param array $config package data + * @param string $class FQCN to be instantiated + * @param string $cwd cwd of the root package to be used to guess the version if it is not provided * @return RootPackageInterface */ public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null) diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 89cedaed0..36eaabadc 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -56,6 +56,7 @@ class ArrayRepository extends BaseRepository } } } + return null; } diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index fd55610ae..9b4ea1c75 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -269,9 +269,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito } /** - * @param Pool $pool - * @param string $name package name - * @param bool $bypassFilters If set to true, this bypasses the stability filtering, and forces a recompute without cache + * @param Pool $pool + * @param string $name package name + * @param bool $bypassFilters If set to true, this bypasses the stability filtering, and forces a recompute without cache * @return array|mixed */ public function whatProvides(Pool $pool, $name, $bypassFilters = false) diff --git a/src/Composer/Repository/RepositoryFactory.php b/src/Composer/Repository/RepositoryFactory.php index 95b5cc13d..bbf866b9e 100644 --- a/src/Composer/Repository/RepositoryFactory.php +++ b/src/Composer/Repository/RepositoryFactory.php @@ -25,10 +25,10 @@ use Composer\Json\JsonFile; class RepositoryFactory { /** - * @param IOInterface $io - * @param Config $config - * @param string $repository - * @param bool $allowFilesystem + * @param IOInterface $io + * @param Config $config + * @param string $repository + * @param bool $allowFilesystem * @return array|mixed */ public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false) @@ -56,10 +56,10 @@ class RepositoryFactory } /** - * @param IOInterface $io - * @param Config $config - * @param string $repository - * @param bool $allowFilesystem + * @param IOInterface $io + * @param Config $config + * @param string $repository + * @param bool $allowFilesystem * @return RepositoryInterface */ public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false) @@ -70,9 +70,9 @@ class RepositoryFactory } /** - * @param IOInterface $io - * @param Config $config - * @param array $repoConfig + * @param IOInterface $io + * @param Config $config + * @param array $repoConfig * @return RepositoryInterface */ public static function createRepo(IOInterface $io, Config $config, array $repoConfig) @@ -84,9 +84,9 @@ class RepositoryFactory } /** - * @param IOInterface|null $io - * @param Config|null $config - * @param RepositoryManager|null $rm + * @param IOInterface|null $io + * @param Config|null $config + * @param RepositoryManager|null $rm * @return RepositoryInterface[] */ public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null) diff --git a/src/Composer/Repository/RepositoryManager.php b/src/Composer/Repository/RepositoryManager.php index f3c5912b0..9038d1c94 100644 --- a/src/Composer/Repository/RepositoryManager.php +++ b/src/Composer/Repository/RepositoryManager.php @@ -58,6 +58,7 @@ class RepositoryManager return $package; } } + return null; } diff --git a/src/Composer/Util/Bitbucket.php b/src/Composer/Util/Bitbucket.php index 9e142bacc..89fdd3902 100644 --- a/src/Composer/Util/Bitbucket.php +++ b/src/Composer/Util/Bitbucket.php @@ -75,7 +75,7 @@ class Bitbucket } /** - * @param string $originUrl + * @param string $originUrl * @return bool */ private function requestAccessToken($originUrl) @@ -88,7 +88,7 @@ class Bitbucket 'http' => array( 'method' => 'POST', 'content' => 'grant_type=client_credentials', - ) + ), )); $this->token = json_decode($json, true); @@ -150,7 +150,7 @@ class Bitbucket $consumer = array( "consumer-key" => $consumerKey, - "consumer-secret" => $consumerSecret + "consumer-secret" => $consumerSecret, ); $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer); @@ -162,9 +162,9 @@ class Bitbucket /** * Retrieves an access token from Bitbucket. * - * @param string $originUrl - * @param string $consumerKey - * @param string $consumerSecret + * @param string $originUrl + * @param string $consumerKey + * @param string $consumerSecret * @return array */ public function requestToken($originUrl, $consumerKey, $consumerSecret) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 78819060b..9c13b2db5 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -127,7 +127,7 @@ class Git $auth = $this->io->getAuthentication($match[1]); //We already have an access_token from a previous request. - if($auth['username'] !== 'x-token-auth') { + if ($auth['username'] !== 'x-token-auth') { $token = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']); $this->io->setAuthentication($match[1], 'x-token-auth', $token['access_token']); } diff --git a/src/Composer/Util/TlsHelper.php b/src/Composer/Util/TlsHelper.php index 137511a70..819cef6b7 100644 --- a/src/Composer/Util/TlsHelper.php +++ b/src/Composer/Util/TlsHelper.php @@ -82,6 +82,7 @@ final class TlsHelper if (0 === strpos($name, 'DNS:')) { return strtolower(ltrim(substr($name, 4))); } + return null; }, $subjectAltNames)); $subjectAltNames = array_values($subjectAltNames); diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php index 9fd693122..5b8bc2601 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\Downloader\TransportException; class ConfigTest extends \PHPUnit_Framework_TestCase { @@ -252,7 +251,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase 'file://myserver.localhost/mygit.git', 'file://example.org/mygit.git', ); - return array_combine($urls, array_map(function($e) { return array($e); }, $urls)); + + return array_combine($urls, array_map(function ($e) { return array($e); }, $urls)); } /** @@ -270,9 +270,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase 'svn://1.2.3.4/trunk', 'git://5.6.7.8/git.git', ); - return array_combine($urls, array_map(function($e) { return array($e); }, $urls)); + + return array_combine($urls, array_map(function ($e) { return array($e); }, $urls)); } - + /** * @group TLS */