1
0
Fork 0
pull/6236/head
Jordi Boggiano 2017-03-08 15:07:29 +01:00
parent 7211eedc36
commit 122e422682
98 changed files with 503 additions and 413 deletions

12
.php_cs
View File

@ -29,18 +29,17 @@ return PhpCsFixer\Config::create()
'cast_spaces' => true, 'cast_spaces' => true,
'header_comment' => array('header' => $header), 'header_comment' => array('header' => $header),
'include' => true, 'include' => true,
'long_array_syntax' => true, 'array_syntax' => array('syntax' => 'long'),
'method_separation' => true, 'method_separation' => true,
'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true, 'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_between_uses' => true, 'no_empty_statement' => true,
'no_duplicate_semicolons' => true,
'no_extra_consecutive_blank_lines' => true, 'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true, 'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true, 'no_leading_namespace_whitespace' => true,
'no_trailing_comma_in_singleline_array' => true, 'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true, 'no_unused_imports' => true,
'no_whitespace_in_blank_lines' => true, 'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true, 'object_operator_without_whitespace' => true,
'phpdoc_align' => true, 'phpdoc_align' => true,
'phpdoc_indent' => true, 'phpdoc_indent' => true,
@ -49,12 +48,13 @@ return PhpCsFixer\Config::create()
'phpdoc_order' => true, 'phpdoc_order' => true,
'phpdoc_scalar' => true, 'phpdoc_scalar' => true,
'phpdoc_trim' => true, 'phpdoc_trim' => true,
'phpdoc_type_to_var' => true, 'phpdoc_types' => true,
'psr0' => true, 'psr0' => true,
'single_blank_line_before_namespace' => true, 'single_blank_line_before_namespace' => true,
'short_scalar_cast' => true,
'standardize_not_equals' => true, 'standardize_not_equals' => true,
'ternary_operator_spaces' => true, 'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true, 'trailing_comma_in_multiline_array' => true,
)) ))
->finder($finder) ->setFinder($finder)
; ;

View File

@ -66,7 +66,7 @@ class AutoloadGenerator
public function setDevMode($devMode = true) public function setDevMode($devMode = true)
{ {
$this->devMode = (boolean) $devMode; $this->devMode = (bool) $devMode;
} }
/** /**
@ -77,7 +77,7 @@ class AutoloadGenerator
*/ */
public function setClassMapAuthoritative($classMapAuthoritative) public function setClassMapAuthoritative($classMapAuthoritative)
{ {
$this->classMapAuthoritative = (boolean) $classMapAuthoritative; $this->classMapAuthoritative = (bool) $classMapAuthoritative;
} }
/** /**
@ -87,7 +87,7 @@ class AutoloadGenerator
*/ */
public function setApcu($apcu) public function setApcu($apcu)
{ {
$this->apcu = (boolean) $apcu; $this->apcu = (bool) $apcu;
} }
/** /**
@ -97,7 +97,7 @@ class AutoloadGenerator
*/ */
public function setRunScripts($runScripts = true) 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 = '') 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) protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
{ {
$lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode)-1]; $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
if ("'" === $lastChar || '"' === $lastChar) { if ("'" === $lastChar || '"' === $lastChar) {
$vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar; $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
} else { } else {

View File

@ -46,6 +46,7 @@ class Cache
if (preg_match('{(^|[\\\\/])(\$null|NUL|/dev/null)([\\\\/]|$)}', $cacheDir)) { if (preg_match('{(^|[\\\\/])(\$null|NUL|/dev/null)([\\\\/]|$)}', $cacheDir)) {
$this->enabled = false; $this->enabled = false;
return; return;
} }

View File

@ -45,7 +45,7 @@ class ArchiveCommand extends BaseCommand
new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'), 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.' new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
.' Note that the format will be appended.'), .' 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(<<<EOT ->setHelp(<<<EOT
The <info>archive</info> command creates an archive of the specified format The <info>archive</info> command creates an archive of the specified format
@ -139,7 +139,9 @@ EOT
if (count($packages) > 1) { if (count($packages) > 1) {
$package = reset($packages); $package = reset($packages);
$io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>'); $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
$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('<comment>Please use a more specific constraint to pick a different package.</comment>'); $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
} elseif ($packages) { } elseif ($packages) {
$package = reset($packages); $package = reset($packages);

View File

@ -286,19 +286,29 @@ EOT
$values = $input->getArgument('setting-value'); // what the user is trying to add/change $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); }; $booleanValidator = function ($val) {
$booleanNormalizer = function ($val) { return $val !== 'false' && (bool) $val; }; return in_array($val, array('true', 'false', '1', '0'), true);
};
$booleanNormalizer = function ($val) {
return $val !== 'false' && (bool) $val;
};
// handle config values // handle config values
$uniqueConfigValues = array( $uniqueConfigValues = array(
'process-timeout' => array('is_numeric', 'intval'), 'process-timeout' => array('is_numeric', 'intval'),
'use-include-path' => array($booleanValidator, $booleanNormalizer), 'use-include-path' => array($booleanValidator, $booleanNormalizer),
'preferred-install' => array( 'preferred-install' => array(
function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); }, function ($val) {
function ($val) { return $val; }, return in_array($val, array('auto', 'source', 'dist'), true);
},
function ($val) {
return $val;
},
), ),
'store-auths' => array( '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) { function ($val) {
if ('prompt' === $val) { if ('prompt' === $val) {
return 'prompt'; return 'prompt';
@ -308,27 +318,55 @@ EOT
}, },
), ),
'notify-on-install' => array($booleanValidator, $booleanNormalizer), 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
'vendor-dir' => array('is_string', function ($val) { return $val; }), 'vendor-dir' => array('is_string', function ($val) {
'bin-dir' => array('is_string', function ($val) { return $val; }), return $val;
'archive-dir' => array('is_string', function ($val) { return $val; }), }),
'archive-format' => array('is_string', function ($val) { return $val; }), 'bin-dir' => array('is_string', function ($val) {
'data-dir' => array('is_string', function ($val) { return $val; }), return $val;
'cache-dir' => array('is_string', function ($val) { return $val; }), }),
'cache-files-dir' => array('is_string', function ($val) { return $val; }), 'archive-dir' => array('is_string', function ($val) {
'cache-repo-dir' => array('is_string', function ($val) { return $val; }), return $val;
'cache-vcs-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-ttl' => array('is_numeric', 'intval'),
'cache-files-ttl' => array('is_numeric', 'intval'), 'cache-files-ttl' => array('is_numeric', 'intval'),
'cache-files-maxsize' => array( 'cache-files-maxsize' => array(
function ($val) { return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0; }, function ($val) {
function ($val) { return $val; }, return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0;
},
function ($val) {
return $val;
},
), ),
'bin-compat' => array( 'bin-compat' => array(
function ($val) { return in_array($val, array('auto', 'full')); }, function ($val) {
function ($val) { return $val; }, return in_array($val, array('auto', 'full'));
},
function ($val) {
return $val;
},
), ),
'discard-changes' => array( '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) { function ($val) {
if ('stash' === $val) { if ('stash' === $val) {
return 'stash'; return 'stash';
@ -337,7 +375,9 @@ EOT
return $val !== 'false' && (bool) $val; 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), 'sort-packages' => array($booleanValidator, $booleanNormalizer),
'optimize-autoloader' => array($booleanValidator, $booleanNormalizer), 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
'classmap-authoritative' => array($booleanValidator, $booleanNormalizer), 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
@ -346,12 +386,20 @@ EOT
'disable-tls' => array($booleanValidator, $booleanNormalizer), 'disable-tls' => array($booleanValidator, $booleanNormalizer),
'secure-http' => array($booleanValidator, $booleanNormalizer), 'secure-http' => array($booleanValidator, $booleanNormalizer),
'cafile' => array( 'cafile' => array(
function ($val) { return file_exists($val) && is_readable($val); }, function ($val) {
function ($val) { return $val === 'null' ? null : $val; }, return file_exists($val) && is_readable($val);
},
function ($val) {
return $val === 'null' ? null : $val;
},
), ),
'capath' => array( 'capath' => array(
function ($val) { return is_dir($val) && is_readable($val); }, function ($val) {
function ($val) { return $val === 'null' ? null : $val; }, return is_dir($val) && is_readable($val);
},
function ($val) {
return $val === 'null' ? null : $val;
},
), ),
'github-expose-hostname' => array($booleanValidator, $booleanNormalizer), 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
); );
@ -412,14 +460,28 @@ EOT
// handle properties // handle properties
$uniqueProps = array( $uniqueProps = array(
'name' => array('is_string', function ($val) { return $val; }), 'name' => array('is_string', function ($val) {
'type' => array('is_string', function ($val) { return $val; }), return $val;
'description' => array('is_string', function ($val) { return $val; }), }),
'homepage' => array('is_string', function ($val) { return $val; }), 'type' => array('is_string', function ($val) {
'version' => array('is_string', function ($val) { return $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( 'minimum-stability' => array(
function ($val) { return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]); }, function ($val) {
function ($val) { return VersionParser::normalizeStability($val); } return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
},
function ($val) {
return VersionParser::normalizeStability($val);
},
), ),
'prefer-stable' => array($booleanValidator, $booleanNormalizer), 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
); );

View File

@ -390,6 +390,7 @@ EOT
$io = $this->getIO(); $io = $this->getIO();
if (true === $result) { if (true === $result) {
$io->write('<info>OK</info>'); $io->write('<info>OK</info>');
return; return;
} }

View File

@ -45,7 +45,9 @@ class ExecCommand extends BaseCommand
$binDir = $composer->getConfig()->get('bin-dir'); $binDir = $composer->getConfig()->get('bin-dir');
if ($input->getOption('list') || !$input->getArgument('binary')) { if ($input->getOption('list') || !$input->getArgument('binary')) {
$bins = glob($binDir . '/*'); $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) { if (!$bins) {
throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)"); throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");

View File

@ -185,6 +185,7 @@ EOT
} }
$io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json'); $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
return 1; return 1;
} }
} else { } else {
@ -314,7 +315,6 @@ EOT
if ($showVersion) { if ($showVersion) {
$versionLength = max($versionLength, strlen($package->getFullPrettyVersion())); $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
if ($showLatest) { if ($showLatest) {
$latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly); $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly);
if ($latestPackage === false) { if ($latestPackage === false) {
continue; continue;
@ -464,6 +464,7 @@ EOT
protected function getRootRequires() protected function getRootRequires()
{ {
$rootPackage = $this->getComposer()->getPackage(); $rootPackage = $this->getComposer()->getPackage();
return array_map( return array_map(
'strtolower', 'strtolower',
array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires())) 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); 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()) { if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
return 'up-to-date'; return 'up-to-date';
} }

View File

@ -32,7 +32,6 @@ use Composer\Util\ProcessExecutor;
*/ */
class StatusCommand extends BaseCommand class StatusCommand extends BaseCommand
{ {
const EXIT_CODE_ERRORS = 1; const EXIT_CODE_ERRORS = 1;
const EXIT_CODE_UNPUSHED_CHANGES = 2; const EXIT_CODE_UNPUSHED_CHANGES = 2;
const EXIT_CODE_VERSION_CHANGES = 4; const EXIT_CODE_VERSION_CHANGES = 4;
@ -113,7 +112,7 @@ EOT
$vcsVersionChanges[$targetDir] = array( $vcsVersionChanges[$targetDir] = array(
'previous' => array( 'previous' => array(
'version' => $package->getPrettyVersion(), 'version' => $package->getPrettyVersion(),
'ref' => $previousRef 'ref' => $previousRef,
), ),
'current' => array( 'current' => array(
'version' => $currentVersion['pretty_version'], 'version' => $currentVersion['pretty_version'],
@ -134,6 +133,7 @@ EOT
// output errors/warnings // output errors/warnings
if (!$errors && !$unpushedChanges && !$vcsVersionChanges) { if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
$io->writeError('<info>No local changes</info>'); $io->writeError('<info>No local changes</info>');
return 0; return 0;
} }

View File

@ -416,7 +416,7 @@ class Config
{ {
if (isset($this->repositories[$name])) { if (isset($this->repositories[$name])) {
unset($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']); unset($this->repositories['packagist.org']);
} }
} }

View File

@ -123,12 +123,12 @@ class JsonConfigSource implements ConfigSourceInterface
if (substr($key, 0, 6) === 'extra.') { if (substr($key, 0, 6) === 'extra.') {
$bits = explode('.', $key); $bits = explode('.', $key);
$last = array_pop($bits); $last = array_pop($bits);
$arr =& $config['extra']; $arr = &$config['extra'];
foreach ($bits as $bit) { foreach ($bits as $bit) {
if (!isset($arr[$bit])) { if (!isset($arr[$bit])) {
$arr[$bit] = array(); $arr[$bit] = array();
} }
$arr =& $arr[$bit]; $arr = &$arr[$bit];
} }
$arr[$last] = $val; $arr[$last] = $val;
} else { } else {
@ -147,12 +147,12 @@ class JsonConfigSource implements ConfigSourceInterface
if (substr($key, 0, 6) === 'extra.') { if (substr($key, 0, 6) === 'extra.') {
$bits = explode('.', $key); $bits = explode('.', $key);
$last = array_pop($bits); $last = array_pop($bits);
$arr =& $config['extra']; $arr = &$config['extra'];
foreach ($bits as $bit) { foreach ($bits as $bit) {
if (!isset($arr[$bit])) { if (!isset($arr[$bit])) {
return; return;
} }
$arr =& $arr[$bit]; $arr = &$arr[$bit];
} }
unset($arr[$last]); unset($arr[$last]);
} else { } else {

View File

@ -97,7 +97,8 @@ class Transaction
protected function transactionFromMaps($installMap, $updateMap, $uninstallMap) protected function transactionFromMaps($installMap, $updateMap, $uninstallMap)
{ {
$queue = array_map(function ($operation) { $queue = array_map(
function ($operation) {
return $operation['package']; return $operation['package'];
}, },
$this->findRootPackages($installMap, $updateMap) $this->findRootPackages($installMap, $updateMap)

View File

@ -97,8 +97,7 @@ class FossilDownloader extends VcsDownloader
$match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/'; $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
foreach ($this->process->splitLines($output) as $line) { foreach ($this->process->splitLines($output) as $line) {
if (preg_match($match, $line)) if (preg_match($match, $line)) {
{
break; break;
} }
$log .= $line; $log .= $line;

View File

@ -59,7 +59,8 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
$cacheOptions = sprintf('--dissociate --reference %s ', ProcessExecutor::escape($cachePath)); $cacheOptions = sprintf('--dissociate --reference %s ', ProcessExecutor::escape($cachePath));
$msg = "Cloning ".$this->getShortHash($ref).' from cache'; $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'; $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); $this->io->writeError($msg);

View File

@ -21,7 +21,6 @@ use Composer\Package\PackageInterface;
*/ */
interface VcsCapableDownloaderInterface interface VcsCapableDownloaderInterface
{ {
/** /**
* Gets the VCS Reference for the package at path * Gets the VCS Reference for the package at path
* *

View File

@ -356,7 +356,7 @@ class EventDispatcher
* Add a listener for a particular event * Add a listener for a particular event
* *
* @param string $eventName The event name - typically a constant * @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 * @param int $priority A higher value represents a higher priority
*/ */
public function addListener($eventName, $listener, $priority = 0) public function addListener($eventName, $listener, $priority = 0)

View File

@ -1194,7 +1194,6 @@ class Installer
} }
} }
/** /**
* @param PlatformRepository $platformRepo * @param PlatformRepository $platformRepo
* @param array $aliases * @param array $aliases
@ -1424,7 +1423,7 @@ class Installer
*/ */
public function setDryRun($dryRun = true) public function setDryRun($dryRun = true)
{ {
$this->dryRun = (boolean) $dryRun; $this->dryRun = (bool) $dryRun;
return $this; return $this;
} }
@ -1447,7 +1446,7 @@ class Installer
*/ */
public function setPreferSource($preferSource = true) public function setPreferSource($preferSource = true)
{ {
$this->preferSource = (boolean) $preferSource; $this->preferSource = (bool) $preferSource;
return $this; return $this;
} }
@ -1460,7 +1459,7 @@ class Installer
*/ */
public function setPreferDist($preferDist = true) public function setPreferDist($preferDist = true)
{ {
$this->preferDist = (boolean) $preferDist; $this->preferDist = (bool) $preferDist;
return $this; return $this;
} }
@ -1473,7 +1472,7 @@ class Installer
*/ */
public function setOptimizeAutoloader($optimizeAutoloader = false) public function setOptimizeAutoloader($optimizeAutoloader = false)
{ {
$this->optimizeAutoloader = (boolean) $optimizeAutoloader; $this->optimizeAutoloader = (bool) $optimizeAutoloader;
if (!$this->optimizeAutoloader) { if (!$this->optimizeAutoloader) {
// Force classMapAuthoritative off when not optimizing the // Force classMapAuthoritative off when not optimizing the
// autoloader // autoloader
@ -1492,7 +1491,7 @@ class Installer
*/ */
public function setClassMapAuthoritative($classMapAuthoritative = false) public function setClassMapAuthoritative($classMapAuthoritative = false)
{ {
$this->classMapAuthoritative = (boolean) $classMapAuthoritative; $this->classMapAuthoritative = (bool) $classMapAuthoritative;
if ($this->classMapAuthoritative) { if ($this->classMapAuthoritative) {
// Force optimizeAutoloader when classmap is authoritative // Force optimizeAutoloader when classmap is authoritative
$this->setOptimizeAutoloader(true); $this->setOptimizeAutoloader(true);
@ -1509,7 +1508,7 @@ class Installer
*/ */
public function setApcuAutoloader($apcuAutoloader = false) public function setApcuAutoloader($apcuAutoloader = false)
{ {
$this->apcuAutoloader = (boolean) $apcuAutoloader; $this->apcuAutoloader = (bool) $apcuAutoloader;
return $this; return $this;
} }
@ -1522,7 +1521,7 @@ class Installer
*/ */
public function setUpdate($update = true) public function setUpdate($update = true)
{ {
$this->update = (boolean) $update; $this->update = (bool) $update;
return $this; return $this;
} }
@ -1535,7 +1534,7 @@ class Installer
*/ */
public function setDevMode($devMode = true) public function setDevMode($devMode = true)
{ {
$this->devMode = (boolean) $devMode; $this->devMode = (bool) $devMode;
return $this; return $this;
} }
@ -1550,7 +1549,7 @@ class Installer
*/ */
public function setDumpAutoloader($dumpAutoloader = true) public function setDumpAutoloader($dumpAutoloader = true)
{ {
$this->dumpAutoloader = (boolean) $dumpAutoloader; $this->dumpAutoloader = (bool) $dumpAutoloader;
return $this; return $this;
} }
@ -1565,7 +1564,7 @@ class Installer
*/ */
public function setRunScripts($runScripts = true) public function setRunScripts($runScripts = true)
{ {
$this->runScripts = (boolean) $runScripts; $this->runScripts = (bool) $runScripts;
return $this; return $this;
} }
@ -1591,7 +1590,7 @@ class Installer
*/ */
public function setVerbose($verbose = true) public function setVerbose($verbose = true)
{ {
$this->verbose = (boolean) $verbose; $this->verbose = (bool) $verbose;
return $this; return $this;
} }
@ -1614,7 +1613,7 @@ class Installer
*/ */
public function setIgnorePlatformRequirements($ignorePlatformReqs = false) public function setIgnorePlatformRequirements($ignorePlatformReqs = false)
{ {
$this->ignorePlatformReqs = (boolean) $ignorePlatformReqs; $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
return $this; return $this;
} }
@ -1641,7 +1640,7 @@ class Installer
*/ */
public function setWhitelistDependencies($updateDependencies = true) public function setWhitelistDependencies($updateDependencies = true)
{ {
$this->whitelistDependencies = (boolean) $updateDependencies; $this->whitelistDependencies = (bool) $updateDependencies;
return $this; return $this;
} }
@ -1654,7 +1653,7 @@ class Installer
*/ */
public function setPreferStable($preferStable = true) public function setPreferStable($preferStable = true)
{ {
$this->preferStable = (boolean) $preferStable; $this->preferStable = (bool) $preferStable;
return $this; return $this;
} }
@ -1667,7 +1666,7 @@ class Installer
*/ */
public function setPreferLowest($preferLowest = true) public function setPreferLowest($preferLowest = true)
{ {
$this->preferLowest = (boolean) $preferLowest; $this->preferLowest = (bool) $preferLowest;
return $this; return $this;
} }
@ -1682,7 +1681,7 @@ class Installer
*/ */
public function setWriteLock($writeLock = true) public function setWriteLock($writeLock = true)
{ {
$this->writeLock = (boolean) $writeLock; $this->writeLock = (bool) $writeLock;
return $this; return $this;
} }
@ -1697,7 +1696,7 @@ class Installer
*/ */
public function setExecuteOperations($executeOperations = true) public function setExecuteOperations($executeOperations = true)
{ {
$this->executeOperations = (boolean) $executeOperations; $this->executeOperations = (bool) $executeOperations;
return $this; return $this;
} }
@ -1710,7 +1709,7 @@ class Installer
*/ */
public function setSkipSuggest($skipSuggest = true) public function setSkipSuggest($skipSuggest = true)
{ {
$this->skipSuggest = (boolean) $skipSuggest; $this->skipSuggest = (bool) $skipSuggest;
return $this; return $this;
} }

View File

@ -26,7 +26,7 @@ class ArchivableFilesFilter extends FilterIterator
{ {
$file = $this->getInnerIterator()->current(); $file = $this->getInnerIterator()->current();
if ($file->isDir()) { if ($file->isDir()) {
$this->dirs[] = (string)$file; $this->dirs[] = (string) $file;
return false; return false;
} }

View File

@ -37,7 +37,7 @@ class ArchivableFilesFinder extends \FilterIterator
* *
* @param string $sources Path to source files to be archived * @param string $sources Path to source files to be archived
* @param array $excludes Composer's own exclude rules from composer.json * @param array $excludes Composer's own exclude rules from composer.json
* @param boolean $ignoreFilters Ignore filters when looking for files * @param bool $ignoreFilters Ignore filters when looking for files
*/ */
public function __construct($sources, array $excludes, $ignoreFilters = false) public function __construct($sources, array $excludes, $ignoreFilters = false)
{ {

View File

@ -99,7 +99,7 @@ class ArchiveManager
* @param string $targetDir The directory where to build the archive * @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 * @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 * 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 bool $ignoreFilters Ignore filters when looking for files in the package
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws \RuntimeException * @throws \RuntimeException
* @return string The path of the created archive * @return string The path of the created archive

View File

@ -176,7 +176,7 @@ class CompletePackage extends Package implements CompletePackageInterface
*/ */
public function isAbandoned() public function isAbandoned()
{ {
return (boolean) $this->abandoned; return (bool) $this->abandoned;
} }
/** /**

View File

@ -56,7 +56,7 @@ abstract class BitbucketDriver extends VcsDriver
$this->config->get('cache-repo-dir'), $this->config->get('cache-repo-dir'),
$this->originUrl, $this->originUrl,
$this->owner, $this->owner,
$this->repository $this->repository,
)) ))
); );
} }
@ -104,6 +104,7 @@ abstract class BitbucketDriver extends VcsDriver
$this->homeUrl = $repoData['links']['html']['href']; $this->homeUrl = $repoData['links']['html']['href'];
$this->website = $repoData['website']; $this->website = $repoData['website'];
$this->vcsType = $repoData['scm']; $this->vcsType = $repoData['scm'];
return true; return true;
} }
@ -268,7 +269,7 @@ abstract class BitbucketDriver extends VcsDriver
array( array(
'pagelen' => 100, 'pagelen' => 100,
'fields' => 'values.name,values.target.hash,next', 'fields' => 'values.name,values.target.hash,next',
'sort' => '-target.date' 'sort' => '-target.date',
), ),
null, null,
'&' '&'
@ -312,7 +313,7 @@ abstract class BitbucketDriver extends VcsDriver
array( array(
'pagelen' => 100, 'pagelen' => 100,
'fields' => 'values.name,values.target.hash,next', 'fields' => 'values.name,values.target.hash,next',
'sort' => '-target.date' 'sort' => '-target.date',
), ),
null, null,
'&' '&'

View File

@ -13,7 +13,6 @@
namespace Composer\Repository\Vcs; namespace Composer\Repository\Vcs;
use Composer\Config; use Composer\Config;
use Composer\Json\JsonFile;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
@ -142,6 +141,7 @@ class FossilDriver extends VcsDriver
public function getChangeDate($identifier) public function getChangeDate($identifier)
{ {
$this->process->execute(sprintf('fossil finfo composer.json | head -n 2 | tail -n 1 | awk \'{print $1}\''), $output, $this->checkoutDir); $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')); return new \DateTime(trim($output), new \DateTimeZone('UTC'));
} }
@ -194,8 +194,7 @@ class FossilDriver extends VcsDriver
return true; return true;
} }
if (preg_match('!/fossil/|\.fossil!', $url)) if (preg_match('!/fossil/|\.fossil!', $url)) {
{
return true; return true;
} }

View File

@ -12,7 +12,6 @@
namespace Composer\Repository\Vcs; namespace Composer\Repository\Vcs;
use Composer\Json\JsonFile;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\Util\Git as GitUtil; use Composer\Util\Git as GitUtil;
@ -143,6 +142,7 @@ class GitDriver extends VcsDriver
'git log -1 --format=%%at %s', 'git log -1 --format=%%at %s',
ProcessExecutor::escape($identifier) ProcessExecutor::escape($identifier)
), $output, $this->repoDir); ), $output, $this->repoDir);
return new \DateTime('@'.trim($output), new \DateTimeZone('UTC')); return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
} }

View File

@ -186,7 +186,6 @@ class GitHubDriver extends VcsDriver
$notFoundRetries = 2; $notFoundRetries = 2;
while ($notFoundRetries) { while ($notFoundRetries) {
try { try {
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier); $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
$resource = JsonFile::parseJson($this->getContents($resource)); $resource = JsonFile::parseJson($this->getContents($resource));
if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) { 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 // TODO should be removed when possible
// retry fetching if github returns a 404 since they happen randomly // retry fetching if github returns a 404 since they happen randomly
$notFoundRetries--; $notFoundRetries--;
return null; return null;
} }
} }
@ -220,6 +220,7 @@ class GitHubDriver extends VcsDriver
$resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier); $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
$commit = JsonFile::parseJson($this->getContents($resource), $resource); $commit = JsonFile::parseJson($this->getContents($resource), $resource);
return new \DateTime($commit['commit']['committer']['date']); return new \DateTime($commit['commit']['committer']['date']);
} }

View File

@ -127,6 +127,7 @@ class GitLabDriver extends VcsDriver
if ($e->getCode() !== 404) { if ($e->getCode() !== 404) {
throw $e; throw $e;
} }
return null; return null;
} }
@ -149,7 +150,6 @@ class GitLabDriver extends VcsDriver
return new \DateTime(); return new \DateTime();
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -260,6 +260,7 @@ class GitLabDriver extends VcsDriver
} }
$encoded .= $character; $encoded .= $character;
} }
return $encoded; return $encoded;
} }

View File

@ -13,7 +13,6 @@
namespace Composer\Repository\Vcs; namespace Composer\Repository\Vcs;
use Composer\Config; use Composer\Config;
use Composer\Json\JsonFile;
use Composer\Util\ProcessExecutor; use Composer\Util\ProcessExecutor;
use Composer\Util\Filesystem; use Composer\Util\Filesystem;
use Composer\IO\IOInterface; use Composer\IO\IOInterface;
@ -142,6 +141,7 @@ class HgDriver extends VcsDriver
$output, $output,
$this->repoDir $this->repoDir
); );
return new \DateTime(trim($output), new \DateTimeZone('UTC')); return new \DateTime(trim($output), new \DateTimeZone('UTC'));
} }

View File

@ -26,6 +26,7 @@ class PerforceDriver extends VcsDriver
protected $branch; protected $branch;
/** @var Perforce */ /** @var Perforce */
protected $perforce; protected $perforce;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -57,7 +58,6 @@ class PerforceDriver extends VcsDriver
$this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io); $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -132,7 +132,6 @@ class SvnDriver extends VcsDriver
$this->infoCache[$identifier] = $composer; $this->infoCache[$identifier] = $composer;
} }
return $this->infoCache[$identifier]; return $this->infoCache[$identifier];
} }

View File

@ -76,7 +76,7 @@ abstract class VcsDriver implements VcsDriverInterface
* Returns whether or not the given $identifier should be cached or not. * Returns whether or not the given $identifier should be cached or not.
* *
* @param string $identifier * @param string $identifier
* @return boolean * @return bool
*/ */
protected function shouldCache($identifier) protected function shouldCache($identifier)
{ {
@ -102,7 +102,6 @@ abstract class VcsDriver implements VcsDriverInterface
$this->infoCache[$identifier] = $composer; $this->infoCache[$identifier] = $composer;
} }
return $this->infoCache[$identifier]; return $this->infoCache[$identifier];
} }

View File

@ -57,6 +57,7 @@ class Bitbucket
if (!isset($this->token['access_token'])) { if (!isset($this->token['access_token'])) {
return ''; return '';
} }
return $this->token['access_token']; return $this->token['access_token'];
} }
@ -213,7 +214,7 @@ class Bitbucket
"consumer-key" => $consumerKey, "consumer-key" => $consumerKey,
"consumer-secret" => $consumerSecret, "consumer-secret" => $consumerSecret,
"access-token" => $this->token['access_token'], "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); $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
@ -236,7 +237,7 @@ class Bitbucket
} }
$this->token = array( $this->token = array(
'access_token' => $authConfig[$originUrl]['access-token'] 'access_token' => $authConfig[$originUrl]['access-token'],
); );
return true; return true;

View File

@ -165,7 +165,7 @@ class Git
$defaultUsername = null; $defaultUsername = null;
if (isset($authParts) && $authParts) { if (isset($authParts) && $authParts) {
if (false !== strpos($authParts, ':')) { if (false !== strpos($authParts, ':')) {
list($defaultUsername,) = explode(':', $authParts, 2); list($defaultUsername, ) = explode(':', $authParts, 2);
} else { } else {
$defaultUsername = $authParts; $defaultUsername = $authParts;
} }
@ -238,7 +238,7 @@ class Git
'fatal: Authentication failed', 'fatal: Authentication failed',
'remote error: Invalid username or password.', 'remote error: Invalid username or password.',
'error: 401 Unauthorized', 'error: 401 Unauthorized',
'fatal: unable to access' 'fatal: unable to access',
); );
foreach ($authFailures as $authFailure) { foreach ($authFailures as $authFailure) {

View File

@ -441,6 +441,7 @@ class Perforce
if ($index3 !== false) { if ($index3 !== false) {
$phrase = trim(substr($result, $index3)); $phrase = trim(substr($result, $index3));
$fields = explode(' ', $phrase); $fields = explode(' ', $phrase);
return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1]; return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
} }
} }

View File

@ -30,18 +30,20 @@ class Platform
if (preg_match('#^~[\\/]#', $path)) { if (preg_match('#^~[\\/]#', $path)) {
return self::getUserDirectory() . substr($path, 1); return self::getUserDirectory() . substr($path, 1);
} }
return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function($matches) {
return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
// Treat HOME as an alias for USERPROFILE on Windows for legacy reasons // Treat HOME as an alias for USERPROFILE on Windows for legacy reasons
if (Platform::isWindows() && $matches['var'] == 'HOME') { if (Platform::isWindows() && $matches['var'] == 'HOME') {
return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path']; return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
} }
return getenv($matches['var']) . $matches['path']; return getenv($matches['var']) . $matches['path'];
}, $path); }, $path);
} }
/** /**
* @return string The formal user home as detected from environment parameters
* @throws \RuntimeException If the user home could not reliably be determined * @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() public static function getUserDirectory()
{ {
@ -55,6 +57,7 @@ class Platform
if (function_exists('posix_getuid') && function_exists('posix_getpwuid')) { if (function_exists('posix_getuid') && function_exists('posix_getpwuid')) {
$info = posix_getpwuid(posix_getuid()); $info = posix_getpwuid(posix_getuid());
return $info['dir']; return $info['dir'];
} }

View File

@ -721,8 +721,7 @@ class RemoteFilesystem
} elseif ($this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)) { } elseif ($this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)) {
if ($auth['password'] === 'oauth2') { if ($auth['password'] === 'oauth2') {
$headers[] = 'Authorization: Bearer '.$auth['username']; $headers[] = 'Authorization: Bearer '.$auth['username'];
} } elseif ($auth['password'] === 'private-token') {
else if ($auth['password'] === 'private-token') {
$headers[] = 'PRIVATE-TOKEN: '.$auth['username']; $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
} }
} elseif ('bitbucket.org' === $originUrl } elseif ('bitbucket.org' === $originUrl

View File

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

View File

@ -12,7 +12,6 @@
namespace Composer\Util; namespace Composer\Util;
use Symfony\Component\Process\PhpProcess;
use Composer\CaBundle\CaBundle; use Composer\CaBundle\CaBundle;
/** /**

View File

@ -67,6 +67,7 @@ class XdebugHandler
$command = $this->getCommand(); $command = $this->getCommand();
$this->restart($command); $this->restart($command);
} }
return; return;
} }
@ -249,7 +250,7 @@ class XdebugHandler
} }
if ($this->output->isDecorated()) { if ($this->output->isDecorated()) {
$offset = count($args) > 1 ? 2: 1; $offset = count($args) > 1 ? 2 : 1;
array_splice($args, $offset, 0, '--ansi'); array_splice($args, $offset, 0, '--ansi');
} }

View File

@ -182,7 +182,7 @@ class AllFunctionalTest extends TestCase
break; break;
case 'EXPECT-EXIT-CODE': case 'EXPECT-EXIT-CODE':
$sectionData = (integer) $sectionData; $sectionData = (int) $sectionData;
break; break;
case 'EXPECT': case 'EXPECT':

View File

@ -17,7 +17,10 @@ use Composer\Util\Filesystem;
class CacheTest extends TestCase class CacheTest extends TestCase
{ {
private $files, $root, $finder, $cache; private $files;
private $root;
private $finder;
private $cache;
public function setUp() public function setUp()
{ {

View File

@ -17,7 +17,6 @@ use Composer\TestCase;
class InitCommandTest extends TestCase class InitCommandTest extends TestCase
{ {
public function testParseValidAuthorString() public function testParseValidAuthorString()
{ {
$command = new InitCommand; $command = new InitCommand;
@ -51,7 +50,7 @@ class InitCommandTest extends TestCase
$command = new InitCommand; $command = new InitCommand;
$author = $command->parseAuthorString( $author = $command->parseAuthorString(
'Johnathon "Johnny" Smith <john@example.com>'); 'Johnathon "Johnny" Smith <john@example.com>');
$this->assertEquals('Johnathon "Johnny" Smith', $author['name'] ); $this->assertEquals('Johnathon "Johnny" Smith', $author['name']);
$this->assertEquals('john@example.com', $author['email']); $this->assertEquals('john@example.com', $author['email']);
} }
@ -64,7 +63,7 @@ class InitCommandTest extends TestCase
$command = new InitCommand; $command = new InitCommand;
$author = $command->parseAuthorString( $author = $command->parseAuthorString(
'Johnathon (Johnny) Smith <john@example.com>'); 'Johnathon (Johnny) Smith <john@example.com>');
$this->assertEquals('Johnathon (Johnny) Smith', $author['name'] ); $this->assertEquals('Johnathon (Johnny) Smith', $author['name']);
$this->assertEquals('john@example.com', $author['email']); $this->assertEquals('john@example.com', $author['email']);
} }

View File

@ -19,7 +19,6 @@ use Composer\TestCase;
class RunScriptCommandTest extends TestCase class RunScriptCommandTest extends TestCase
{ {
/** /**
* @dataProvider getDevOptions * @dataProvider getDevOptions
* @param bool $dev * @param bool $dev
@ -79,7 +78,7 @@ class RunScriptCommandTest extends TestCase
'getSynopsis', 'getSynopsis',
'initialize', 'initialize',
'isInteractive', 'isInteractive',
'getComposer' 'getComposer',
)) ))
->getMock(); ->getMock();
$command->expects($this->any())->method('getComposer')->willReturn($composer); $command->expects($this->any())->method('getComposer')->willReturn($composer);

View File

@ -261,7 +261,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
'ssh://[user@]host.xz[:port]/path/to/repo.git/', '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', '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));
} }
/** /**

View File

@ -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), 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; $ruleSet = new RuleSet;

View File

@ -45,7 +45,8 @@ class GitDownloaderTest extends TestCase
$refl->setValue(null, null); $refl->setValue(null, null);
} }
protected function setupConfig($config = null) { protected function setupConfig($config = null)
{
if (!$config) { if (!$config) {
$config = new Config(); $config = new Config();
} }
@ -53,6 +54,7 @@ class GitDownloaderTest extends TestCase
$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest-'.md5(uniqid('', true)); $tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest-'.md5(uniqid('', true));
$config->merge(array('config' => array('home' => $tmpDir))); $config->merge(array('config' => array('home' => $tmpDir)));
} }
return $config; return $config;
} }
@ -100,8 +102,9 @@ class GitDownloaderTest extends TestCase
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($this->winCompat('git --version'))) ->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'; $output = 'git version 1.0.0';
return 0; return 0;
})); }));
@ -150,8 +153,9 @@ class GitDownloaderTest extends TestCase
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($this->winCompat('git --version'))) ->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'; $output = 'git version 2.3.1';
return 0; return 0;
})); }));
@ -215,8 +219,9 @@ class GitDownloaderTest extends TestCase
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($this->winCompat('git --version'))) ->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'; $output = 'git version 1.0.0';
return 0; return 0;
})); }));
@ -298,8 +303,9 @@ class GitDownloaderTest extends TestCase
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($this->winCompat('git --version'))) ->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'; $output = 'git version 1.0.0';
return 0; return 0;
})); }));
@ -343,8 +349,9 @@ class GitDownloaderTest extends TestCase
$processExecutor->expects($this->at(0)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($this->winCompat('git --version'))) ->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'; $output = 'git version 1.0.0';
return 0; return 0;
})); }));
$processExecutor->expects($this->at(1)) $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 (fetch)
composer https://github.com/old/url (push) composer https://github.com/old/url (push)
'; ';
return 0; return 0;
})); }));
$processExecutor->expects($this->at(3)) $processExecutor->expects($this->at(3))

View File

@ -2266,7 +2266,6 @@ class JsonManipulatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('{ $this->assertEquals('{
} }
', $manipulator->getContents()); ', $manipulator->getContents());
} }
public function testIndentDetection() public function testIndentDetection()

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
<?php <?php
/* /*
* This file is part of Composer. * This file is part of Composer.
* *
@ -25,7 +26,7 @@ class XdebugHandlerMock extends XdebugHandler
$this->output = Factory::createOutput(); $this->output = Factory::createOutput();
parent::__construct($this->output); parent::__construct($this->output);
$loaded = null === $loaded ? true: $loaded; $loaded = null === $loaded ? true : $loaded;
$class = new \ReflectionClass(get_parent_class($this)); $class = new \ReflectionClass(get_parent_class($this));
$prop = $class->getProperty('loaded'); $prop = $class->getProperty('loaded');

View File

@ -136,6 +136,7 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase
{ {
$expectedConfig = $config; $expectedConfig = $config;
unset($expectedConfig['transport-options']); unset($expectedConfig['transport-options']);
return $expectedConfig; return $expectedConfig;
} }

View File

@ -178,9 +178,9 @@ class ComposerRepositoryTest extends TestCase
'results' => array( 'results' => array(
array( array(
'name' => 'foo', 'name' => 'foo',
'description' => null 'description' => null,
) ),
) ),
); );
$rfs = $this->getMockBuilder('Composer\Util\RemoteFilesystem') $rfs = $this->getMockBuilder('Composer\Util\RemoteFilesystem')

View File

@ -109,32 +109,32 @@ class GitBitbucketDriverTest extends TestCase
array( array(
$this->originUrl, $this->originUrl,
'https://api.bitbucket.org/2.0/repositories/user/repo?fields=-project%2C-owner', 'https://api.bitbucket.org/2.0/repositories/user/repo?fields=-project%2C-owner',
false false,
), ),
array( array(
$this->originUrl, $this->originUrl,
'https://api.bitbucket.org/1.0/repositories/user/repo/main-branch', 'https://api.bitbucket.org/1.0/repositories/user/repo/main-branch',
false false,
), ),
array( array(
$this->originUrl, $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', '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( array(
$this->originUrl, $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', '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( array(
$this->originUrl, $this->originUrl,
'https://api.bitbucket.org/1.0/repositories/user/repo/raw/master/composer.json', 'https://api.bitbucket.org/1.0/repositories/user/repo/raw/master/composer.json',
false false,
), ),
array( array(
$this->originUrl, $this->originUrl,
'https://api.bitbucket.org/2.0/repositories/user/repo/commit/master?fields=date', 'https://api.bitbucket.org/2.0/repositories/user/repo/commit/master?fields=date',
false false,
) )
) )
->willReturnOnConsecutiveCalls( ->willReturnOnConsecutiveCalls(
@ -154,14 +154,14 @@ class GitBitbucketDriverTest extends TestCase
$this->assertEquals( $this->assertEquals(
array( array(
'1.0.1' => '9b78a3932143497c519e49b8241083838c8ff8a1', '1.0.1' => '9b78a3932143497c519e49b8241083838c8ff8a1',
'1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb' '1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb',
), ),
$driver->getTags() $driver->getTags()
); );
$this->assertEquals( $this->assertEquals(
array( array(
'master' => '937992d19d72b5116c3e8c4a04f960e5fa270b22' 'master' => '937992d19d72b5116c3e8c4a04f960e5fa270b22',
), ),
$driver->getBranches() $driver->getBranches()
); );
@ -174,20 +174,20 @@ class GitBitbucketDriverTest extends TestCase
'authors' => array( 'authors' => array(
array( array(
'name' => 'Name', 'name' => 'Name',
'email' => 'local@domain.tld' 'email' => 'local@domain.tld',
) ),
), ),
'require' => array( 'require' => array(
'creator/package' => '^1.0' 'creator/package' => '^1.0',
), ),
'require-dev' => array( 'require-dev' => array(
'phpunit/phpunit' => '~4.8' 'phpunit/phpunit' => '~4.8',
), ),
'time' => '2016-05-17 13:19:52', 'time' => '2016-05-17 13:19:52',
'support' => array( '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') $driver->getComposerInformation('master')
); );
@ -210,7 +210,7 @@ class GitBitbucketDriverTest extends TestCase
'type' => 'zip', 'type' => 'zip',
'url' => 'https://bitbucket.org/user/repo/get/reference.zip', 'url' => 'https://bitbucket.org/user/repo/get/reference.zip',
'reference' => 'reference', 'reference' => 'reference',
'shasum' => '' 'shasum' => '',
), ),
$driver->getDist('reference') $driver->getDist('reference')
); );

View File

@ -19,7 +19,6 @@ use Composer\Config;
class HgDriverTest extends TestCase class HgDriverTest extends TestCase
{ {
/** @type \Composer\IO\IOInterface|\PHPUnit_Framework_MockObject_MockObject */ /** @type \Composer\IO\IOInterface|\PHPUnit_Framework_MockObject_MockObject */
private $io; private $io;
/** @type Config */ /** @type Config */
@ -65,5 +64,4 @@ class HgDriverTest extends TestCase
array('https://user@bitbucket.org/user/repo'), array('https://user@bitbucket.org/user/repo'),
); );
} }
} }

View File

@ -76,7 +76,7 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase
'http' => array( 'http' => array(
'method' => 'POST', 'method' => 'POST',
'content' => 'grant_type=client_credentials', 'content' => 'grant_type=client_credentials',
) ),
) )
) )
->willReturn( ->willReturn(
@ -110,8 +110,8 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase
'access-token' => $this->token, 'access-token' => $this->token,
'access-token-expiration' => $this->time + 1800, 'access-token-expiration' => $this->time + 1800,
'consumer-key' => $this->consumer_key, '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' => 'randomExpiredToken',
'access-token-expiration' => $this->time - 400, 'access-token-expiration' => $this->time - 400,
'consumer-key' => $this->consumer_key, '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( 'http' => array(
'method' => 'POST', 'method' => 'POST',
'content' => 'grant_type=client_credentials', 'content' => 'grant_type=client_credentials',
) ),
) )
) )
->willReturn( ->willReturn(
@ -196,7 +196,7 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase
'http' => array( 'http' => array(
'method' => 'POST', 'method' => 'POST',
'content' => 'grant_type=client_credentials', 'content' => 'grant_type=client_credentials',
) ),
) )
) )
->willThrowException( ->willThrowException(
@ -279,7 +279,7 @@ class BitbucketTest extends \PHPUnit_Framework_TestCase
"consumer-key" => $this->consumer_key, "consumer-key" => $this->consumer_key,
"consumer-secret" => $this->consumer_secret, "consumer-secret" => $this->consumer_secret,
"access-token" => $this->token, "access-token" => $this->token,
"access-token-expiration" => $this->time + 3600 "access-token-expiration" => $this->time + 3600,
) )
); );

View File

@ -257,10 +257,9 @@ class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase
->willReturn(array( ->willReturn(array(
'username' => 'x-token-auth', 'username' => 'x-token-auth',
// This token is fake, but it matches a valid token's pattern. // This token is fake, but it matches a valid token's pattern.
'password' => '1A0yeK5Po3ZEeiiRiMWLivS0jirLdoGuaSGq9NvESFx1Fsdn493wUDXC8rz_1iKVRTl1GINHEUCsDxGh5lZ=' 'password' => '1A0yeK5Po3ZEeiiRiMWLivS0jirLdoGuaSGq9NvESFx1Fsdn493wUDXC8rz_1iKVRTl1GINHEUCsDxGh5lZ=',
)); ));
$rfs = new RemoteFilesystem($io, $config); $rfs = new RemoteFilesystem($io, $config);
$hostname = parse_url($url, PHP_URL_HOST); $hostname = parse_url($url, PHP_URL_HOST);

View File

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

View File

@ -56,7 +56,8 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
), ),
array( array(
$a = array('http' => array('method' => 'GET', 'max_redirects' => 20, 'follow_location' => 1, 'header' => array('User-Agent: foo'))), array('http' => array('method' => 'GET', 'header' => 'User-Agent: foo')), $a = array('http' => 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),
), ),
); );
} }