diff --git a/.php_cs b/.php_cs index 1c75b193a..8f2a14b9b 100644 --- a/.php_cs +++ b/.php_cs @@ -29,18 +29,17 @@ return PhpCsFixer\Config::create() 'cast_spaces' => true, 'header_comment' => array('header' => $header), 'include' => true, - 'long_array_syntax' => true, + 'array_syntax' => array('syntax' => 'long'), 'method_separation' => true, 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, - 'no_blank_lines_between_uses' => true, - 'no_duplicate_semicolons' => true, + 'no_empty_statement' => true, 'no_extra_consecutive_blank_lines' => true, 'no_leading_import_slash' => true, 'no_leading_namespace_whitespace' => true, 'no_trailing_comma_in_singleline_array' => true, 'no_unused_imports' => true, - 'no_whitespace_in_blank_lines' => true, + 'no_whitespace_in_blank_line' => true, 'object_operator_without_whitespace' => true, 'phpdoc_align' => true, 'phpdoc_indent' => true, @@ -49,12 +48,13 @@ return PhpCsFixer\Config::create() 'phpdoc_order' => true, 'phpdoc_scalar' => true, 'phpdoc_trim' => true, - 'phpdoc_type_to_var' => true, + 'phpdoc_types' => true, 'psr0' => true, 'single_blank_line_before_namespace' => true, + 'short_scalar_cast' => true, 'standardize_not_equals' => true, 'ternary_operator_spaces' => true, 'trailing_comma_in_multiline_array' => true, )) - ->finder($finder) + ->setFinder($finder) ; diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index bb2d6f801..c637b9438 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -66,7 +66,7 @@ class AutoloadGenerator public function setDevMode($devMode = true) { - $this->devMode = (boolean) $devMode; + $this->devMode = (bool) $devMode; } /** @@ -77,7 +77,7 @@ class AutoloadGenerator */ public function setClassMapAuthoritative($classMapAuthoritative) { - $this->classMapAuthoritative = (boolean) $classMapAuthoritative; + $this->classMapAuthoritative = (bool) $classMapAuthoritative; } /** @@ -87,7 +87,7 @@ class AutoloadGenerator */ public function setApcu($apcu) { - $this->apcu = (boolean) $apcu; + $this->apcu = (bool) $apcu; } /** @@ -97,7 +97,7 @@ class AutoloadGenerator */ public function setRunScripts($runScripts = true) { - $this->runScripts = (boolean) $runScripts; + $this->runScripts = (bool) $runScripts; } public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '') @@ -543,7 +543,7 @@ EOF; protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix) { - $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode)-1]; + $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1]; if ("'" === $lastChar || '"' === $lastChar) { $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar; } else { diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index 4b1648841..3dbb06eed 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -46,6 +46,7 @@ class Cache if (preg_match('{(^|[\\\\/])(\$null|NUL|/dev/null)([\\\\/]|$)}', $cacheDir)) { $this->enabled = false; + return; } diff --git a/src/Composer/Command/ArchiveCommand.php b/src/Composer/Command/ArchiveCommand.php index b23e4df91..75b4b4c48 100644 --- a/src/Composer/Command/ArchiveCommand.php +++ b/src/Composer/Command/ArchiveCommand.php @@ -45,7 +45,7 @@ class ArchiveCommand extends BaseCommand new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'), new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.' .' Note that the format will be appended.'), - new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package') + new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'), )) ->setHelp(<<archive command creates an archive of the specified format @@ -139,7 +139,9 @@ EOT if (count($packages) > 1) { $package = reset($packages); $io->writeError('Found multiple matches, selected '.$package->getPrettyString().'.'); - $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) { return $p->getPrettyString(); }, $packages)).'.'); + $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) { + return $p->getPrettyString(); + }, $packages)).'.'); $io->writeError('Please use a more specific constraint to pick a different package.'); } elseif ($packages) { $package = reset($packages); diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 38027c82e..23f54e311 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -286,19 +286,29 @@ EOT $values = $input->getArgument('setting-value'); // what the user is trying to add/change - $booleanValidator = function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); }; - $booleanNormalizer = function ($val) { return $val !== 'false' && (bool) $val; }; + $booleanValidator = function ($val) { + return in_array($val, array('true', 'false', '1', '0'), true); + }; + $booleanNormalizer = function ($val) { + return $val !== 'false' && (bool) $val; + }; // handle config values $uniqueConfigValues = array( 'process-timeout' => array('is_numeric', 'intval'), 'use-include-path' => array($booleanValidator, $booleanNormalizer), 'preferred-install' => array( - function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); }, - function ($val) { return $val; }, + function ($val) { + return in_array($val, array('auto', 'source', 'dist'), true); + }, + function ($val) { + return $val; + }, ), 'store-auths' => array( - function ($val) { return in_array($val, array('true', 'false', 'prompt'), true); }, + function ($val) { + return in_array($val, array('true', 'false', 'prompt'), true); + }, function ($val) { if ('prompt' === $val) { return 'prompt'; @@ -308,27 +318,55 @@ EOT }, ), 'notify-on-install' => array($booleanValidator, $booleanNormalizer), - 'vendor-dir' => array('is_string', function ($val) { return $val; }), - 'bin-dir' => array('is_string', function ($val) { return $val; }), - 'archive-dir' => array('is_string', function ($val) { return $val; }), - 'archive-format' => array('is_string', function ($val) { return $val; }), - 'data-dir' => array('is_string', function ($val) { return $val; }), - 'cache-dir' => array('is_string', function ($val) { return $val; }), - 'cache-files-dir' => array('is_string', function ($val) { return $val; }), - 'cache-repo-dir' => array('is_string', function ($val) { return $val; }), - 'cache-vcs-dir' => array('is_string', function ($val) { return $val; }), + 'vendor-dir' => array('is_string', function ($val) { + return $val; + }), + 'bin-dir' => array('is_string', function ($val) { + return $val; + }), + 'archive-dir' => array('is_string', function ($val) { + return $val; + }), + 'archive-format' => array('is_string', function ($val) { + return $val; + }), + 'data-dir' => array('is_string', function ($val) { + return $val; + }), + 'cache-dir' => array('is_string', function ($val) { + return $val; + }), + 'cache-files-dir' => array('is_string', function ($val) { + return $val; + }), + 'cache-repo-dir' => array('is_string', function ($val) { + return $val; + }), + 'cache-vcs-dir' => array('is_string', function ($val) { + return $val; + }), 'cache-ttl' => array('is_numeric', 'intval'), 'cache-files-ttl' => array('is_numeric', 'intval'), 'cache-files-maxsize' => array( - function ($val) { return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0; }, - function ($val) { return $val; }, + function ($val) { + return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0; + }, + function ($val) { + return $val; + }, ), 'bin-compat' => array( - function ($val) { return in_array($val, array('auto', 'full')); }, - function ($val) { return $val; }, + function ($val) { + return in_array($val, array('auto', 'full')); + }, + function ($val) { + return $val; + }, ), 'discard-changes' => array( - function ($val) { return in_array($val, array('stash', 'true', 'false', '1', '0'), true); }, + function ($val) { + return in_array($val, array('stash', 'true', 'false', '1', '0'), true); + }, function ($val) { if ('stash' === $val) { return 'stash'; @@ -337,7 +375,9 @@ EOT return $val !== 'false' && (bool) $val; }, ), - 'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }), + 'autoloader-suffix' => array('is_string', function ($val) { + return $val === 'null' ? null : $val; + }), 'sort-packages' => array($booleanValidator, $booleanNormalizer), 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer), 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer), @@ -346,12 +386,20 @@ EOT 'disable-tls' => array($booleanValidator, $booleanNormalizer), 'secure-http' => array($booleanValidator, $booleanNormalizer), 'cafile' => array( - function ($val) { return file_exists($val) && is_readable($val); }, - function ($val) { return $val === 'null' ? null : $val; }, + function ($val) { + return file_exists($val) && is_readable($val); + }, + function ($val) { + return $val === 'null' ? null : $val; + }, ), 'capath' => array( - function ($val) { return is_dir($val) && is_readable($val); }, - function ($val) { return $val === 'null' ? null : $val; }, + function ($val) { + return is_dir($val) && is_readable($val); + }, + function ($val) { + return $val === 'null' ? null : $val; + }, ), 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer), ); @@ -412,14 +460,28 @@ EOT // handle properties $uniqueProps = array( - 'name' => array('is_string', function ($val) { return $val; }), - 'type' => array('is_string', function ($val) { return $val; }), - 'description' => array('is_string', function ($val) { return $val; }), - 'homepage' => array('is_string', function ($val) { return $val; }), - 'version' => array('is_string', function ($val) { return $val; }), + 'name' => array('is_string', function ($val) { + return $val; + }), + 'type' => array('is_string', function ($val) { + return $val; + }), + 'description' => array('is_string', function ($val) { + return $val; + }), + 'homepage' => array('is_string', function ($val) { + return $val; + }), + 'version' => array('is_string', function ($val) { + return $val; + }), 'minimum-stability' => array( - function ($val) { return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]); }, - function ($val) { return VersionParser::normalizeStability($val); } + function ($val) { + return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]); + }, + function ($val) { + return VersionParser::normalizeStability($val); + }, ), 'prefer-stable' => array($booleanValidator, $booleanNormalizer), ); @@ -472,7 +534,7 @@ EOT if (2 === count($values)) { return $this->configSource->addRepository($matches[1], array( 'type' => $values[0], - 'url' => $values[1], + 'url' => $values[1], )); } diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 2cda68689..32b9d7140 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -167,7 +167,7 @@ EOT $output = ''; foreach ($messages as $style => $msgs) { foreach ($msgs as $msg) { - $output .= '<' . $style . '>' . $msg . '' . PHP_EOL; + $output .= '<' . $style . '>' . $msg . '' . PHP_EOL; } } @@ -390,6 +390,7 @@ EOT $io = $this->getIO(); if (true === $result) { $io->write('OK'); + return; } @@ -590,31 +591,31 @@ EOT foreach ($warnings as $warning => $current) { switch ($warning) { case 'apc_cli': - $text = "The apc.enable_cli setting is incorrect.".PHP_EOL; + $text = "The apc.enable_cli setting is incorrect.".PHP_EOL; $text .= "Add the following to the end of your `php.ini`:".PHP_EOL; $text .= " apc.enable_cli = Off"; $displayIniMessage = true; break; case 'zlib': - $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL; + $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL; $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL; $displayIniMessage = true; break; case 'sigchild': - $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL; + $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL; $text .= "Recompile it without this flag if possible, see also:".PHP_EOL; $text .= " https://bugs.php.net/bug.php?id=22999"; break; case 'curlwrappers': - $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL; + $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL; $text .= " Recompile it without this flag if possible"; break; case 'php': - $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL; + $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL; $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues."; break; @@ -628,12 +629,12 @@ EOT break; case 'xdebug_loaded': - $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL; + $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL; $text .= " Disabling it when using Composer is recommended."; break; case 'xdebug_profile': - $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL; + $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL; $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL; $text .= " xdebug.profiler_enabled = 0"; $displayIniMessage = true; diff --git a/src/Composer/Command/ExecCommand.php b/src/Composer/Command/ExecCommand.php index 110456719..b5d5d9807 100644 --- a/src/Composer/Command/ExecCommand.php +++ b/src/Composer/Command/ExecCommand.php @@ -45,7 +45,9 @@ class ExecCommand extends BaseCommand $binDir = $composer->getConfig()->get('bin-dir'); if ($input->getOption('list') || !$input->getArgument('binary')) { $bins = glob($binDir . '/*'); - $bins = array_merge($bins, array_map(function($e) { return "$e (local)"; }, $composer->getPackage()->getBinaries())); + $bins = array_merge($bins, array_map(function ($e) { + return "$e (local)"; + }, $composer->getPackage()->getBinaries())); if (!$bins) { throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)"); diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index e2361e226..7c3ce96f5 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -323,7 +323,7 @@ EOT if (preg_match('/^(?P[- .,\p{L}\p{N}\'’"()]+) <(?P.+?)>$/u', $author, $match)) { if ($this->isValidEmail($match['email'])) { return array( - 'name' => trim($match['name']), + 'name' => trim($match['name']), 'email' => $match['email'], ); } diff --git a/src/Composer/Command/LicensesCommand.php b/src/Composer/Command/LicensesCommand.php index 5428b55f8..85e28e82a 100644 --- a/src/Composer/Command/LicensesCommand.php +++ b/src/Composer/Command/LicensesCommand.php @@ -97,9 +97,9 @@ EOT } $io->write(JsonFile::encode(array( - 'name' => $root->getPrettyName(), - 'version' => $root->getFullPrettyVersion(), - 'license' => $root->getLicense(), + 'name' => $root->getPrettyName(), + 'version' => $root->getFullPrettyVersion(), + 'license' => $root->getLicense(), 'dependencies' => $dependencies, ))); break; diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 36dab96c4..358b0f28f 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -185,6 +185,7 @@ EOT } $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json'); + return 1; } } else { @@ -314,14 +315,13 @@ EOT if ($showVersion) { $versionLength = max($versionLength, strlen($package->getFullPrettyVersion())); if ($showLatest) { - $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly); if ($latestPackage === false) { continue; } $latestPackages[$package->getPrettyName()] = $latestPackage; - $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion())); + $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion())); } } } else { @@ -464,6 +464,7 @@ EOT protected function getRootRequires() { $rootPackage = $this->getComposer()->getPackage(); + return array_map( 'strtolower', array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires())) @@ -775,7 +776,8 @@ EOT return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus); } - private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package) { + private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package) + { if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) { return 'up-to-date'; } @@ -806,10 +808,10 @@ EOT /** * Given a package, this finds the latest package matching it * - * @param PackageInterface $package - * @param Composer $composer - * @param string $phpVersion - * @param bool $minorOnly + * @param PackageInterface $package + * @param Composer $composer + * @param string $phpVersion + * @param bool $minorOnly * * @return PackageInterface|null */ diff --git a/src/Composer/Command/StatusCommand.php b/src/Composer/Command/StatusCommand.php index 059cddbc3..03d1ff771 100644 --- a/src/Composer/Command/StatusCommand.php +++ b/src/Composer/Command/StatusCommand.php @@ -32,10 +32,9 @@ use Composer\Util\ProcessExecutor; */ class StatusCommand extends BaseCommand { - - const EXIT_CODE_ERRORS = 1; + const EXIT_CODE_ERRORS = 1; const EXIT_CODE_UNPUSHED_CHANGES = 2; - const EXIT_CODE_VERSION_CHANGES = 4; + const EXIT_CODE_VERSION_CHANGES = 4; protected function configure() { @@ -113,11 +112,11 @@ EOT $vcsVersionChanges[$targetDir] = array( 'previous' => array( 'version' => $package->getPrettyVersion(), - 'ref' => $previousRef + 'ref' => $previousRef, ), - 'current' => array( + 'current' => array( 'version' => $currentVersion['pretty_version'], - 'ref' => $currentVersion['commit'], + 'ref' => $currentVersion['commit'], ), ); } @@ -134,6 +133,7 @@ EOT // output errors/warnings if (!$errors && !$unpushedChanges && !$vcsVersionChanges) { $io->writeError('No local changes'); + return 0; } diff --git a/src/Composer/Config.php b/src/Composer/Config.php index fcf00c2f2..d51fe6905 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -416,7 +416,7 @@ class Config { if (isset($this->repositories[$name])) { unset($this->repositories[$name]); - } else if ($name === 'packagist') { // BC support for default "packagist" named repo + } elseif ($name === 'packagist') { // BC support for default "packagist" named repo unset($this->repositories['packagist.org']); } } diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index acd151a20..cbfb2292c 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/src/Composer/Config/JsonConfigSource.php @@ -123,12 +123,12 @@ class JsonConfigSource implements ConfigSourceInterface if (substr($key, 0, 6) === 'extra.') { $bits = explode('.', $key); $last = array_pop($bits); - $arr =& $config['extra']; + $arr = &$config['extra']; foreach ($bits as $bit) { if (!isset($arr[$bit])) { $arr[$bit] = array(); } - $arr =& $arr[$bit]; + $arr = &$arr[$bit]; } $arr[$last] = $val; } else { @@ -147,12 +147,12 @@ class JsonConfigSource implements ConfigSourceInterface if (substr($key, 0, 6) === 'extra.') { $bits = explode('.', $key); $last = array_pop($bits); - $arr =& $config['extra']; + $arr = &$config['extra']; foreach ($bits as $bit) { if (!isset($arr[$bit])) { return; } - $arr =& $arr[$bit]; + $arr = &$arr[$bit]; } unset($arr[$last]); } else { diff --git a/src/Composer/DependencyResolver/Operation/UpdateOperation.php b/src/Composer/DependencyResolver/Operation/UpdateOperation.php index a99fe6125..836725ef5 100644 --- a/src/Composer/DependencyResolver/Operation/UpdateOperation.php +++ b/src/Composer/DependencyResolver/Operation/UpdateOperation.php @@ -36,7 +36,7 @@ class UpdateOperation extends SolverOperation parent::__construct($reason); $this->initialPackage = $initial; - $this->targetPackage = $target; + $this->targetPackage = $target; } /** diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 4657838f0..520109d66 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -820,7 +820,7 @@ class Solver $lastLiteral = null; $lastLevel = null; $lastBranchIndex = 0; - $lastBranchOffset = 0; + $lastBranchOffset = 0; for ($i = count($this->branches) - 1; $i >= 0; $i--) { list($literals, $l) = $this->branches[$i]; diff --git a/src/Composer/DependencyResolver/Transaction.php b/src/Composer/DependencyResolver/Transaction.php index 7c38d92fb..bb60dccc2 100644 --- a/src/Composer/DependencyResolver/Transaction.php +++ b/src/Composer/DependencyResolver/Transaction.php @@ -97,7 +97,8 @@ class Transaction protected function transactionFromMaps($installMap, $updateMap, $uninstallMap) { - $queue = array_map(function ($operation) { + $queue = array_map( + function ($operation) { return $operation['package']; }, $this->findRootPackages($installMap, $updateMap) diff --git a/src/Composer/Downloader/DownloadManager.php b/src/Composer/Downloader/DownloadManager.php index d18bb1ced..77b41c5eb 100644 --- a/src/Composer/Downloader/DownloadManager.php +++ b/src/Composer/Downloader/DownloadManager.php @@ -28,7 +28,7 @@ class DownloadManager private $preferSource = false; private $packagePreferences = array(); private $filesystem; - private $downloaders = array(); + private $downloaders = array(); /** * Initializes download manager. @@ -181,8 +181,8 @@ class DownloadManager public function download(PackageInterface $package, $targetDir, $preferSource = null) { $preferSource = null !== $preferSource ? $preferSource : $this->preferSource; - $sourceType = $package->getSourceType(); - $distType = $package->getDistType(); + $sourceType = $package->getSourceType(); + $distType = $package->getDistType(); $sources = array(); if ($sourceType) { @@ -248,10 +248,10 @@ class DownloadManager if ('dist' === $installationSource) { $initialType = $initial->getDistType(); - $targetType = $target->getDistType(); + $targetType = $target->getDistType(); } else { $initialType = $initial->getSourceType(); - $targetType = $target->getSourceType(); + $targetType = $target->getSourceType(); } // upgrading from a dist stable package to a dev package, force source reinstall diff --git a/src/Composer/Downloader/FossilDownloader.php b/src/Composer/Downloader/FossilDownloader.php index 63839df65..0b2c0181d 100644 --- a/src/Composer/Downloader/FossilDownloader.php +++ b/src/Composer/Downloader/FossilDownloader.php @@ -97,8 +97,7 @@ class FossilDownloader extends VcsDownloader $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/'; foreach ($this->process->splitLines($output) as $line) { - if (preg_match($match, $line)) - { + if (preg_match($match, $line)) { break; } $log .= $line; diff --git a/src/Composer/Downloader/GitDownloader.php b/src/Composer/Downloader/GitDownloader.php index 89a86369f..5cd69d5e4 100644 --- a/src/Composer/Downloader/GitDownloader.php +++ b/src/Composer/Downloader/GitDownloader.php @@ -59,7 +59,8 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface $cacheOptions = sprintf('--dissociate --reference %s ', ProcessExecutor::escape($cachePath)); $msg = "Cloning ".$this->getShortHash($ref).' from cache'; } - } catch (\RuntimeException $e) {} + } catch (\RuntimeException $e) { + } } $command = 'git clone --no-checkout %s %s '.$cacheOptions.'&& cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer'; $this->io->writeError($msg); diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index c40807258..213be04a1 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -30,7 +30,7 @@ use Symfony\Component\Filesystem\Filesystem; class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface { const STRATEGY_SYMLINK = 10; - const STRATEGY_MIRROR = 20; + const STRATEGY_MIRROR = 20; /** * {@inheritdoc} diff --git a/src/Composer/Downloader/VcsCapableDownloaderInterface.php b/src/Composer/Downloader/VcsCapableDownloaderInterface.php index fa4ddf485..39203d5a5 100644 --- a/src/Composer/Downloader/VcsCapableDownloaderInterface.php +++ b/src/Composer/Downloader/VcsCapableDownloaderInterface.php @@ -21,7 +21,6 @@ use Composer\Package\PackageInterface; */ interface VcsCapableDownloaderInterface { - /** * Gets the VCS Reference for the package at path * diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 753446e44..63ef134aa 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -356,7 +356,7 @@ class EventDispatcher * Add a listener for a particular event * * @param string $eventName The event name - typically a constant - * @param Callable $listener A callable expecting an event argument + * @param callable $listener A callable expecting an event argument * @param int $priority A higher value represents a higher priority */ public function addListener($eventName, $listener, $priority = 0) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 21ac5ac08..68e2b8215 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -344,7 +344,7 @@ class Factory // load package $parser = new VersionParser; $guesser = new VersionGuesser($config, new ProcessExecutor($io), $parser); - $loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser); + $loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser); $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd); $composer->setPackage($package); diff --git a/src/Composer/IO/BaseIO.php b/src/Composer/IO/BaseIO.php index 456bec9c4..b327f1bbf 100644 --- a/src/Composer/IO/BaseIO.php +++ b/src/Composer/IO/BaseIO.php @@ -126,8 +126,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface /** * System is unusable. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function emergency($message, array $context = array()) @@ -141,8 +141,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function alert($message, array $context = array()) @@ -155,8 +155,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface * * Example: Application component unavailable, unexpected exception. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function critical($message, array $context = array()) @@ -168,8 +168,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function error($message, array $context = array()) @@ -183,8 +183,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function warning($message, array $context = array()) @@ -195,8 +195,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface /** * Normal but significant events. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function notice($message, array $context = array()) @@ -209,8 +209,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface * * Example: User logs in, SQL logs. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function info($message, array $context = array()) @@ -221,8 +221,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface /** * Detailed debug information. * - * @param string $message - * @param array $context + * @param string $message + * @param array $context * @return null */ public function debug($message, array $context = array()) @@ -233,9 +233,9 @@ abstract class BaseIO implements IOInterface, LoggerInterface /** * Logs with an arbitrary level. * - * @param mixed $level - * @param string $message - * @param array $context + * @param mixed $level + * @param string $message + * @param array $context * @return null */ public function log($level, $message, array $context = array()) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 69d93c69e..57172530f 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -334,7 +334,7 @@ class Installer * @param RepositoryInterface $installedRepo * @param PlatformRepository $platformRepo * @param array $aliases - * @return array [int, PackageInterfaces[]|null] with the exit code and an array of dev packages on update, or null on install + * @return array [int, PackageInterfaces[]|null] with the exit code and an array of dev packages on update, or null on install */ protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases) { @@ -1194,7 +1194,6 @@ class Installer } } - /** * @param PlatformRepository $platformRepo * @param array $aliases @@ -1424,7 +1423,7 @@ class Installer */ public function setDryRun($dryRun = true) { - $this->dryRun = (boolean) $dryRun; + $this->dryRun = (bool) $dryRun; return $this; } @@ -1447,7 +1446,7 @@ class Installer */ public function setPreferSource($preferSource = true) { - $this->preferSource = (boolean) $preferSource; + $this->preferSource = (bool) $preferSource; return $this; } @@ -1460,7 +1459,7 @@ class Installer */ public function setPreferDist($preferDist = true) { - $this->preferDist = (boolean) $preferDist; + $this->preferDist = (bool) $preferDist; return $this; } @@ -1473,7 +1472,7 @@ class Installer */ public function setOptimizeAutoloader($optimizeAutoloader = false) { - $this->optimizeAutoloader = (boolean) $optimizeAutoloader; + $this->optimizeAutoloader = (bool) $optimizeAutoloader; if (!$this->optimizeAutoloader) { // Force classMapAuthoritative off when not optimizing the // autoloader @@ -1492,7 +1491,7 @@ class Installer */ public function setClassMapAuthoritative($classMapAuthoritative = false) { - $this->classMapAuthoritative = (boolean) $classMapAuthoritative; + $this->classMapAuthoritative = (bool) $classMapAuthoritative; if ($this->classMapAuthoritative) { // Force optimizeAutoloader when classmap is authoritative $this->setOptimizeAutoloader(true); @@ -1509,7 +1508,7 @@ class Installer */ public function setApcuAutoloader($apcuAutoloader = false) { - $this->apcuAutoloader = (boolean) $apcuAutoloader; + $this->apcuAutoloader = (bool) $apcuAutoloader; return $this; } @@ -1522,7 +1521,7 @@ class Installer */ public function setUpdate($update = true) { - $this->update = (boolean) $update; + $this->update = (bool) $update; return $this; } @@ -1535,7 +1534,7 @@ class Installer */ public function setDevMode($devMode = true) { - $this->devMode = (boolean) $devMode; + $this->devMode = (bool) $devMode; return $this; } @@ -1550,7 +1549,7 @@ class Installer */ public function setDumpAutoloader($dumpAutoloader = true) { - $this->dumpAutoloader = (boolean) $dumpAutoloader; + $this->dumpAutoloader = (bool) $dumpAutoloader; return $this; } @@ -1565,7 +1564,7 @@ class Installer */ public function setRunScripts($runScripts = true) { - $this->runScripts = (boolean) $runScripts; + $this->runScripts = (bool) $runScripts; return $this; } @@ -1591,7 +1590,7 @@ class Installer */ public function setVerbose($verbose = true) { - $this->verbose = (boolean) $verbose; + $this->verbose = (bool) $verbose; return $this; } @@ -1614,7 +1613,7 @@ class Installer */ public function setIgnorePlatformRequirements($ignorePlatformReqs = false) { - $this->ignorePlatformReqs = (boolean) $ignorePlatformReqs; + $this->ignorePlatformReqs = (bool) $ignorePlatformReqs; return $this; } @@ -1641,7 +1640,7 @@ class Installer */ public function setWhitelistDependencies($updateDependencies = true) { - $this->whitelistDependencies = (boolean) $updateDependencies; + $this->whitelistDependencies = (bool) $updateDependencies; return $this; } @@ -1654,7 +1653,7 @@ class Installer */ public function setPreferStable($preferStable = true) { - $this->preferStable = (boolean) $preferStable; + $this->preferStable = (bool) $preferStable; return $this; } @@ -1667,7 +1666,7 @@ class Installer */ public function setPreferLowest($preferLowest = true) { - $this->preferLowest = (boolean) $preferLowest; + $this->preferLowest = (bool) $preferLowest; return $this; } @@ -1682,7 +1681,7 @@ class Installer */ public function setWriteLock($writeLock = true) { - $this->writeLock = (boolean) $writeLock; + $this->writeLock = (bool) $writeLock; return $this; } @@ -1697,7 +1696,7 @@ class Installer */ public function setExecuteOperations($executeOperations = true) { - $this->executeOperations = (boolean) $executeOperations; + $this->executeOperations = (bool) $executeOperations; return $this; } @@ -1710,7 +1709,7 @@ class Installer */ public function setSkipSuggest($skipSuggest = true) { - $this->skipSuggest = (boolean) $skipSuggest; + $this->skipSuggest = (bool) $skipSuggest; return $this; } diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index b69744e7e..9f50b5980 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -186,7 +186,7 @@ class InstallationManager $target = $operation->getTargetPackage(); $initialType = $initial->getType(); - $targetType = $target->getType(); + $targetType = $target->getType(); if ($initialType === $targetType) { $installer = $this->getInstaller($initialType); @@ -273,8 +273,8 @@ class InstallationManager ); $opts = array('http' => array( - 'method' => 'POST', - 'header' => array('Content-type: application/x-www-form-urlencoded'), + 'method' => 'POST', + 'header' => array('Content-type: application/x-www-form-urlencoded'), 'content' => http_build_query($params, '', '&'), 'timeout' => 3, ), @@ -300,8 +300,8 @@ class InstallationManager $opts = array('http' => array( - 'method' => 'POST', - 'header' => array('Content-Type: application/json'), + 'method' => 'POST', + 'header' => array('Content-Type: application/json'), 'content' => json_encode($postData), 'timeout' => 6, ), diff --git a/src/Composer/Package/Archiver/ArchivableFilesFilter.php b/src/Composer/Package/Archiver/ArchivableFilesFilter.php index 0eda18bad..4a9a5af1f 100644 --- a/src/Composer/Package/Archiver/ArchivableFilesFilter.php +++ b/src/Composer/Package/Archiver/ArchivableFilesFilter.php @@ -26,7 +26,7 @@ class ArchivableFilesFilter extends FilterIterator { $file = $this->getInnerIterator()->current(); if ($file->isDir()) { - $this->dirs[] = (string)$file; + $this->dirs[] = (string) $file; return false; } diff --git a/src/Composer/Package/Archiver/ArchivableFilesFinder.php b/src/Composer/Package/Archiver/ArchivableFilesFinder.php index e99f5343f..150e5f48e 100644 --- a/src/Composer/Package/Archiver/ArchivableFilesFinder.php +++ b/src/Composer/Package/Archiver/ArchivableFilesFinder.php @@ -35,9 +35,9 @@ class ArchivableFilesFinder extends \FilterIterator /** * Initializes the internal Symfony Finder with appropriate filters * - * @param string $sources Path to source files to be archived - * @param array $excludes Composer's own exclude rules from composer.json - * @param boolean $ignoreFilters Ignore filters when looking for files + * @param string $sources Path to source files to be archived + * @param array $excludes Composer's own exclude rules from composer.json + * @param bool $ignoreFilters Ignore filters when looking for files */ public function __construct($sources, array $excludes, $ignoreFilters = false) { diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index e1558c1dd..35a3d3467 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -94,12 +94,12 @@ class ArchiveManager /** * Create an archive of the specified package. * - * @param PackageInterface $package The package to archive - * @param string $format The format of the archive (zip, tar, ...) - * @param string $targetDir The directory where to build the archive - * @param string|null $fileName The relative file name to use for the archive, or null to generate - * the package name. Note that the format will be appended to this name - * @param boolean $ignoreFilters Ignore filters when looking for files in the package + * @param PackageInterface $package The package to archive + * @param string $format The format of the archive (zip, tar, ...) + * @param string $targetDir The directory where to build the archive + * @param string|null $fileName The relative file name to use for the archive, or null to generate + * the package name. Note that the format will be appended to this name + * @param bool $ignoreFilters Ignore filters when looking for files in the package * @throws \InvalidArgumentException * @throws \RuntimeException * @return string The path of the created archive diff --git a/src/Composer/Package/Archiver/PharArchiver.php b/src/Composer/Package/Archiver/PharArchiver.php index 7f64c343e..cbab4ba23 100644 --- a/src/Composer/Package/Archiver/PharArchiver.php +++ b/src/Composer/Package/Archiver/PharArchiver.php @@ -20,14 +20,14 @@ namespace Composer\Package\Archiver; class PharArchiver implements ArchiverInterface { protected static $formats = array( - 'zip' => \Phar::ZIP, - 'tar' => \Phar::TAR, - 'tar.gz' => \Phar::TAR, + 'zip' => \Phar::ZIP, + 'tar' => \Phar::TAR, + 'tar.gz' => \Phar::TAR, 'tar.bz2' => \Phar::TAR, ); protected static $compressFormats = array( - 'tar.gz' => \Phar::GZ, + 'tar.gz' => \Phar::GZ, 'tar.bz2' => \Phar::BZ2, ); diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index 6106f8dda..1e3081c7e 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -23,25 +23,25 @@ use Composer\Repository\PlatformRepository; abstract class BasePackage implements PackageInterface { public static $supportedLinkTypes = array( - 'require' => array('description' => 'requires', 'method' => 'requires'), - 'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'), - 'provide' => array('description' => 'provides', 'method' => 'provides'), - 'replace' => array('description' => 'replaces', 'method' => 'replaces'), + 'require' => array('description' => 'requires', 'method' => 'requires'), + 'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'), + 'provide' => array('description' => 'provides', 'method' => 'provides'), + 'replace' => array('description' => 'replaces', 'method' => 'replaces'), 'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'), ); - const STABILITY_STABLE = 0; - const STABILITY_RC = 5; - const STABILITY_BETA = 10; - const STABILITY_ALPHA = 15; - const STABILITY_DEV = 20; + const STABILITY_STABLE = 0; + const STABILITY_RC = 5; + const STABILITY_BETA = 10; + const STABILITY_ALPHA = 15; + const STABILITY_DEV = 20; public static $stabilities = array( 'stable' => self::STABILITY_STABLE, - 'RC' => self::STABILITY_RC, - 'beta' => self::STABILITY_BETA, - 'alpha' => self::STABILITY_ALPHA, - 'dev' => self::STABILITY_DEV, + 'RC' => self::STABILITY_RC, + 'beta' => self::STABILITY_BETA, + 'alpha' => self::STABILITY_ALPHA, + 'dev' => self::STABILITY_DEV, ); /** diff --git a/src/Composer/Package/CompletePackage.php b/src/Composer/Package/CompletePackage.php index 0a926a4ce..5dbdb82e3 100644 --- a/src/Composer/Package/CompletePackage.php +++ b/src/Composer/Package/CompletePackage.php @@ -176,7 +176,7 @@ class CompletePackage extends Package implements CompletePackageInterface */ public function isAbandoned() { - return (boolean) $this->abandoned; + return (bool) $this->abandoned; } /** diff --git a/src/Composer/Package/Dumper/ArrayDumper.php b/src/Composer/Package/Dumper/ArrayDumper.php index faea5666a..6593143d5 100644 --- a/src/Composer/Package/Dumper/ArrayDumper.php +++ b/src/Composer/Package/Dumper/ArrayDumper.php @@ -133,7 +133,7 @@ class ArrayDumper } $getter = 'get'.ucfirst($method); - $value = $package->$getter(); + $value = $package->$getter(); if (null !== $value && !(is_array($value) && 0 === count($value))) { $data[$key] = $value; diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index a495f96b1..d384b1751 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -73,7 +73,7 @@ class RootPackageLoader extends ArrayLoader $version = getenv('COMPOSER_ROOT_VERSION'); $commit = null; } else { - $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd()); + $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd()); $version = $versionData['version']; $commit = $versionData['commit']; } diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 12102e3e6..b11f5a975 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -355,7 +355,7 @@ class Locker continue; } - $name = $package->getPrettyName(); + $name = $package->getPrettyName(); $version = $package->getPrettyVersion(); if (!$name || !$version) { diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index bb67e03a6..9cae9ee5d 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -232,7 +232,7 @@ class PluginManager public function addPlugin(PluginInterface $plugin) { $this->io->writeError('Loading plugin '.get_class($plugin), true, IOInterface::DEBUG); - $this->plugins[] = $plugin; + $this->plugins[] = $plugin; $plugin->activate($this->composer, $this->io); if ($plugin instanceof EventSubscriberInterface) { @@ -383,10 +383,10 @@ class PluginManager } /** - * @param string $capabilityClassName The fully qualified name of the API interface which the plugin may provide - * an implementation of. - * @param array $ctorArgs Arguments passed to Capability's constructor. - * Keeping it an array will allow future values to be passed w\o changing the signature. + * @param string $capabilityClassName The fully qualified name of the API interface which the plugin may provide + * an implementation of. + * @param array $ctorArgs Arguments passed to Capability's constructor. + * Keeping it an array will allow future values to be passed w\o changing the signature. * @return Capability[] */ public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array()) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index c0cac4edc..02d40e9a4 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -266,7 +266,7 @@ class PlatformRepository extends ArrayRepository /** * Parses the version and adds a new package to the repository * - * @param string $name + * @param string $name * @param null|string $prettyVersion */ private function addExtension($name, $prettyVersion) diff --git a/src/Composer/Repository/RepositoryInterface.php b/src/Composer/Repository/RepositoryInterface.php index ccbdc2226..4e8e478f4 100644 --- a/src/Composer/Repository/RepositoryInterface.php +++ b/src/Composer/Repository/RepositoryInterface.php @@ -65,8 +65,8 @@ interface RepositoryInterface extends \Countable /** * Searches the repository for packages containing the query * - * @param string $query search query - * @param int $mode a set of SEARCH_* constants to search on, implementations should do a best effort only + * @param string $query search query + * @param int $mode a set of SEARCH_* constants to search on, implementations should do a best effort only * * @return \array[] an array of array('name' => '...', 'description' => '...') */ diff --git a/src/Composer/Repository/Vcs/BitbucketDriver.php b/src/Composer/Repository/Vcs/BitbucketDriver.php index ba1851f53..707e8189f 100644 --- a/src/Composer/Repository/Vcs/BitbucketDriver.php +++ b/src/Composer/Repository/Vcs/BitbucketDriver.php @@ -56,7 +56,7 @@ abstract class BitbucketDriver extends VcsDriver $this->config->get('cache-repo-dir'), $this->originUrl, $this->owner, - $this->repository + $this->repository, )) ); } @@ -104,6 +104,7 @@ abstract class BitbucketDriver extends VcsDriver $this->homeUrl = $repoData['links']['html']['href']; $this->website = $repoData['website']; $this->vcsType = $repoData['scm']; + return true; } @@ -268,7 +269,7 @@ abstract class BitbucketDriver extends VcsDriver array( 'pagelen' => 100, 'fields' => 'values.name,values.target.hash,next', - 'sort' => '-target.date' + 'sort' => '-target.date', ), null, '&' @@ -312,7 +313,7 @@ abstract class BitbucketDriver extends VcsDriver array( 'pagelen' => 100, 'fields' => 'values.name,values.target.hash,next', - 'sort' => '-target.date' + 'sort' => '-target.date', ), null, '&' @@ -338,8 +339,8 @@ abstract class BitbucketDriver extends VcsDriver /** * Get the remote content. * - * @param string $url The URL of content - * @param bool $fetchingRepoData + * @param string $url The URL of content + * @param bool $fetchingRepoData * * @return mixed The result */ @@ -389,13 +390,13 @@ abstract class BitbucketDriver extends VcsDriver } /** - * @param string $url + * @param string $url * @return void */ abstract protected function setupFallbackDriver($url); /** - * @param array $cloneLinks + * @param array $cloneLinks * @return void */ protected function parseCloneUrls(array $cloneLinks) diff --git a/src/Composer/Repository/Vcs/FossilDriver.php b/src/Composer/Repository/Vcs/FossilDriver.php index b992db7ec..e0abd10fc 100644 --- a/src/Composer/Repository/Vcs/FossilDriver.php +++ b/src/Composer/Repository/Vcs/FossilDriver.php @@ -13,7 +13,6 @@ namespace Composer\Repository\Vcs; use Composer\Config; -use Composer\Json\JsonFile; use Composer\Util\ProcessExecutor; use Composer\Util\Filesystem; use Composer\IO\IOInterface; @@ -142,6 +141,7 @@ class FossilDriver extends VcsDriver public function getChangeDate($identifier) { $this->process->execute(sprintf('fossil finfo composer.json | head -n 2 | tail -n 1 | awk \'{print $1}\''), $output, $this->checkoutDir); + return new \DateTime(trim($output), new \DateTimeZone('UTC')); } @@ -194,8 +194,7 @@ class FossilDriver extends VcsDriver return true; } - if (preg_match('!/fossil/|\.fossil!', $url)) - { + if (preg_match('!/fossil/|\.fossil!', $url)) { return true; } @@ -214,5 +213,5 @@ class FossilDriver extends VcsDriver } return false; - } + } } diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 42998992d..0f2c95714 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -12,7 +12,6 @@ namespace Composer\Repository\Vcs; -use Composer\Json\JsonFile; use Composer\Util\ProcessExecutor; use Composer\Util\Filesystem; use Composer\Util\Git as GitUtil; @@ -143,6 +142,7 @@ class GitDriver extends VcsDriver 'git log -1 --format=%%at %s', ProcessExecutor::escape($identifier) ), $output, $this->repoDir); + return new \DateTime('@'.trim($output), new \DateTimeZone('UTC')); } diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 42c509580..d1d6705f1 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -186,7 +186,6 @@ class GitHubDriver extends VcsDriver $notFoundRetries = 2; while ($notFoundRetries) { try { - $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier); $resource = JsonFile::parseJson($this->getContents($resource)); if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) { @@ -202,6 +201,7 @@ class GitHubDriver extends VcsDriver // TODO should be removed when possible // retry fetching if github returns a 404 since they happen randomly $notFoundRetries--; + return null; } } @@ -220,6 +220,7 @@ class GitHubDriver extends VcsDriver $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier); $commit = JsonFile::parseJson($this->getContents($resource), $resource); + return new \DateTime($commit['commit']['committer']['date']); } diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php index 8c4d6e25a..99e324b30 100644 --- a/src/Composer/Repository/Vcs/GitLabDriver.php +++ b/src/Composer/Repository/Vcs/GitLabDriver.php @@ -127,6 +127,7 @@ class GitLabDriver extends VcsDriver if ($e->getCode() !== 404) { throw $e; } + return null; } @@ -149,7 +150,6 @@ class GitLabDriver extends VcsDriver return new \DateTime(); } - /** * {@inheritDoc} */ @@ -247,7 +247,7 @@ class GitLabDriver extends VcsDriver /** * Urlencode all non alphanumeric characters. rawurlencode() can not be used as it does not encode `.` * - * @param string $string + * @param string $string * @return string */ private function urlEncodeAll($string) @@ -260,6 +260,7 @@ class GitLabDriver extends VcsDriver } $encoded .= $character; } + return $encoded; } diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index bad52bed3..d9df58412 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -13,7 +13,6 @@ namespace Composer\Repository\Vcs; use Composer\Config; -use Composer\Json\JsonFile; use Composer\Util\ProcessExecutor; use Composer\Util\Filesystem; use Composer\IO\IOInterface; @@ -142,6 +141,7 @@ class HgDriver extends VcsDriver $output, $this->repoDir ); + return new \DateTime(trim($output), new \DateTimeZone('UTC')); } diff --git a/src/Composer/Repository/Vcs/PerforceDriver.php b/src/Composer/Repository/Vcs/PerforceDriver.php index e6411a412..f9c6937ec 100644 --- a/src/Composer/Repository/Vcs/PerforceDriver.php +++ b/src/Composer/Repository/Vcs/PerforceDriver.php @@ -26,6 +26,7 @@ class PerforceDriver extends VcsDriver protected $branch; /** @var Perforce */ protected $perforce; + /** * {@inheritDoc} */ @@ -57,7 +58,6 @@ class PerforceDriver extends VcsDriver $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io); } - /** * {@inheritdoc} */ @@ -116,10 +116,10 @@ class PerforceDriver extends VcsDriver public function getSource($identifier) { $source = array( - 'type' => 'perforce', - 'url' => $this->repoConfig['url'], + 'type' => 'perforce', + 'url' => $this->repoConfig['url'], 'reference' => $identifier, - 'p4user' => $this->perforce->getUser(), + 'p4user' => $this->perforce->getUser(), ); return $source; diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index ffc7183f7..2c31f8173 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -37,10 +37,10 @@ class SvnDriver extends VcsDriver protected $rootIdentifier; protected $infoCache = array(); - protected $trunkPath = 'trunk'; + protected $trunkPath = 'trunk'; protected $branchesPath = 'branches'; - protected $tagsPath = 'tags'; - protected $packagePath = ''; + protected $tagsPath = 'tags'; + protected $packagePath = ''; protected $cacheCredentials = true; /** @@ -132,7 +132,6 @@ class SvnDriver extends VcsDriver $this->infoCache[$identifier] = $composer; } - return $this->infoCache[$identifier]; } diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index c72a6c6a8..a59472fde 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -75,8 +75,8 @@ abstract class VcsDriver implements VcsDriverInterface /** * Returns whether or not the given $identifier should be cached or not. * - * @param string $identifier - * @return boolean + * @param string $identifier + * @return bool */ protected function shouldCache($identifier) { @@ -102,7 +102,6 @@ abstract class VcsDriver implements VcsDriverInterface $this->infoCache[$identifier] = $composer; } - return $this->infoCache[$identifier]; } diff --git a/src/Composer/Repository/Vcs/VcsDriverInterface.php b/src/Composer/Repository/Vcs/VcsDriverInterface.php index 5f77b3161..5e3bcec68 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 */ public function getFileContent($file, $identifier); @@ -45,7 +45,7 @@ interface VcsDriverInterface /** * Get the changedate for $identifier. * - * @param string $identifier + * @param string $identifier * @return \DateTime */ public function getChangeDate($identifier); diff --git a/src/Composer/Repository/VcsRepository.php b/src/Composer/Repository/VcsRepository.php index cef099b75..a1771c554 100644 --- a/src/Composer/Repository/VcsRepository.php +++ b/src/Composer/Repository/VcsRepository.php @@ -46,16 +46,16 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt { parent::__construct(); $this->drivers = $drivers ?: array( - 'github' => 'Composer\Repository\Vcs\GitHubDriver', - 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver', + 'github' => 'Composer\Repository\Vcs\GitHubDriver', + 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver', 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver', - 'git' => 'Composer\Repository\Vcs\GitDriver', - 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver', - 'hg' => 'Composer\Repository\Vcs\HgDriver', - 'perforce' => 'Composer\Repository\Vcs\PerforceDriver', - 'fossil' => 'Composer\Repository\Vcs\FossilDriver', + 'git' => 'Composer\Repository\Vcs\GitDriver', + 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver', + 'hg' => 'Composer\Repository\Vcs\HgDriver', + 'perforce' => 'Composer\Repository\Vcs\PerforceDriver', + 'fossil' => 'Composer\Repository\Vcs\FossilDriver', // svn must be last because identifying a subversion server for sure is practically impossible - 'svn' => 'Composer\Repository\Vcs\SvnDriver', + 'svn' => 'Composer\Repository\Vcs\SvnDriver', ); $this->url = $repoConfig['url']; diff --git a/src/Composer/Util/Bitbucket.php b/src/Composer/Util/Bitbucket.php index 4e5579c94..cba9fd25d 100644 --- a/src/Composer/Util/Bitbucket.php +++ b/src/Composer/Util/Bitbucket.php @@ -57,6 +57,7 @@ class Bitbucket if (!isset($this->token['access_token'])) { return ''; } + return $this->token['access_token']; } @@ -213,14 +214,14 @@ class Bitbucket "consumer-key" => $consumerKey, "consumer-secret" => $consumerSecret, "access-token" => $this->token['access_token'], - "access-token-expiration" => $time + $this->token['expires_in'] + "access-token-expiration" => $time + $this->token['expires_in'], ); $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer); } /** - * @param string $originUrl + * @param string $originUrl * @return bool */ private function getTokenFromConfig($originUrl) @@ -236,7 +237,7 @@ class Bitbucket } $this->token = array( - 'access_token' => $authConfig[$originUrl]['access-token'] + 'access_token' => $authConfig[$originUrl]['access-token'], ); return true; diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 97b36ef19..82962455c 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -165,7 +165,7 @@ class Git $defaultUsername = null; if (isset($authParts) && $authParts) { if (false !== strpos($authParts, ':')) { - list($defaultUsername,) = explode(':', $authParts, 2); + list($defaultUsername, ) = explode(':', $authParts, 2); } else { $defaultUsername = $authParts; } @@ -238,7 +238,7 @@ class Git 'fatal: Authentication failed', 'remote error: Invalid username or password.', 'error: 401 Unauthorized', - 'fatal: unable to access' + 'fatal: unable to access', ); foreach ($authFailures as $authFailure) { diff --git a/src/Composer/Util/NoProxyPattern.php b/src/Composer/Util/NoProxyPattern.php index 994149268..5cc6e361b 100644 --- a/src/Composer/Util/NoProxyPattern.php +++ b/src/Composer/Util/NoProxyPattern.php @@ -125,7 +125,7 @@ class NoProxyPattern list($a, $b, $c, $d) = explode('.', $base); // Now do some bit shifting/switching to convert to ints - $i = ($a << 24) + ($b << 16) + ($c << 8) + $d; + $i = ($a << 24) + ($b << 16) + ($c << 8) + $d; $mask = $bits == 0 ? 0 : (~0 << (32 - $bits)); // Here's our lowest int diff --git a/src/Composer/Util/Perforce.php b/src/Composer/Util/Perforce.php index f3c20fce3..364f2394f 100644 --- a/src/Composer/Util/Perforce.php +++ b/src/Composer/Util/Perforce.php @@ -285,7 +285,7 @@ class Perforce public function isLoggedIn() { $command = $this->generateP4Command('login -s', false); - $exitCode = $this->executeCommand($command); + $exitCode = $this->executeCommand($command); if ($exitCode) { $errorOutput = $this->process->getErrorOutput(); $index = strpos($errorOutput, $this->getUser()); @@ -441,6 +441,7 @@ class Perforce if ($index3 !== false) { $phrase = trim(substr($result, $index3)); $fields = explode(' ', $phrase); + return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1]; } } diff --git a/src/Composer/Util/Platform.php b/src/Composer/Util/Platform.php index f60737e13..60bf9efa9 100644 --- a/src/Composer/Util/Platform.php +++ b/src/Composer/Util/Platform.php @@ -22,7 +22,7 @@ class Platform /** * Parses tildes and environment variables in paths. * - * @param string $path + * @param string $path * @return string */ public static function expandPath($path) @@ -30,18 +30,20 @@ class Platform if (preg_match('#^~[\\/]#', $path)) { return self::getUserDirectory() . substr($path, 1); } - return preg_replace_callback('#^(\$|(?P%))(?P\w++)(?(percent)%)(?P.*)#', function($matches) { + + return preg_replace_callback('#^(\$|(?P%))(?P\w++)(?(percent)%)(?P.*)#', function ($matches) { // Treat HOME as an alias for USERPROFILE on Windows for legacy reasons if (Platform::isWindows() && $matches['var'] == 'HOME') { return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path']; } + return getenv($matches['var']) . $matches['path']; }, $path); } /** - * @return string The formal user home as detected from environment parameters * @throws \RuntimeException If the user home could not reliably be determined + * @return string The formal user home as detected from environment parameters */ public static function getUserDirectory() { @@ -55,6 +57,7 @@ class Platform if (function_exists('posix_getuid') && function_exists('posix_getpwuid')) { $info = posix_getpwuid(posix_getuid()); + return $info['dir']; } @@ -71,7 +74,7 @@ class Platform /** * @param string $str - * @return int return a guaranteed binary length of the string, regardless of silly mbstring configs + * @return int return a guaranteed binary length of the string, regardless of silly mbstring configs */ public static function strlen($str) { diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index ed5eb720e..ee0bfaace 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -721,8 +721,7 @@ class RemoteFilesystem } elseif ($this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)) { if ($auth['password'] === 'oauth2') { $headers[] = 'Authorization: Bearer '.$auth['username']; - } - else if ($auth['password'] === 'private-token') { + } elseif ($auth['password'] === 'private-token') { $headers[] = 'PRIVATE-TOKEN: '.$auth['username']; } } elseif ('bitbucket.org' === $originUrl diff --git a/src/Composer/Util/Silencer.php b/src/Composer/Util/Silencer.php index 03cfff430..69a065dd6 100644 --- a/src/Composer/Util/Silencer.php +++ b/src/Composer/Util/Silencer.php @@ -1,4 +1,5 @@ url = $url; - $this->io = $io; + $this->io = $io; $this->config = $config; $this->process = $process ?: new ProcessExecutor; } diff --git a/src/Composer/Util/TlsHelper.php b/src/Composer/Util/TlsHelper.php index a089046ae..b261f47a5 100644 --- a/src/Composer/Util/TlsHelper.php +++ b/src/Composer/Util/TlsHelper.php @@ -12,7 +12,6 @@ namespace Composer\Util; -use Symfony\Component\Process\PhpProcess; use Composer\CaBundle\CaBundle; /** @@ -137,12 +136,12 @@ final class TlsHelper public static function getCertificateFingerprint($certificate) { $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate)); - $pubkeypem = $pubkeydetails['key']; + $pubkeypem = $pubkeydetails['key']; //Convert PEM to DER before SHA1'ing - $start = '-----BEGIN PUBLIC KEY-----'; - $end = '-----END PUBLIC KEY-----'; - $pemtrim = substr($pubkeypem, (strpos($pubkeypem, $start) + strlen($start)), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1)); - $der = base64_decode($pemtrim); + $start = '-----BEGIN PUBLIC KEY-----'; + $end = '-----END PUBLIC KEY-----'; + $pemtrim = substr($pubkeypem, (strpos($pubkeypem, $start) + strlen($start)), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1)); + $der = base64_decode($pemtrim); return sha1($der); } diff --git a/src/Composer/XdebugHandler.php b/src/Composer/XdebugHandler.php index ad2343c0e..dae3ee840 100644 --- a/src/Composer/XdebugHandler.php +++ b/src/Composer/XdebugHandler.php @@ -67,6 +67,7 @@ class XdebugHandler $command = $this->getCommand(); $this->restart($command); } + return; } @@ -199,8 +200,8 @@ class XdebugHandler /** * Returns true if the restart environment variables were set * - * @param bool $additional Whether there were additional inis - * @param array $iniPaths Locations used by the current prcoess + * @param bool $additional Whether there were additional inis + * @param array $iniPaths Locations used by the current prcoess * * @return bool */ @@ -249,7 +250,7 @@ class XdebugHandler } if ($this->output->isDecorated()) { - $offset = count($args) > 1 ? 2: 1; + $offset = count($args) > 1 ? 2 : 1; array_splice($args, $offset, 0, '--ansi'); } @@ -262,8 +263,8 @@ class XdebugHandler * From https://github.com/johnstevenson/winbox-args * MIT Licensed (c) John Stevenson * - * @param string $arg The argument to be escaped - * @param bool $meta Additionally escape cmd.exe meta characters + * @param string $arg The argument to be escaped + * @param bool $meta Additionally escape cmd.exe meta characters * * @return string The escaped argument */ diff --git a/tests/Composer/Test/AllFunctionalTest.php b/tests/Composer/Test/AllFunctionalTest.php index c1751fa3d..78d306805 100644 --- a/tests/Composer/Test/AllFunctionalTest.php +++ b/tests/Composer/Test/AllFunctionalTest.php @@ -182,7 +182,7 @@ class AllFunctionalTest extends TestCase break; case 'EXPECT-EXIT-CODE': - $sectionData = (integer) $sectionData; + $sectionData = (int) $sectionData; break; case 'EXPECT': diff --git a/tests/Composer/Test/Autoload/ClassLoaderTest.php b/tests/Composer/Test/Autoload/ClassLoaderTest.php index 530dd8c4d..ed398b7f8 100644 --- a/tests/Composer/Test/Autoload/ClassLoaderTest.php +++ b/tests/Composer/Test/Autoload/ClassLoaderTest.php @@ -24,7 +24,7 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase * * @dataProvider getLoadClassTests * - * @param string $class The fully-qualified class name to test, without preceding namespace separator. + * @param string $class The fully-qualified class name to test, without preceding namespace separator. */ public function testLoadClass($class) { diff --git a/tests/Composer/Test/CacheTest.php b/tests/Composer/Test/CacheTest.php index 4e8ed6045..4fb467d22 100644 --- a/tests/Composer/Test/CacheTest.php +++ b/tests/Composer/Test/CacheTest.php @@ -17,7 +17,10 @@ use Composer\Util\Filesystem; class CacheTest extends TestCase { - private $files, $root, $finder, $cache; + private $files; + private $root; + private $finder; + private $cache; public function setUp() { diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index 80e7935d3..23bc32acb 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -17,7 +17,6 @@ use Composer\TestCase; class InitCommandTest extends TestCase { - public function testParseValidAuthorString() { $command = new InitCommand; @@ -41,31 +40,31 @@ class InitCommandTest extends TestCase $this->assertEquals('h4x0r', $author['name']); $this->assertEquals('h4x@example.com', $author['email']); } - + /** * Test scenario for issue #5631 * @link https://github.com/composer/composer/issues/5631 Issue #5631 */ public function testParseValidAlias1AuthorString() { - $command = new InitCommand; - $author = $command->parseAuthorString( + $command = new InitCommand; + $author = $command->parseAuthorString( 'Johnathon "Johnny" Smith '); - $this->assertEquals('Johnathon "Johnny" Smith', $author['name'] ); - $this->assertEquals('john@example.com', $author['email']); + $this->assertEquals('Johnathon "Johnny" Smith', $author['name']); + $this->assertEquals('john@example.com', $author['email']); } - + /** * Test scenario for issue #5631 * @link https://github.com/composer/composer/issues/5631 Issue #5631 */ public function testParseValidAlias2AuthorString() { - $command = new InitCommand; - $author = $command->parseAuthorString( + $command = new InitCommand; + $author = $command->parseAuthorString( 'Johnathon (Johnny) Smith '); - $this->assertEquals('Johnathon (Johnny) Smith', $author['name'] ); - $this->assertEquals('john@example.com', $author['email']); + $this->assertEquals('Johnathon (Johnny) Smith', $author['name']); + $this->assertEquals('john@example.com', $author['email']); } public function testParseEmptyAuthorString() diff --git a/tests/Composer/Test/Command/RunScriptCommandTest.php b/tests/Composer/Test/Command/RunScriptCommandTest.php index 702d433eb..83ec63b76 100644 --- a/tests/Composer/Test/Command/RunScriptCommandTest.php +++ b/tests/Composer/Test/Command/RunScriptCommandTest.php @@ -19,7 +19,6 @@ use Composer\TestCase; class RunScriptCommandTest extends TestCase { - /** * @dataProvider getDevOptions * @param bool $dev @@ -79,7 +78,7 @@ class RunScriptCommandTest extends TestCase 'getSynopsis', 'initialize', 'isInteractive', - 'getComposer' + 'getComposer', )) ->getMock(); $command->expects($this->any())->method('getComposer')->willReturn($composer); @@ -101,7 +100,7 @@ class RunScriptCommandTest extends TestCase private function createComposerInstance() { $composer = new Composer; - $config = new Config; + $config = new Config; $composer->setConfig($config); return $composer; diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php index d7df18fc5..79c124fc5 100644 --- a/tests/Composer/Test/ConfigTest.php +++ b/tests/Composer/Test/ConfigTest.php @@ -261,7 +261,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase 'ssh://[user@]host.xz[:port]/path/to/repo.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)); } /** @@ -280,7 +282,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase '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)); } /** diff --git a/tests/Composer/Test/DependencyResolver/RuleSetTest.php b/tests/Composer/Test/DependencyResolver/RuleSetTest.php index 57fbc15e8..cecae613d 100644 --- a/tests/Composer/Test/DependencyResolver/RuleSetTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleSetTest.php @@ -57,7 +57,7 @@ class RuleSetTest extends TestCase new GenericRule(array(), Rule::RULE_JOB_INSTALL, null), new GenericRule(array(), Rule::RULE_JOB_INSTALL, null), new GenericRule(array(), Rule::RULE_JOB_INSTALL, null), - ) + ), ); $ruleSet = new RuleSet; diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index f2b080ef3..9067c4abd 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -850,14 +850,14 @@ class SolverTest extends TestCase foreach ($transaction as $operation) { if ('update' === $operation->getJobType()) { $result[] = array( - 'job' => 'update', + 'job' => 'update', 'from' => $operation->getInitialPackage(), - 'to' => $operation->getTargetPackage(), + 'to' => $operation->getTargetPackage(), ); } else { $job = ('uninstall' === $operation->getJobType() ? 'remove' : 'install'); $result[] = array( - 'job' => $job, + 'job' => $job, 'package' => $operation->getPackage(), ); } diff --git a/tests/Composer/Test/Downloader/DownloadManagerTest.php b/tests/Composer/Test/Downloader/DownloadManagerTest.php index 340717fbd..524b9b280 100644 --- a/tests/Composer/Test/Downloader/DownloadManagerTest.php +++ b/tests/Composer/Test/Downloader/DownloadManagerTest.php @@ -28,7 +28,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase public function testSetGetDownloader() { $downloader = $this->createDownloaderMock(); - $manager = new DownloadManager($this->io, false, $this->filesystem); + $manager = new DownloadManager($this->io, false, $this->filesystem); $manager->setDownloader('test', $downloader); $this->assertSame($downloader, $manager->getDownloader('test')); diff --git a/tests/Composer/Test/Downloader/GitDownloaderTest.php b/tests/Composer/Test/Downloader/GitDownloaderTest.php index ad3cd6666..e0081d990 100644 --- a/tests/Composer/Test/Downloader/GitDownloaderTest.php +++ b/tests/Composer/Test/Downloader/GitDownloaderTest.php @@ -45,7 +45,8 @@ class GitDownloaderTest extends TestCase $refl->setValue(null, null); } - protected function setupConfig($config = null) { + protected function setupConfig($config = null) + { if (!$config) { $config = new Config(); } @@ -53,6 +54,7 @@ class GitDownloaderTest extends TestCase $tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest-'.md5(uniqid('', true)); $config->merge(array('config' => array('home' => $tmpDir))); } + return $config; } @@ -100,8 +102,9 @@ class GitDownloaderTest extends TestCase $processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($this->winCompat('git --version'))) - ->will($this->returnCallback(function($command, &$output = null) { + ->will($this->returnCallback(function ($command, &$output = null) { $output = 'git version 1.0.0'; + return 0; })); @@ -150,8 +153,9 @@ class GitDownloaderTest extends TestCase $processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($this->winCompat('git --version'))) - ->will($this->returnCallback(function($command, &$output = null) { + ->will($this->returnCallback(function ($command, &$output = null) { $output = 'git version 2.3.1'; + return 0; })); @@ -215,8 +219,9 @@ class GitDownloaderTest extends TestCase $processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($this->winCompat('git --version'))) - ->will($this->returnCallback(function($command, &$output = null) { + ->will($this->returnCallback(function ($command, &$output = null) { $output = 'git version 1.0.0'; + return 0; })); @@ -298,8 +303,9 @@ class GitDownloaderTest extends TestCase $processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($this->winCompat('git --version'))) - ->will($this->returnCallback(function($command, &$output = null) { + ->will($this->returnCallback(function ($command, &$output = null) { $output = 'git version 1.0.0'; + return 0; })); @@ -343,8 +349,9 @@ class GitDownloaderTest extends TestCase $processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($this->winCompat('git --version'))) - ->will($this->returnCallback(function($command, &$output = null) { + ->will($this->returnCallback(function ($command, &$output = null) { $output = 'git version 1.0.0'; + return 0; })); $processExecutor->expects($this->at(1)) @@ -455,6 +462,7 @@ origin https://github.com/old/url (push) composer https://github.com/old/url (fetch) composer https://github.com/old/url (push) '; + return 0; })); $processExecutor->expects($this->at(3)) diff --git a/tests/Composer/Test/Downloader/PerforceDownloaderTest.php b/tests/Composer/Test/Downloader/PerforceDownloaderTest.php index 627db80e7..6ec44d3c3 100644 --- a/tests/Composer/Test/Downloader/PerforceDownloaderTest.php +++ b/tests/Composer/Test/Downloader/PerforceDownloaderTest.php @@ -36,23 +36,23 @@ class PerforceDownloaderTest extends TestCase protected function setUp() { - $this->testPath = $this->getUniqueTmpDirectory(); - $this->repoConfig = $this->getRepoConfig(); - $this->config = $this->getConfig(); - $this->io = $this->getMockIoInterface(); + $this->testPath = $this->getUniqueTmpDirectory(); + $this->repoConfig = $this->getRepoConfig(); + $this->config = $this->getConfig(); + $this->io = $this->getMockIoInterface(); $this->processExecutor = $this->getMockProcessExecutor(); - $this->repository = $this->getMockRepository($this->repoConfig, $this->io, $this->config); - $this->package = $this->getMockPackageInterface($this->repository); - $this->downloader = new PerforceDownloader($this->io, $this->config, $this->processExecutor); + $this->repository = $this->getMockRepository($this->repoConfig, $this->io, $this->config); + $this->package = $this->getMockPackageInterface($this->repository); + $this->downloader = new PerforceDownloader($this->io, $this->config, $this->processExecutor); } protected function tearDown() { $this->downloader = null; - $this->package = null; + $this->package = null; $this->repository = null; - $this->io = null; - $this->config = null; + $this->io = null; + $this->config = null; $this->repoConfig = null; if (is_dir($this->testPath)) { $fs = new Filesystem; diff --git a/tests/Composer/Test/Installer/InstallationManagerTest.php b/tests/Composer/Test/Installer/InstallationManagerTest.php index f165ca792..58e772041 100644 --- a/tests/Composer/Test/Installer/InstallationManagerTest.php +++ b/tests/Composer/Test/Installer/InstallationManagerTest.php @@ -35,7 +35,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase return $arg === 'vendor'; })); - $manager = new InstallationManager(); + $manager = new InstallationManager(); $manager->addInstaller($installer); $this->assertSame($installer, $manager->getInstaller('vendor')); @@ -64,7 +64,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase return $arg === 'vendor'; })); - $manager = new InstallationManager(); + $manager = new InstallationManager(); $manager->addInstaller($installer); $this->assertSame($installer, $manager->getInstaller('vendor')); @@ -81,8 +81,8 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase ->getMock(); $installOperation = new InstallOperation($this->createPackageMock()); - $removeOperation = new UninstallOperation($this->createPackageMock()); - $updateOperation = new UpdateOperation( + $removeOperation = new UninstallOperation($this->createPackageMock()); + $updateOperation = new UpdateOperation( $this->createPackageMock(), $this->createPackageMock() ); @@ -107,10 +107,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase public function testInstall() { $installer = $this->createInstallerMock(); - $manager = new InstallationManager(); + $manager = new InstallationManager(); $manager->addInstaller($installer); - $package = $this->createPackageMock(); + $package = $this->createPackageMock(); $operation = new InstallOperation($package, 'test'); $package @@ -135,11 +135,11 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase public function testUpdateWithEqualTypes() { $installer = $this->createInstallerMock(); - $manager = new InstallationManager(); + $manager = new InstallationManager(); $manager->addInstaller($installer); - $initial = $this->createPackageMock(); - $target = $this->createPackageMock(); + $initial = $this->createPackageMock(); + $target = $this->createPackageMock(); $operation = new UpdateOperation($initial, $target, 'test'); $initial @@ -169,12 +169,12 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase { $libInstaller = $this->createInstallerMock(); $bundleInstaller = $this->createInstallerMock(); - $manager = new InstallationManager(); + $manager = new InstallationManager(); $manager->addInstaller($libInstaller); $manager->addInstaller($bundleInstaller); - $initial = $this->createPackageMock(); - $target = $this->createPackageMock(); + $initial = $this->createPackageMock(); + $target = $this->createPackageMock(); $operation = new UpdateOperation($initial, $target, 'test'); $initial @@ -215,10 +215,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase public function testUninstall() { $installer = $this->createInstallerMock(); - $manager = new InstallationManager(); + $manager = new InstallationManager(); $manager->addInstaller($installer); - $package = $this->createPackageMock(); + $package = $this->createPackageMock(); $operation = new UninstallOperation($package, 'test'); $package @@ -245,10 +245,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase $installer = $this->getMockBuilder('Composer\Installer\LibraryInstaller') ->disableOriginalConstructor() ->getMock(); - $manager = new InstallationManager(); + $manager = new InstallationManager(); $manager->addInstaller($installer); - $package = $this->createPackageMock(); + $package = $this->createPackageMock(); $package ->expects($this->once()) diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index ce55fb1d9..7ab76402d 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php @@ -140,7 +140,7 @@ class LibraryInstallerTest extends TestCase ->with($this->vendorDir.'/package1/oldtarget', $this->vendorDir.'/package1/newtarget'); $initial = $this->createPackageMock(); - $target = $this->createPackageMock(); + $target = $this->createPackageMock(); $initial ->expects($this->any()) diff --git a/tests/Composer/Test/Installer/MetapackageInstallerTest.php b/tests/Composer/Test/Installer/MetapackageInstallerTest.php index 204e05265..12de6b4bf 100644 --- a/tests/Composer/Test/Installer/MetapackageInstallerTest.php +++ b/tests/Composer/Test/Installer/MetapackageInstallerTest.php @@ -44,7 +44,7 @@ class MetapackageInstallerTest extends \PHPUnit_Framework_TestCase public function testUpdate() { $initial = $this->createPackageMock(); - $target = $this->createPackageMock(); + $target = $this->createPackageMock(); $this->repository ->expects($this->exactly(2)) diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 985ba64c2..adac21714 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -82,8 +82,8 @@ class InstallerTest extends TestCase $result = $installer->run(); $this->assertSame(0, $result); - $expectedInstalled = isset($options['install']) ? $options['install'] : array(); - $expectedUpdated = isset($options['update']) ? $options['update'] : array(); + $expectedInstalled = isset($options['install']) ? $options['install'] : array(); + $expectedUpdated = isset($options['update']) ? $options['update'] : array(); $expectedUninstalled = isset($options['uninstall']) ? $options['uninstall'] : array(); $installed = $installationManager->getInstalledPackages(); @@ -198,7 +198,7 @@ class InstallerTest extends TestCase } $contents = json_encode($composerConfig); - $locker = new Locker($io, $lockJsonMock, $repositoryManager, $composer->getInstallationManager(), $contents); + $locker = new Locker($io, $lockJsonMock, $repositoryManager, $composer->getInstallationManager(), $contents); $composer->setLocker($locker); $eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(); @@ -345,7 +345,7 @@ class InstallerTest extends TestCase 'CONDITION' => false, 'COMPOSER' => true, 'LOCK' => false, - 'INSTALLED' => false, + 'INSTALLED' => false, 'RUN' => true, 'EXPECT-LOCK' => false, 'EXPECT-OUTPUT' => false, diff --git a/tests/Composer/Test/Json/JsonManipulatorTest.php b/tests/Composer/Test/Json/JsonManipulatorTest.php index 893350a3f..12080da2e 100644 --- a/tests/Composer/Test/Json/JsonManipulatorTest.php +++ b/tests/Composer/Test/Json/JsonManipulatorTest.php @@ -2266,7 +2266,6 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase $this->assertEquals('{ } ', $manipulator->getContents()); - } public function testIndentDetection() diff --git a/tests/Composer/Test/Mock/FactoryMock.php b/tests/Composer/Test/Mock/FactoryMock.php index bde22d41f..a6f88b9cb 100644 --- a/tests/Composer/Test/Mock/FactoryMock.php +++ b/tests/Composer/Test/Mock/FactoryMock.php @@ -1,4 +1,5 @@ output = Factory::createOutput(); parent::__construct($this->output); - $loaded = null === $loaded ? true: $loaded; + $loaded = null === $loaded ? true : $loaded; $class = new \ReflectionClass(get_parent_class($this)); $prop = $class->getProperty('loaded'); diff --git a/tests/Composer/Test/Package/Archiver/ArchiverTest.php b/tests/Composer/Test/Package/Archiver/ArchiverTest.php index 32a6ed749..1d08e8873 100644 --- a/tests/Composer/Test/Package/Archiver/ArchiverTest.php +++ b/tests/Composer/Test/Package/Archiver/ArchiverTest.php @@ -37,8 +37,8 @@ abstract class ArchiverTest extends TestCase public function setUp() { $this->filesystem = new Filesystem(); - $this->process = new ProcessExecutor(); - $this->testDir = $this->getUniqueTmpDirectory(); + $this->process = new ProcessExecutor(); + $this->testDir = $this->getUniqueTmpDirectory(); } public function tearDown() diff --git a/tests/Composer/Test/Package/Archiver/PharArchiverTest.php b/tests/Composer/Test/Package/Archiver/PharArchiverTest.php index 16753784d..668e101e3 100644 --- a/tests/Composer/Test/Package/Archiver/PharArchiverTest.php +++ b/tests/Composer/Test/Package/Archiver/PharArchiverTest.php @@ -21,7 +21,7 @@ class PharArchiverTest extends ArchiverTest // Set up repository $this->setupDummyRepo(); $package = $this->setupPackage(); - $target = $this->getUniqueTmpDirectory().'/composer_archiver_test.tar'; + $target = $this->getUniqueTmpDirectory().'/composer_archiver_test.tar'; // Test archive $archiver = new PharArchiver(); @@ -36,7 +36,7 @@ class PharArchiverTest extends ArchiverTest // Set up repository $this->setupDummyRepo(); $package = $this->setupPackage(); - $target = $this->getUniqueTmpDirectory().'/composer_archiver_test.zip'; + $target = $this->getUniqueTmpDirectory().'/composer_archiver_test.zip'; // Test archive $archiver = new PharArchiver(); diff --git a/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php b/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php index 3a498b674..c76843c39 100644 --- a/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php +++ b/tests/Composer/Test/Package/Archiver/ZipArchiverTest.php @@ -25,7 +25,7 @@ class ZipArchiverTest extends ArchiverTest // Set up repository $this->setupDummyRepo(); $package = $this->setupPackage(); - $target = sys_get_temp_dir().'/composer_archiver_test.zip'; + $target = sys_get_temp_dir().'/composer_archiver_test.zip'; // Test archive $archiver = new ZipArchiver(); diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index a2ce20d12..4093f4381 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -136,6 +136,7 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase { $expectedConfig = $config; unset($expectedConfig['transport-options']); + return $expectedConfig; } diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index e7f91bb98..de55e8b5e 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -19,7 +19,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase { public function testIsLocked() { - $json = $this->createJsonFileMock(); + $json = $this->createJsonFileMock(); $locker = new Locker(new NullIO, $json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), $this->getJsonContent()); diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index 6e98b192a..57ba7f13f 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -243,7 +243,7 @@ class PluginInstallerTest extends TestCase ->expects($this->any()) ->method('getPackages') ->will($this->returnCallback(function () use ($plugApiInternalPackage, $plugins) { - return array_merge(array($plugApiInternalPackage), $plugins); + return array_merge(array($plugApiInternalPackage), $plugins); })); $this->pm->loadInstalledPlugins(); diff --git a/tests/Composer/Test/Repository/ComposerRepositoryTest.php b/tests/Composer/Test/Repository/ComposerRepositoryTest.php index 11adf3d6e..4017bfe51 100644 --- a/tests/Composer/Test/Repository/ComposerRepositoryTest.php +++ b/tests/Composer/Test/Repository/ComposerRepositoryTest.php @@ -89,7 +89,7 @@ class ComposerRepositoryTest extends TestCase ), array('packages' => array( 'bar/foo' => array( - '3.14' => array('name' => 'bar/foo', 'version' => '3.14'), + '3.14' => array('name' => 'bar/foo', 'version' => '3.14'), '3.145' => array('name' => 'bar/foo', 'version' => '3.145'), ), )), @@ -178,9 +178,9 @@ class ComposerRepositoryTest extends TestCase 'results' => array( array( 'name' => 'foo', - 'description' => null - ) - ) + 'description' => null, + ), + ), ); $rfs = $this->getMockBuilder('Composer\Util\RemoteFilesystem') diff --git a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php index 58e17ab9b..668cd2b84 100644 --- a/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php @@ -58,7 +58,7 @@ class GitBitbucketDriverTest extends TestCase } /** - * @param array $repoConfig + * @param array $repoConfig * @return GitBitbucketDriver */ private function getDriver(array $repoConfig) @@ -109,32 +109,32 @@ class GitBitbucketDriverTest extends TestCase array( $this->originUrl, 'https://api.bitbucket.org/2.0/repositories/user/repo?fields=-project%2C-owner', - false + false, ), array( $this->originUrl, 'https://api.bitbucket.org/1.0/repositories/user/repo/main-branch', - false + false, ), array( $this->originUrl, 'https://api.bitbucket.org/2.0/repositories/user/repo/refs/tags?pagelen=100&fields=values.name%2Cvalues.target.hash%2Cnext&sort=-target.date', - false + false, ), array( $this->originUrl, 'https://api.bitbucket.org/2.0/repositories/user/repo/refs/branches?pagelen=100&fields=values.name%2Cvalues.target.hash%2Cnext&sort=-target.date', - false + false, ), array( $this->originUrl, 'https://api.bitbucket.org/1.0/repositories/user/repo/raw/master/composer.json', - false + false, ), array( $this->originUrl, 'https://api.bitbucket.org/2.0/repositories/user/repo/commit/master?fields=date', - false + false, ) ) ->willReturnOnConsecutiveCalls( @@ -154,14 +154,14 @@ class GitBitbucketDriverTest extends TestCase $this->assertEquals( array( '1.0.1' => '9b78a3932143497c519e49b8241083838c8ff8a1', - '1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb' + '1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb', ), $driver->getTags() ); $this->assertEquals( array( - 'master' => '937992d19d72b5116c3e8c4a04f960e5fa270b22' + 'master' => '937992d19d72b5116c3e8c4a04f960e5fa270b22', ), $driver->getBranches() ); @@ -174,20 +174,20 @@ class GitBitbucketDriverTest extends TestCase 'authors' => array( array( 'name' => 'Name', - 'email' => 'local@domain.tld' - ) + 'email' => 'local@domain.tld', + ), ), 'require' => array( - 'creator/package' => '^1.0' + 'creator/package' => '^1.0', ), 'require-dev' => array( - 'phpunit/phpunit' => '~4.8' + 'phpunit/phpunit' => '~4.8', ), 'time' => '2016-05-17 13:19:52', 'support' => array( - 'source' => 'https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=master' + 'source' => 'https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=master', ), - 'homepage' => 'https://bitbucket.org/user/repo' + 'homepage' => 'https://bitbucket.org/user/repo', ), $driver->getComposerInformation('master') ); @@ -210,7 +210,7 @@ class GitBitbucketDriverTest extends TestCase 'type' => 'zip', 'url' => 'https://bitbucket.org/user/repo/get/reference.zip', 'reference' => 'reference', - 'shasum' => '' + 'shasum' => '', ), $driver->getDist('reference') ); diff --git a/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php b/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php index e377bf523..ed43972bd 100644 --- a/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php @@ -87,7 +87,7 @@ JSON; ->shouldBeCalledTimes(1) ; - $driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal()); + $driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal()); $driver->initialize(); $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); @@ -126,7 +126,7 @@ JSON; ->shouldBeCalledTimes(1) ; - $driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal()); + $driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal()); $driver->initialize(); $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); @@ -257,7 +257,7 @@ JSON; $expected = array( 'mymaster' => '97eda36b5c1dd953a3792865c222d4e85e5f302e', - 'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd', + 'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd', ); $this->assertEquals($expected, $driver->getBranches()); @@ -315,7 +315,7 @@ JSON; ->shouldBeCalledTimes(1) ; - $driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal()); + $driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal()); $driver->initialize(); $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); diff --git a/tests/Composer/Test/Repository/Vcs/HgDriverTest.php b/tests/Composer/Test/Repository/Vcs/HgDriverTest.php index da326aaf5..8f496da9c 100644 --- a/tests/Composer/Test/Repository/Vcs/HgDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/HgDriverTest.php @@ -19,7 +19,6 @@ use Composer\Config; class HgDriverTest extends TestCase { - /** @type \Composer\IO\IOInterface|\PHPUnit_Framework_MockObject_MockObject */ private $io; /** @type Config */ @@ -65,5 +64,4 @@ class HgDriverTest extends TestCase array('https://user@bitbucket.org/user/repo'), ); } - } diff --git a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php index 05adbf030..02b97501c 100644 --- a/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php @@ -32,19 +32,19 @@ class PerforceDriverTest extends TestCase protected $repoConfig; protected $perforce; - const TEST_URL = 'TEST_PERFORCE_URL'; - const TEST_DEPOT = 'TEST_DEPOT_CONFIG'; + const TEST_URL = 'TEST_PERFORCE_URL'; + const TEST_DEPOT = 'TEST_DEPOT_CONFIG'; const TEST_BRANCH = 'TEST_BRANCH_CONFIG'; protected function setUp() { - $this->testPath = $this->getUniqueTmpDirectory(); - $this->config = $this->getTestConfig($this->testPath); - $this->repoConfig = $this->getTestRepoConfig(); - $this->io = $this->getMockIOInterface(); - $this->process = $this->getMockProcessExecutor(); + $this->testPath = $this->getUniqueTmpDirectory(); + $this->config = $this->getTestConfig($this->testPath); + $this->repoConfig = $this->getTestRepoConfig(); + $this->io = $this->getMockIOInterface(); + $this->process = $this->getMockProcessExecutor(); $this->remoteFileSystem = $this->getMockRemoteFilesystem(); - $this->perforce = $this->getMockPerforce(); + $this->perforce = $this->getMockPerforce(); $this->driver = new PerforceDriver($this->repoConfig, $this->io, $this->config, $this->process, $this->remoteFileSystem); $this->overrideDriverInternalPerforce($this->perforce); } @@ -54,14 +54,14 @@ class PerforceDriverTest extends TestCase //cleanup directory under test path $fs = new Filesystem; $fs->removeDirectory($this->testPath); - $this->driver = null; - $this->perforce = null; + $this->driver = null; + $this->perforce = null; $this->remoteFileSystem = null; - $this->process = null; - $this->io = null; - $this->repoConfig = null; - $this->config = null; - $this->testPath = null; + $this->process = null; + $this->io = null; + $this->repoConfig = null; + $this->config = null; + $this->testPath = null; } protected function overrideDriverInternalPerforce(Perforce $perforce) @@ -83,8 +83,8 @@ class PerforceDriverTest extends TestCase protected function getTestRepoConfig() { return array( - 'url' => self::TEST_URL, - 'depot' => self::TEST_DEPOT, + 'url' => self::TEST_URL, + 'depot' => self::TEST_DEPOT, 'branch' => self::TEST_BRANCH, ); } diff --git a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php index 7cd90b6aa..a3a9855db 100644 --- a/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php +++ b/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php @@ -47,7 +47,7 @@ class SvnDriverTest extends TestCase { $console = $this->getMock('Composer\IO\IOInterface'); - $output = "svn: OPTIONS of 'https://corp.svn.local/repo':"; + $output = "svn: OPTIONS of 'https://corp.svn.local/repo':"; $output .= " authorization failed: Could not authenticate to server:"; $output .= " rejected Basic challenge (https://corp.svn.local/)"; diff --git a/tests/Composer/Test/Util/BitbucketTest.php b/tests/Composer/Test/Util/BitbucketTest.php index 62bae0633..4d4094b65 100644 --- a/tests/Composer/Test/Util/BitbucketTest.php +++ b/tests/Composer/Test/Util/BitbucketTest.php @@ -76,7 +76,7 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase 'http' => array( 'method' => 'POST', 'content' => 'grant_type=client_credentials', - ) + ), ) ) ->willReturn( @@ -110,8 +110,8 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase 'access-token' => $this->token, 'access-token-expiration' => $this->time + 1800, 'consumer-key' => $this->consumer_key, - 'consumer-secret' => $this->consumer_secret - ) + 'consumer-secret' => $this->consumer_secret, + ), ) ); @@ -132,8 +132,8 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase 'access-token' => 'randomExpiredToken', 'access-token-expiration' => $this->time - 400, 'consumer-key' => $this->consumer_key, - 'consumer-secret' => $this->consumer_secret - ) + 'consumer-secret' => $this->consumer_secret, + ), ) ); @@ -152,7 +152,7 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase 'http' => array( 'method' => 'POST', 'content' => 'grant_type=client_credentials', - ) + ), ) ) ->willReturn( @@ -196,7 +196,7 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase 'http' => array( 'method' => 'POST', 'content' => 'grant_type=client_credentials', - ) + ), ) ) ->willThrowException( @@ -279,7 +279,7 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase "consumer-key" => $this->consumer_key, "consumer-secret" => $this->consumer_secret, "access-token" => $this->token, - "access-token-expiration" => $this->time + 3600 + "access-token-expiration" => $this->time + 3600, ) ); diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index 4e60b0ce9..7b54d8762 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -229,7 +229,7 @@ class FilesystemTest extends TestCase */ public function testUnlinkSymlinkedDirectory() { - $basepath = $this->workingDir; + $basepath = $this->workingDir; $symlinked = $basepath . "/linked"; @mkdir($basepath . "/real", 0777, true); touch($basepath . "/real/FILE"); @@ -244,7 +244,7 @@ class FilesystemTest extends TestCase $this->fail('Precondition assertion failed (is_dir is false on symbolic link to directory).'); } - $fs = new Filesystem(); + $fs = new Filesystem(); $result = $fs->unlink($symlinked); $this->assertTrue($result); $this->assertFalse(file_exists($symlinked)); @@ -258,7 +258,7 @@ class FilesystemTest extends TestCase { @mkdir($this->workingDir . "/real", 0777, true); touch($this->workingDir . "/real/FILE"); - $symlinked = $this->workingDir . "/linked"; + $symlinked = $this->workingDir . "/linked"; $symlinkedTrailingSlash = $symlinked . "/"; $result = @symlink($this->workingDir . "/real", $symlinked); diff --git a/tests/Composer/Test/Util/PerforceTest.php b/tests/Composer/Test/Util/PerforceTest.php index f4d12d1be..6798fd121 100644 --- a/tests/Composer/Test/Util/PerforceTest.php +++ b/tests/Composer/Test/Util/PerforceTest.php @@ -24,12 +24,12 @@ class PerforceTest extends \PHPUnit_Framework_TestCase protected $processExecutor; protected $io; - const TEST_DEPOT = 'depot'; - const TEST_BRANCH = 'branch'; - const TEST_P4USER = 'user'; + const TEST_DEPOT = 'depot'; + const TEST_BRANCH = 'branch'; + const TEST_P4USER = 'user'; const TEST_CLIENT_NAME = 'TEST'; - const TEST_PORT = 'port'; - const TEST_PATH = 'path'; + const TEST_PORT = 'port'; + const TEST_PATH = 'path'; protected function setUp() { @@ -41,18 +41,18 @@ class PerforceTest extends \PHPUnit_Framework_TestCase protected function tearDown() { - $this->perforce = null; - $this->io = null; - $this->repoConfig = null; + $this->perforce = null; + $this->io = null; + $this->repoConfig = null; $this->processExecutor = null; } public function getTestRepoConfig() { return array( - 'depot' => self::TEST_DEPOT, - 'branch' => self::TEST_BRANCH, - 'p4user' => self::TEST_P4USER, + 'depot' => self::TEST_DEPOT, + 'branch' => self::TEST_BRANCH, + 'p4user' => self::TEST_P4USER, 'unique_perforce_client_name' => self::TEST_CLIENT_NAME, ); } @@ -140,10 +140,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $this->perforce->setUser(null); $expectedCommand = 'p4 set'; $callback = function ($command, &$output) { - $output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL; + $output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL; - return true; - }; + return true; + }; $this->processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($expectedCommand)) @@ -158,10 +158,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $this->perforce->setUser(null); $expectedCommand = 'echo $P4USER'; $callback = function ($command, &$output) { - $output = 'TEST_P4VARIABLE_USER' . PHP_EOL; + $output = 'TEST_P4VARIABLE_USER' . PHP_EOL; - return true; - }; + return true; + }; $this->processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($expectedCommand)) @@ -187,7 +187,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $this->createNewPerforceWithWindowsFlag(true); $this->perforce->setUser(null); $expectedQuestion = 'Enter P4 User:'; - $expectedCommand = 'p4 set P4USER=TEST_QUERY_USER'; + $expectedCommand = 'p4 set P4USER=TEST_QUERY_USER'; $this->io->expects($this->at(0)) ->method('ask') ->with($this->equalTo($expectedQuestion)) @@ -204,7 +204,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $this->createNewPerforceWithWindowsFlag(false); $this->perforce->setUser(null); $expectedQuestion = 'Enter P4 User:'; - $expectedCommand = 'export P4USER=TEST_QUERY_USER'; + $expectedCommand = 'export P4USER=TEST_QUERY_USER'; $this->io->expects($this->at(0)) ->method('ask') ->with($this->equalTo($expectedQuestion)) @@ -219,9 +219,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase public function testQueryP4PasswordWithPasswordAlreadySet() { $repoConfig = array( - 'depot' => 'depot', - 'branch' => 'branch', - 'p4user' => 'user', + 'depot' => 'depot', + 'branch' => 'branch', + 'p4user' => 'user', 'p4password' => 'TEST_PASSWORD', ); $this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, $this->getMockIOInterface(), 'TEST'); @@ -234,10 +234,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $this->createNewPerforceWithWindowsFlag(true); $expectedCommand = 'p4 set'; $callback = function ($command, &$output) { - $output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL; + $output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL; - return true; - }; + return true; + }; $this->processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($expectedCommand)) @@ -251,10 +251,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $this->createNewPerforceWithWindowsFlag(false); $expectedCommand = 'echo $P4PASSWD'; $callback = function ($command, &$output) { - $output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL; + $output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL; - return true; - }; + return true; + }; $this->processExecutor->expects($this->at(0)) ->method('execute') ->with($this->equalTo($expectedCommand)) @@ -358,10 +358,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase ); $expectedCommand2 = 'p4 -u user -p port changes //depot/branch/...'; $expectedCallback = function ($command, &$output) { - $output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\''; + $output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\''; - return true; - }; + return true; + }; $this->processExecutor->expects($this->at(1)) ->method('execute') ->with($this->equalTo($expectedCommand2)) @@ -375,10 +375,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase { $expectedCommand = 'p4 -u user -p port changes //depot/...'; $expectedCallback = function ($command, &$output) { - $output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\''; + $output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\''; - return true; - }; + return true; + }; $this->processExecutor->expects($this->once()) ->method('execute') ->with($this->equalTo($expectedCommand)) @@ -473,10 +473,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $result = $this->perforce->getComposerInformation('//depot'); $expected = array( - 'name' => 'test/perforce', - 'description' => 'Basic project for testing', + 'name' => 'test/perforce', + 'description' => 'Basic project for testing', 'minimum-stability' => 'dev', - 'autoload' => array('psr-0' => array()), + 'autoload' => array('psr-0' => array()), ); $this->assertEquals($expected, $result); } @@ -514,10 +514,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $result = $this->perforce->getComposerInformation('//depot@0.0.1'); $expected = array( - 'name' => 'test/perforce', - 'description' => 'Basic project for testing', + 'name' => 'test/perforce', + 'description' => 'Basic project for testing', 'minimum-stability' => 'dev', - 'autoload' => array('psr-0' => array()), + 'autoload' => array('psr-0' => array()), ); $this->assertEquals($expected, $result); } @@ -543,10 +543,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $result = $this->perforce->getComposerInformation('//depot/branch'); $expected = array( - 'name' => 'test/perforce', - 'description' => 'Basic project for testing', + 'name' => 'test/perforce', + 'description' => 'Basic project for testing', 'minimum-stability' => 'dev', - 'autoload' => array('psr-0' => array()), + 'autoload' => array('psr-0' => array()), ); $this->assertEquals($expected, $result); } @@ -585,10 +585,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase $result = $this->perforce->getComposerInformation('//depot/branch@0.0.1'); $expected = array( - 'name' => 'test/perforce', - 'description' => 'Basic project for testing', + 'name' => 'test/perforce', + 'description' => 'Basic project for testing', 'minimum-stability' => 'dev', - 'autoload' => array('psr-0' => array()), + 'autoload' => array('psr-0' => array()), ); $this->assertEquals($expected, $result); } diff --git a/tests/Composer/Test/Util/PlatformTest.php b/tests/Composer/Test/Util/PlatformTest.php index 129410d95..ed835db39 100644 --- a/tests/Composer/Test/Util/PlatformTest.php +++ b/tests/Composer/Test/Util/PlatformTest.php @@ -28,7 +28,7 @@ class PlatformTest extends \PHPUnit_Framework_TestCase $this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath')); $this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test')); } - + public function testIsWindows() { // Compare 2 common tests for Windows to the built-in Windows test diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index b776c433d..b2276bc01 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -257,10 +257,9 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase ->willReturn(array( 'username' => 'x-token-auth', // This token is fake, but it matches a valid token's pattern. - 'password' => '1A0yeK5Po3ZEeiiRiMWLivS0jirLdoGuaSGq9NvESFx1Fsdn493wUDXC8rz_1iKVRTl1GINHEUCsDxGh5lZ=' + 'password' => '1A0yeK5Po3ZEeiiRiMWLivS0jirLdoGuaSGq9NvESFx1Fsdn493wUDXC8rz_1iKVRTl1GINHEUCsDxGh5lZ=', )); - $rfs = new RemoteFilesystem($io, $config); $hostname = parse_url($url, PHP_URL_HOST); diff --git a/tests/Composer/Test/Util/SilencerTest.php b/tests/Composer/Test/Util/SilencerTest.php index 5201522f8..69e2afe34 100644 --- a/tests/Composer/Test/Util/SilencerTest.php +++ b/tests/Composer/Test/Util/SilencerTest.php @@ -1,4 +1,5 @@ array('method' => 'GET', 'max_redirects' => 20, 'follow_location' => 1, 'header' => array('User-Agent: foo'))), array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo')), - array('options' => $a, 'notification' => $f = function () {}), array('notification' => $f), + array('options' => $a, 'notification' => $f = function () { + }), array('notification' => $f), ), ); }