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),
); );
@ -472,7 +534,7 @@ EOT
if (2 === count($values)) { if (2 === count($values)) {
return $this->configSource->addRepository($matches[1], array( return $this->configSource->addRepository($matches[1], array(
'type' => $values[0], 'type' => $values[0],
'url' => $values[1], 'url' => $values[1],
)); ));
} }

View File

@ -167,7 +167,7 @@ EOT
$output = ''; $output = '';
foreach ($messages as $style => $msgs) { foreach ($messages as $style => $msgs) {
foreach ($msgs as $msg) { foreach ($msgs as $msg) {
$output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL; $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
} }
} }
@ -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;
} }
@ -590,31 +591,31 @@ EOT
foreach ($warnings as $warning => $current) { foreach ($warnings as $warning => $current) {
switch ($warning) { switch ($warning) {
case 'apc_cli': 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 .= "Add the following to the end of your `php.ini`:".PHP_EOL;
$text .= " apc.enable_cli = Off"; $text .= " apc.enable_cli = Off";
$displayIniMessage = true; $displayIniMessage = true;
break; break;
case 'zlib': 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; $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
$displayIniMessage = true; $displayIniMessage = true;
break; break;
case 'sigchild': 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 .= "Recompile it without this flag if possible, see also:".PHP_EOL;
$text .= " https://bugs.php.net/bug.php?id=22999"; $text .= " https://bugs.php.net/bug.php?id=22999";
break; break;
case 'curlwrappers': 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"; $text .= " Recompile it without this flag if possible";
break; break;
case 'php': 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."; $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
break; break;
@ -628,12 +629,12 @@ EOT
break; break;
case 'xdebug_loaded': 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."; $text .= " Disabling it when using Composer is recommended.";
break; break;
case 'xdebug_profile': 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 .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
$text .= " xdebug.profiler_enabled = 0"; $text .= " xdebug.profiler_enabled = 0";
$displayIniMessage = true; $displayIniMessage = true;

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

@ -323,7 +323,7 @@ EOT
if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\'"()]+) <(?P<email>.+?)>$/u', $author, $match)) { if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\'"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
if ($this->isValidEmail($match['email'])) { if ($this->isValidEmail($match['email'])) {
return array( return array(
'name' => trim($match['name']), 'name' => trim($match['name']),
'email' => $match['email'], 'email' => $match['email'],
); );
} }

View File

@ -97,9 +97,9 @@ EOT
} }
$io->write(JsonFile::encode(array( $io->write(JsonFile::encode(array(
'name' => $root->getPrettyName(), 'name' => $root->getPrettyName(),
'version' => $root->getFullPrettyVersion(), 'version' => $root->getFullPrettyVersion(),
'license' => $root->getLicense(), 'license' => $root->getLicense(),
'dependencies' => $dependencies, 'dependencies' => $dependencies,
))); )));
break; break;

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,14 +315,13 @@ 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;
} }
$latestPackages[$package->getPrettyName()] = $latestPackage; $latestPackages[$package->getPrettyName()] = $latestPackage;
$latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion())); $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
} }
} }
} else { } else {
@ -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';
} }
@ -806,10 +808,10 @@ EOT
/** /**
* Given a package, this finds the latest package matching it * Given a package, this finds the latest package matching it
* *
* @param PackageInterface $package * @param PackageInterface $package
* @param Composer $composer * @param Composer $composer
* @param string $phpVersion * @param string $phpVersion
* @param bool $minorOnly * @param bool $minorOnly
* *
* @return PackageInterface|null * @return PackageInterface|null
*/ */

View File

@ -32,10 +32,9 @@ 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;
protected function configure() protected function configure()
{ {
@ -113,11 +112,11 @@ 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'],
'ref' => $currentVersion['commit'], 'ref' => $currentVersion['commit'],
), ),
); );
} }
@ -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

@ -36,7 +36,7 @@ class UpdateOperation extends SolverOperation
parent::__construct($reason); parent::__construct($reason);
$this->initialPackage = $initial; $this->initialPackage = $initial;
$this->targetPackage = $target; $this->targetPackage = $target;
} }
/** /**

View File

@ -820,7 +820,7 @@ class Solver
$lastLiteral = null; $lastLiteral = null;
$lastLevel = null; $lastLevel = null;
$lastBranchIndex = 0; $lastBranchIndex = 0;
$lastBranchOffset = 0; $lastBranchOffset = 0;
for ($i = count($this->branches) - 1; $i >= 0; $i--) { for ($i = count($this->branches) - 1; $i >= 0; $i--) {
list($literals, $l) = $this->branches[$i]; list($literals, $l) = $this->branches[$i];

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

@ -28,7 +28,7 @@ class DownloadManager
private $preferSource = false; private $preferSource = false;
private $packagePreferences = array(); private $packagePreferences = array();
private $filesystem; private $filesystem;
private $downloaders = array(); private $downloaders = array();
/** /**
* Initializes download manager. * Initializes download manager.
@ -181,8 +181,8 @@ class DownloadManager
public function download(PackageInterface $package, $targetDir, $preferSource = null) public function download(PackageInterface $package, $targetDir, $preferSource = null)
{ {
$preferSource = null !== $preferSource ? $preferSource : $this->preferSource; $preferSource = null !== $preferSource ? $preferSource : $this->preferSource;
$sourceType = $package->getSourceType(); $sourceType = $package->getSourceType();
$distType = $package->getDistType(); $distType = $package->getDistType();
$sources = array(); $sources = array();
if ($sourceType) { if ($sourceType) {
@ -248,10 +248,10 @@ class DownloadManager
if ('dist' === $installationSource) { if ('dist' === $installationSource) {
$initialType = $initial->getDistType(); $initialType = $initial->getDistType();
$targetType = $target->getDistType(); $targetType = $target->getDistType();
} else { } else {
$initialType = $initial->getSourceType(); $initialType = $initial->getSourceType();
$targetType = $target->getSourceType(); $targetType = $target->getSourceType();
} }
// upgrading from a dist stable package to a dev package, force source reinstall // upgrading from a dist stable package to a dev package, force source reinstall

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

@ -30,7 +30,7 @@ use Symfony\Component\Filesystem\Filesystem;
class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
{ {
const STRATEGY_SYMLINK = 10; const STRATEGY_SYMLINK = 10;
const STRATEGY_MIRROR = 20; const STRATEGY_MIRROR = 20;
/** /**
* {@inheritdoc} * {@inheritdoc}

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

@ -344,7 +344,7 @@ class Factory
// load package // load package
$parser = new VersionParser; $parser = new VersionParser;
$guesser = new VersionGuesser($config, new ProcessExecutor($io), $parser); $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); $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
$composer->setPackage($package); $composer->setPackage($package);

View File

@ -126,8 +126,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface
/** /**
* System is unusable. * System is unusable.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function emergency($message, array $context = array()) 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 * Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up. * trigger the SMS alerts and wake you up.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function alert($message, array $context = array()) public function alert($message, array $context = array())
@ -155,8 +155,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface
* *
* Example: Application component unavailable, unexpected exception. * Example: Application component unavailable, unexpected exception.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function critical($message, array $context = array()) 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 * Runtime errors that do not require immediate action but should typically
* be logged and monitored. * be logged and monitored.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function error($message, array $context = array()) 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 * Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong. * that are not necessarily wrong.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function warning($message, array $context = array()) public function warning($message, array $context = array())
@ -195,8 +195,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface
/** /**
* Normal but significant events. * Normal but significant events.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function notice($message, array $context = array()) public function notice($message, array $context = array())
@ -209,8 +209,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface
* *
* Example: User logs in, SQL logs. * Example: User logs in, SQL logs.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function info($message, array $context = array()) public function info($message, array $context = array())
@ -221,8 +221,8 @@ abstract class BaseIO implements IOInterface, LoggerInterface
/** /**
* Detailed debug information. * Detailed debug information.
* *
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function debug($message, array $context = array()) public function debug($message, array $context = array())
@ -233,9 +233,9 @@ abstract class BaseIO implements IOInterface, LoggerInterface
/** /**
* Logs with an arbitrary level. * Logs with an arbitrary level.
* *
* @param mixed $level * @param mixed $level
* @param string $message * @param string $message
* @param array $context * @param array $context
* @return null * @return null
*/ */
public function log($level, $message, array $context = array()) public function log($level, $message, array $context = array())

View File

@ -334,7 +334,7 @@ class Installer
* @param RepositoryInterface $installedRepo * @param RepositoryInterface $installedRepo
* @param PlatformRepository $platformRepo * @param PlatformRepository $platformRepo
* @param array $aliases * @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) protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases)
{ {
@ -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

@ -186,7 +186,7 @@ class InstallationManager
$target = $operation->getTargetPackage(); $target = $operation->getTargetPackage();
$initialType = $initial->getType(); $initialType = $initial->getType();
$targetType = $target->getType(); $targetType = $target->getType();
if ($initialType === $targetType) { if ($initialType === $targetType) {
$installer = $this->getInstaller($initialType); $installer = $this->getInstaller($initialType);
@ -273,8 +273,8 @@ class InstallationManager
); );
$opts = array('http' => $opts = array('http' =>
array( array(
'method' => 'POST', 'method' => 'POST',
'header' => array('Content-type: application/x-www-form-urlencoded'), 'header' => array('Content-type: application/x-www-form-urlencoded'),
'content' => http_build_query($params, '', '&'), 'content' => http_build_query($params, '', '&'),
'timeout' => 3, 'timeout' => 3,
), ),
@ -300,8 +300,8 @@ class InstallationManager
$opts = array('http' => $opts = array('http' =>
array( array(
'method' => 'POST', 'method' => 'POST',
'header' => array('Content-Type: application/json'), 'header' => array('Content-Type: application/json'),
'content' => json_encode($postData), 'content' => json_encode($postData),
'timeout' => 6, 'timeout' => 6,
), ),

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

@ -35,9 +35,9 @@ class ArchivableFilesFinder extends \FilterIterator
/** /**
* Initializes the internal Symfony Finder with appropriate filters * Initializes the internal Symfony Finder with appropriate filters
* *
* @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

@ -94,12 +94,12 @@ class ArchiveManager
/** /**
* Create an archive of the specified package. * Create an archive of the specified package.
* *
* @param PackageInterface $package The package to archive * @param PackageInterface $package The package to archive
* @param string $format The format of the archive (zip, tar, ...) * @param string $format The format of the archive (zip, tar, ...)
* @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

@ -20,14 +20,14 @@ namespace Composer\Package\Archiver;
class PharArchiver implements ArchiverInterface class PharArchiver implements ArchiverInterface
{ {
protected static $formats = array( protected static $formats = array(
'zip' => \Phar::ZIP, 'zip' => \Phar::ZIP,
'tar' => \Phar::TAR, 'tar' => \Phar::TAR,
'tar.gz' => \Phar::TAR, 'tar.gz' => \Phar::TAR,
'tar.bz2' => \Phar::TAR, 'tar.bz2' => \Phar::TAR,
); );
protected static $compressFormats = array( protected static $compressFormats = array(
'tar.gz' => \Phar::GZ, 'tar.gz' => \Phar::GZ,
'tar.bz2' => \Phar::BZ2, 'tar.bz2' => \Phar::BZ2,
); );

View File

@ -23,25 +23,25 @@ use Composer\Repository\PlatformRepository;
abstract class BasePackage implements PackageInterface abstract class BasePackage implements PackageInterface
{ {
public static $supportedLinkTypes = array( public static $supportedLinkTypes = array(
'require' => array('description' => 'requires', 'method' => 'requires'), 'require' => array('description' => 'requires', 'method' => 'requires'),
'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'), 'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'),
'provide' => array('description' => 'provides', 'method' => 'provides'), 'provide' => array('description' => 'provides', 'method' => 'provides'),
'replace' => array('description' => 'replaces', 'method' => 'replaces'), 'replace' => array('description' => 'replaces', 'method' => 'replaces'),
'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'), 'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'),
); );
const STABILITY_STABLE = 0; const STABILITY_STABLE = 0;
const STABILITY_RC = 5; const STABILITY_RC = 5;
const STABILITY_BETA = 10; const STABILITY_BETA = 10;
const STABILITY_ALPHA = 15; const STABILITY_ALPHA = 15;
const STABILITY_DEV = 20; const STABILITY_DEV = 20;
public static $stabilities = array( public static $stabilities = array(
'stable' => self::STABILITY_STABLE, 'stable' => self::STABILITY_STABLE,
'RC' => self::STABILITY_RC, 'RC' => self::STABILITY_RC,
'beta' => self::STABILITY_BETA, 'beta' => self::STABILITY_BETA,
'alpha' => self::STABILITY_ALPHA, 'alpha' => self::STABILITY_ALPHA,
'dev' => self::STABILITY_DEV, 'dev' => self::STABILITY_DEV,
); );
/** /**

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

@ -133,7 +133,7 @@ class ArrayDumper
} }
$getter = 'get'.ucfirst($method); $getter = 'get'.ucfirst($method);
$value = $package->$getter(); $value = $package->$getter();
if (null !== $value && !(is_array($value) && 0 === count($value))) { if (null !== $value && !(is_array($value) && 0 === count($value))) {
$data[$key] = $value; $data[$key] = $value;

View File

@ -73,7 +73,7 @@ class RootPackageLoader extends ArrayLoader
$version = getenv('COMPOSER_ROOT_VERSION'); $version = getenv('COMPOSER_ROOT_VERSION');
$commit = null; $commit = null;
} else { } else {
$versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd()); $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
$version = $versionData['version']; $version = $versionData['version'];
$commit = $versionData['commit']; $commit = $versionData['commit'];
} }

View File

@ -355,7 +355,7 @@ class Locker
continue; continue;
} }
$name = $package->getPrettyName(); $name = $package->getPrettyName();
$version = $package->getPrettyVersion(); $version = $package->getPrettyVersion();
if (!$name || !$version) { if (!$name || !$version) {

View File

@ -232,7 +232,7 @@ class PluginManager
public function addPlugin(PluginInterface $plugin) public function addPlugin(PluginInterface $plugin)
{ {
$this->io->writeError('Loading plugin '.get_class($plugin), true, IOInterface::DEBUG); $this->io->writeError('Loading plugin '.get_class($plugin), true, IOInterface::DEBUG);
$this->plugins[] = $plugin; $this->plugins[] = $plugin;
$plugin->activate($this->composer, $this->io); $plugin->activate($this->composer, $this->io);
if ($plugin instanceof EventSubscriberInterface) { 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 * @param string $capabilityClassName The fully qualified name of the API interface which the plugin may provide
* an implementation of. * an implementation of.
* @param array $ctorArgs Arguments passed to Capability's constructor. * @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. * Keeping it an array will allow future values to be passed w\o changing the signature.
* @return Capability[] * @return Capability[]
*/ */
public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array()) public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())

View File

@ -266,7 +266,7 @@ class PlatformRepository extends ArrayRepository
/** /**
* Parses the version and adds a new package to the repository * Parses the version and adds a new package to the repository
* *
* @param string $name * @param string $name
* @param null|string $prettyVersion * @param null|string $prettyVersion
*/ */
private function addExtension($name, $prettyVersion) private function addExtension($name, $prettyVersion)

View File

@ -65,8 +65,8 @@ interface RepositoryInterface extends \Countable
/** /**
* Searches the repository for packages containing the query * Searches the repository for packages containing the query
* *
* @param string $query search 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 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' => '...') * @return \array[] an array of array('name' => '...', 'description' => '...')
*/ */

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,
'&' '&'
@ -338,8 +339,8 @@ abstract class BitbucketDriver extends VcsDriver
/** /**
* Get the remote content. * Get the remote content.
* *
* @param string $url The URL of content * @param string $url The URL of content
* @param bool $fetchingRepoData * @param bool $fetchingRepoData
* *
* @return mixed The result * @return mixed The result
*/ */
@ -389,13 +390,13 @@ abstract class BitbucketDriver extends VcsDriver
} }
/** /**
* @param string $url * @param string $url
* @return void * @return void
*/ */
abstract protected function setupFallbackDriver($url); abstract protected function setupFallbackDriver($url);
/** /**
* @param array $cloneLinks * @param array $cloneLinks
* @return void * @return void
*/ */
protected function parseCloneUrls(array $cloneLinks) protected function parseCloneUrls(array $cloneLinks)

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;
} }
@ -214,5 +213,5 @@ class FossilDriver extends VcsDriver
} }
return false; return false;
} }
} }

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}
*/ */
@ -247,7 +247,7 @@ class GitLabDriver extends VcsDriver
/** /**
* Urlencode all non alphanumeric characters. rawurlencode() can not be used as it does not encode `.` * Urlencode all non alphanumeric characters. rawurlencode() can not be used as it does not encode `.`
* *
* @param string $string * @param string $string
* @return string * @return string
*/ */
private function urlEncodeAll($string) private function urlEncodeAll($string)
@ -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}
*/ */
@ -116,10 +116,10 @@ class PerforceDriver extends VcsDriver
public function getSource($identifier) public function getSource($identifier)
{ {
$source = array( $source = array(
'type' => 'perforce', 'type' => 'perforce',
'url' => $this->repoConfig['url'], 'url' => $this->repoConfig['url'],
'reference' => $identifier, 'reference' => $identifier,
'p4user' => $this->perforce->getUser(), 'p4user' => $this->perforce->getUser(),
); );
return $source; return $source;

View File

@ -37,10 +37,10 @@ class SvnDriver extends VcsDriver
protected $rootIdentifier; protected $rootIdentifier;
protected $infoCache = array(); protected $infoCache = array();
protected $trunkPath = 'trunk'; protected $trunkPath = 'trunk';
protected $branchesPath = 'branches'; protected $branchesPath = 'branches';
protected $tagsPath = 'tags'; protected $tagsPath = 'tags';
protected $packagePath = ''; protected $packagePath = '';
protected $cacheCredentials = true; protected $cacheCredentials = true;
/** /**
@ -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

@ -75,8 +75,8 @@ 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

@ -36,8 +36,8 @@ interface VcsDriverInterface
/** /**
* Return the content of $file or null if the file does not exist. * Return the content of $file or null if the file does not exist.
* *
* @param string $file * @param string $file
* @param string $identifier * @param string $identifier
* @return string * @return string
*/ */
public function getFileContent($file, $identifier); public function getFileContent($file, $identifier);
@ -45,7 +45,7 @@ interface VcsDriverInterface
/** /**
* Get the changedate for $identifier. * Get the changedate for $identifier.
* *
* @param string $identifier * @param string $identifier
* @return \DateTime * @return \DateTime
*/ */
public function getChangeDate($identifier); public function getChangeDate($identifier);

View File

@ -46,16 +46,16 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
{ {
parent::__construct(); parent::__construct();
$this->drivers = $drivers ?: array( $this->drivers = $drivers ?: array(
'github' => 'Composer\Repository\Vcs\GitHubDriver', 'github' => 'Composer\Repository\Vcs\GitHubDriver',
'gitlab' => 'Composer\Repository\Vcs\GitLabDriver', 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver', 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
'git' => 'Composer\Repository\Vcs\GitDriver', 'git' => 'Composer\Repository\Vcs\GitDriver',
'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver', 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
'hg' => 'Composer\Repository\Vcs\HgDriver', 'hg' => 'Composer\Repository\Vcs\HgDriver',
'perforce' => 'Composer\Repository\Vcs\PerforceDriver', 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
'fossil' => 'Composer\Repository\Vcs\FossilDriver', 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
// svn must be last because identifying a subversion server for sure is practically impossible // 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']; $this->url = $repoConfig['url'];

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,14 +214,14 @@ 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);
} }
/** /**
* @param string $originUrl * @param string $originUrl
* @return bool * @return bool
*/ */
private function getTokenFromConfig($originUrl) private function getTokenFromConfig($originUrl)
@ -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

@ -125,7 +125,7 @@ class NoProxyPattern
list($a, $b, $c, $d) = explode('.', $base); list($a, $b, $c, $d) = explode('.', $base);
// Now do some bit shifting/switching to convert to ints // 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)); $mask = $bits == 0 ? 0 : (~0 << (32 - $bits));
// Here's our lowest int // Here's our lowest int

View File

@ -285,7 +285,7 @@ class Perforce
public function isLoggedIn() public function isLoggedIn()
{ {
$command = $this->generateP4Command('login -s', false); $command = $this->generateP4Command('login -s', false);
$exitCode = $this->executeCommand($command); $exitCode = $this->executeCommand($command);
if ($exitCode) { if ($exitCode) {
$errorOutput = $this->process->getErrorOutput(); $errorOutput = $this->process->getErrorOutput();
$index = strpos($errorOutput, $this->getUser()); $index = strpos($errorOutput, $this->getUser());
@ -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

@ -22,7 +22,7 @@ class Platform
/** /**
* Parses tildes and environment variables in paths. * Parses tildes and environment variables in paths.
* *
* @param string $path * @param string $path
* @return string * @return string
*/ */
public static function expandPath($path) public static function expandPath($path)
@ -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'];
} }
@ -71,7 +74,7 @@ class Platform
/** /**
* @param string $str * @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) public static function strlen($str)
{ {

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

@ -72,7 +72,7 @@ class Svn
public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null) public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
{ {
$this->url = $url; $this->url = $url;
$this->io = $io; $this->io = $io;
$this->config = $config; $this->config = $config;
$this->process = $process ?: new ProcessExecutor; $this->process = $process ?: new ProcessExecutor;
} }

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;
/** /**
@ -137,12 +136,12 @@ final class TlsHelper
public static function getCertificateFingerprint($certificate) public static function getCertificateFingerprint($certificate)
{ {
$pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate)); $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
$pubkeypem = $pubkeydetails['key']; $pubkeypem = $pubkeydetails['key'];
//Convert PEM to DER before SHA1'ing //Convert PEM to DER before SHA1'ing
$start = '-----BEGIN PUBLIC KEY-----'; $start = '-----BEGIN PUBLIC KEY-----';
$end = '-----END PUBLIC KEY-----'; $end = '-----END PUBLIC KEY-----';
$pemtrim = substr($pubkeypem, (strpos($pubkeypem, $start) + strlen($start)), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1)); $pemtrim = substr($pubkeypem, (strpos($pubkeypem, $start) + strlen($start)), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
$der = base64_decode($pemtrim); $der = base64_decode($pemtrim);
return sha1($der); return sha1($der);
} }

View File

@ -67,6 +67,7 @@ class XdebugHandler
$command = $this->getCommand(); $command = $this->getCommand();
$this->restart($command); $this->restart($command);
} }
return; return;
} }
@ -199,8 +200,8 @@ class XdebugHandler
/** /**
* Returns true if the restart environment variables were set * Returns true if the restart environment variables were set
* *
* @param bool $additional Whether there were additional inis * @param bool $additional Whether there were additional inis
* @param array $iniPaths Locations used by the current prcoess * @param array $iniPaths Locations used by the current prcoess
* *
* @return bool * @return bool
*/ */
@ -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');
} }
@ -262,8 +263,8 @@ class XdebugHandler
* From https://github.com/johnstevenson/winbox-args * From https://github.com/johnstevenson/winbox-args
* MIT Licensed (c) John Stevenson <john-stevenson@blueyonder.co.uk> * MIT Licensed (c) John Stevenson <john-stevenson@blueyonder.co.uk>
* *
* @param string $arg The argument to be escaped * @param string $arg The argument to be escaped
* @param bool $meta Additionally escape cmd.exe meta characters * @param bool $meta Additionally escape cmd.exe meta characters
* *
* @return string The escaped argument * @return string The escaped argument
*/ */

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

@ -24,7 +24,7 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
* *
* @dataProvider getLoadClassTests * @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) public function testLoadClass($class)
{ {

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;
@ -41,31 +40,31 @@ class InitCommandTest extends TestCase
$this->assertEquals('h4x0r', $author['name']); $this->assertEquals('h4x0r', $author['name']);
$this->assertEquals('h4x@example.com', $author['email']); $this->assertEquals('h4x@example.com', $author['email']);
} }
/** /**
* Test scenario for issue #5631 * Test scenario for issue #5631
* @link https://github.com/composer/composer/issues/5631 Issue #5631 * @link https://github.com/composer/composer/issues/5631 Issue #5631
*/ */
public function testParseValidAlias1AuthorString() public function testParseValidAlias1AuthorString()
{ {
$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']);
} }
/** /**
* Test scenario for issue #5631 * Test scenario for issue #5631
* @link https://github.com/composer/composer/issues/5631 Issue #5631 * @link https://github.com/composer/composer/issues/5631 Issue #5631
*/ */
public function testParseValidAlias2AuthorString() public function testParseValidAlias2AuthorString()
{ {
$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']);
} }
public function testParseEmptyAuthorString() public function testParseEmptyAuthorString()

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);
@ -101,7 +100,7 @@ class RunScriptCommandTest extends TestCase
private function createComposerInstance() private function createComposerInstance()
{ {
$composer = new Composer; $composer = new Composer;
$config = new Config; $config = new Config;
$composer->setConfig($config); $composer->setConfig($config);
return $composer; return $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

@ -850,14 +850,14 @@ class SolverTest extends TestCase
foreach ($transaction as $operation) { foreach ($transaction as $operation) {
if ('update' === $operation->getJobType()) { if ('update' === $operation->getJobType()) {
$result[] = array( $result[] = array(
'job' => 'update', 'job' => 'update',
'from' => $operation->getInitialPackage(), 'from' => $operation->getInitialPackage(),
'to' => $operation->getTargetPackage(), 'to' => $operation->getTargetPackage(),
); );
} else { } else {
$job = ('uninstall' === $operation->getJobType() ? 'remove' : 'install'); $job = ('uninstall' === $operation->getJobType() ? 'remove' : 'install');
$result[] = array( $result[] = array(
'job' => $job, 'job' => $job,
'package' => $operation->getPackage(), 'package' => $operation->getPackage(),
); );
} }

View File

@ -28,7 +28,7 @@ class DownloadManagerTest extends \PHPUnit_Framework_TestCase
public function testSetGetDownloader() public function testSetGetDownloader()
{ {
$downloader = $this->createDownloaderMock(); $downloader = $this->createDownloaderMock();
$manager = new DownloadManager($this->io, false, $this->filesystem); $manager = new DownloadManager($this->io, false, $this->filesystem);
$manager->setDownloader('test', $downloader); $manager->setDownloader('test', $downloader);
$this->assertSame($downloader, $manager->getDownloader('test')); $this->assertSame($downloader, $manager->getDownloader('test'));

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

@ -36,23 +36,23 @@ class PerforceDownloaderTest extends TestCase
protected function setUp() protected function setUp()
{ {
$this->testPath = $this->getUniqueTmpDirectory(); $this->testPath = $this->getUniqueTmpDirectory();
$this->repoConfig = $this->getRepoConfig(); $this->repoConfig = $this->getRepoConfig();
$this->config = $this->getConfig(); $this->config = $this->getConfig();
$this->io = $this->getMockIoInterface(); $this->io = $this->getMockIoInterface();
$this->processExecutor = $this->getMockProcessExecutor(); $this->processExecutor = $this->getMockProcessExecutor();
$this->repository = $this->getMockRepository($this->repoConfig, $this->io, $this->config); $this->repository = $this->getMockRepository($this->repoConfig, $this->io, $this->config);
$this->package = $this->getMockPackageInterface($this->repository); $this->package = $this->getMockPackageInterface($this->repository);
$this->downloader = new PerforceDownloader($this->io, $this->config, $this->processExecutor); $this->downloader = new PerforceDownloader($this->io, $this->config, $this->processExecutor);
} }
protected function tearDown() protected function tearDown()
{ {
$this->downloader = null; $this->downloader = null;
$this->package = null; $this->package = null;
$this->repository = null; $this->repository = null;
$this->io = null; $this->io = null;
$this->config = null; $this->config = null;
$this->repoConfig = null; $this->repoConfig = null;
if (is_dir($this->testPath)) { if (is_dir($this->testPath)) {
$fs = new Filesystem; $fs = new Filesystem;

View File

@ -35,7 +35,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
return $arg === 'vendor'; return $arg === 'vendor';
})); }));
$manager = new InstallationManager(); $manager = new InstallationManager();
$manager->addInstaller($installer); $manager->addInstaller($installer);
$this->assertSame($installer, $manager->getInstaller('vendor')); $this->assertSame($installer, $manager->getInstaller('vendor'));
@ -64,7 +64,7 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
return $arg === 'vendor'; return $arg === 'vendor';
})); }));
$manager = new InstallationManager(); $manager = new InstallationManager();
$manager->addInstaller($installer); $manager->addInstaller($installer);
$this->assertSame($installer, $manager->getInstaller('vendor')); $this->assertSame($installer, $manager->getInstaller('vendor'));
@ -81,8 +81,8 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
->getMock(); ->getMock();
$installOperation = new InstallOperation($this->createPackageMock()); $installOperation = new InstallOperation($this->createPackageMock());
$removeOperation = new UninstallOperation($this->createPackageMock()); $removeOperation = new UninstallOperation($this->createPackageMock());
$updateOperation = new UpdateOperation( $updateOperation = new UpdateOperation(
$this->createPackageMock(), $this->createPackageMock() $this->createPackageMock(), $this->createPackageMock()
); );
@ -107,10 +107,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
public function testInstall() public function testInstall()
{ {
$installer = $this->createInstallerMock(); $installer = $this->createInstallerMock();
$manager = new InstallationManager(); $manager = new InstallationManager();
$manager->addInstaller($installer); $manager->addInstaller($installer);
$package = $this->createPackageMock(); $package = $this->createPackageMock();
$operation = new InstallOperation($package, 'test'); $operation = new InstallOperation($package, 'test');
$package $package
@ -135,11 +135,11 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
public function testUpdateWithEqualTypes() public function testUpdateWithEqualTypes()
{ {
$installer = $this->createInstallerMock(); $installer = $this->createInstallerMock();
$manager = new InstallationManager(); $manager = new InstallationManager();
$manager->addInstaller($installer); $manager->addInstaller($installer);
$initial = $this->createPackageMock(); $initial = $this->createPackageMock();
$target = $this->createPackageMock(); $target = $this->createPackageMock();
$operation = new UpdateOperation($initial, $target, 'test'); $operation = new UpdateOperation($initial, $target, 'test');
$initial $initial
@ -169,12 +169,12 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
{ {
$libInstaller = $this->createInstallerMock(); $libInstaller = $this->createInstallerMock();
$bundleInstaller = $this->createInstallerMock(); $bundleInstaller = $this->createInstallerMock();
$manager = new InstallationManager(); $manager = new InstallationManager();
$manager->addInstaller($libInstaller); $manager->addInstaller($libInstaller);
$manager->addInstaller($bundleInstaller); $manager->addInstaller($bundleInstaller);
$initial = $this->createPackageMock(); $initial = $this->createPackageMock();
$target = $this->createPackageMock(); $target = $this->createPackageMock();
$operation = new UpdateOperation($initial, $target, 'test'); $operation = new UpdateOperation($initial, $target, 'test');
$initial $initial
@ -215,10 +215,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
public function testUninstall() public function testUninstall()
{ {
$installer = $this->createInstallerMock(); $installer = $this->createInstallerMock();
$manager = new InstallationManager(); $manager = new InstallationManager();
$manager->addInstaller($installer); $manager->addInstaller($installer);
$package = $this->createPackageMock(); $package = $this->createPackageMock();
$operation = new UninstallOperation($package, 'test'); $operation = new UninstallOperation($package, 'test');
$package $package
@ -245,10 +245,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
$installer = $this->getMockBuilder('Composer\Installer\LibraryInstaller') $installer = $this->getMockBuilder('Composer\Installer\LibraryInstaller')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$manager = new InstallationManager(); $manager = new InstallationManager();
$manager->addInstaller($installer); $manager->addInstaller($installer);
$package = $this->createPackageMock(); $package = $this->createPackageMock();
$package $package
->expects($this->once()) ->expects($this->once())

View File

@ -140,7 +140,7 @@ class LibraryInstallerTest extends TestCase
->with($this->vendorDir.'/package1/oldtarget', $this->vendorDir.'/package1/newtarget'); ->with($this->vendorDir.'/package1/oldtarget', $this->vendorDir.'/package1/newtarget');
$initial = $this->createPackageMock(); $initial = $this->createPackageMock();
$target = $this->createPackageMock(); $target = $this->createPackageMock();
$initial $initial
->expects($this->any()) ->expects($this->any())

View File

@ -44,7 +44,7 @@ class MetapackageInstallerTest extends \PHPUnit_Framework_TestCase
public function testUpdate() public function testUpdate()
{ {
$initial = $this->createPackageMock(); $initial = $this->createPackageMock();
$target = $this->createPackageMock(); $target = $this->createPackageMock();
$this->repository $this->repository
->expects($this->exactly(2)) ->expects($this->exactly(2))

View File

@ -82,8 +82,8 @@ class InstallerTest extends TestCase
$result = $installer->run(); $result = $installer->run();
$this->assertSame(0, $result); $this->assertSame(0, $result);
$expectedInstalled = isset($options['install']) ? $options['install'] : array(); $expectedInstalled = isset($options['install']) ? $options['install'] : array();
$expectedUpdated = isset($options['update']) ? $options['update'] : array(); $expectedUpdated = isset($options['update']) ? $options['update'] : array();
$expectedUninstalled = isset($options['uninstall']) ? $options['uninstall'] : array(); $expectedUninstalled = isset($options['uninstall']) ? $options['uninstall'] : array();
$installed = $installationManager->getInstalledPackages(); $installed = $installationManager->getInstalledPackages();
@ -198,7 +198,7 @@ class InstallerTest extends TestCase
} }
$contents = json_encode($composerConfig); $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); $composer->setLocker($locker);
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(); $eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
@ -345,7 +345,7 @@ class InstallerTest extends TestCase
'CONDITION' => false, 'CONDITION' => false,
'COMPOSER' => true, 'COMPOSER' => true,
'LOCK' => false, 'LOCK' => false,
'INSTALLED' => false, 'INSTALLED' => false,
'RUN' => true, 'RUN' => true,
'EXPECT-LOCK' => false, 'EXPECT-LOCK' => false,
'EXPECT-OUTPUT' => false, 'EXPECT-OUTPUT' => false,

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

@ -37,8 +37,8 @@ abstract class ArchiverTest extends TestCase
public function setUp() public function setUp()
{ {
$this->filesystem = new Filesystem(); $this->filesystem = new Filesystem();
$this->process = new ProcessExecutor(); $this->process = new ProcessExecutor();
$this->testDir = $this->getUniqueTmpDirectory(); $this->testDir = $this->getUniqueTmpDirectory();
} }
public function tearDown() public function tearDown()

View File

@ -21,7 +21,7 @@ class PharArchiverTest extends ArchiverTest
// Set up repository // Set up repository
$this->setupDummyRepo(); $this->setupDummyRepo();
$package = $this->setupPackage(); $package = $this->setupPackage();
$target = $this->getUniqueTmpDirectory().'/composer_archiver_test.tar'; $target = $this->getUniqueTmpDirectory().'/composer_archiver_test.tar';
// Test archive // Test archive
$archiver = new PharArchiver(); $archiver = new PharArchiver();
@ -36,7 +36,7 @@ class PharArchiverTest extends ArchiverTest
// Set up repository // Set up repository
$this->setupDummyRepo(); $this->setupDummyRepo();
$package = $this->setupPackage(); $package = $this->setupPackage();
$target = $this->getUniqueTmpDirectory().'/composer_archiver_test.zip'; $target = $this->getUniqueTmpDirectory().'/composer_archiver_test.zip';
// Test archive // Test archive
$archiver = new PharArchiver(); $archiver = new PharArchiver();

View File

@ -25,7 +25,7 @@ class ZipArchiverTest extends ArchiverTest
// Set up repository // Set up repository
$this->setupDummyRepo(); $this->setupDummyRepo();
$package = $this->setupPackage(); $package = $this->setupPackage();
$target = sys_get_temp_dir().'/composer_archiver_test.zip'; $target = sys_get_temp_dir().'/composer_archiver_test.zip';
// Test archive // Test archive
$archiver = new ZipArchiver(); $archiver = new ZipArchiver();

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

@ -19,7 +19,7 @@ class LockerTest extends \PHPUnit_Framework_TestCase
{ {
public function testIsLocked() public function testIsLocked()
{ {
$json = $this->createJsonFileMock(); $json = $this->createJsonFileMock();
$locker = new Locker(new NullIO, $json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), $locker = new Locker(new NullIO, $json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(),
$this->getJsonContent()); $this->getJsonContent());

View File

@ -243,7 +243,7 @@ class PluginInstallerTest extends TestCase
->expects($this->any()) ->expects($this->any())
->method('getPackages') ->method('getPackages')
->will($this->returnCallback(function () use ($plugApiInternalPackage, $plugins) { ->will($this->returnCallback(function () use ($plugApiInternalPackage, $plugins) {
return array_merge(array($plugApiInternalPackage), $plugins); return array_merge(array($plugApiInternalPackage), $plugins);
})); }));
$this->pm->loadInstalledPlugins(); $this->pm->loadInstalledPlugins();

View File

@ -89,7 +89,7 @@ class ComposerRepositoryTest extends TestCase
), ),
array('packages' => array( array('packages' => array(
'bar/foo' => 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'), '3.145' => array('name' => 'bar/foo', 'version' => '3.145'),
), ),
)), )),
@ -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

@ -58,7 +58,7 @@ class GitBitbucketDriverTest extends TestCase
} }
/** /**
* @param array $repoConfig * @param array $repoConfig
* @return GitBitbucketDriver * @return GitBitbucketDriver
*/ */
private function getDriver(array $repoConfig) private function getDriver(array $repoConfig)
@ -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

@ -87,7 +87,7 @@ JSON;
->shouldBeCalledTimes(1) ->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(); $driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
@ -126,7 +126,7 @@ JSON;
->shouldBeCalledTimes(1) ->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(); $driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
@ -257,7 +257,7 @@ JSON;
$expected = array( $expected = array(
'mymaster' => '97eda36b5c1dd953a3792865c222d4e85e5f302e', 'mymaster' => '97eda36b5c1dd953a3792865c222d4e85e5f302e',
'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd', 'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd',
); );
$this->assertEquals($expected, $driver->getBranches()); $this->assertEquals($expected, $driver->getBranches());
@ -315,7 +315,7 @@ JSON;
->shouldBeCalledTimes(1) ->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(); $driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL'); $this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');

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

@ -32,19 +32,19 @@ class PerforceDriverTest extends TestCase
protected $repoConfig; protected $repoConfig;
protected $perforce; protected $perforce;
const TEST_URL = 'TEST_PERFORCE_URL'; const TEST_URL = 'TEST_PERFORCE_URL';
const TEST_DEPOT = 'TEST_DEPOT_CONFIG'; const TEST_DEPOT = 'TEST_DEPOT_CONFIG';
const TEST_BRANCH = 'TEST_BRANCH_CONFIG'; const TEST_BRANCH = 'TEST_BRANCH_CONFIG';
protected function setUp() protected function setUp()
{ {
$this->testPath = $this->getUniqueTmpDirectory(); $this->testPath = $this->getUniqueTmpDirectory();
$this->config = $this->getTestConfig($this->testPath); $this->config = $this->getTestConfig($this->testPath);
$this->repoConfig = $this->getTestRepoConfig(); $this->repoConfig = $this->getTestRepoConfig();
$this->io = $this->getMockIOInterface(); $this->io = $this->getMockIOInterface();
$this->process = $this->getMockProcessExecutor(); $this->process = $this->getMockProcessExecutor();
$this->remoteFileSystem = $this->getMockRemoteFilesystem(); $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->driver = new PerforceDriver($this->repoConfig, $this->io, $this->config, $this->process, $this->remoteFileSystem);
$this->overrideDriverInternalPerforce($this->perforce); $this->overrideDriverInternalPerforce($this->perforce);
} }
@ -54,14 +54,14 @@ class PerforceDriverTest extends TestCase
//cleanup directory under test path //cleanup directory under test path
$fs = new Filesystem; $fs = new Filesystem;
$fs->removeDirectory($this->testPath); $fs->removeDirectory($this->testPath);
$this->driver = null; $this->driver = null;
$this->perforce = null; $this->perforce = null;
$this->remoteFileSystem = null; $this->remoteFileSystem = null;
$this->process = null; $this->process = null;
$this->io = null; $this->io = null;
$this->repoConfig = null; $this->repoConfig = null;
$this->config = null; $this->config = null;
$this->testPath = null; $this->testPath = null;
} }
protected function overrideDriverInternalPerforce(Perforce $perforce) protected function overrideDriverInternalPerforce(Perforce $perforce)
@ -83,8 +83,8 @@ class PerforceDriverTest extends TestCase
protected function getTestRepoConfig() protected function getTestRepoConfig()
{ {
return array( return array(
'url' => self::TEST_URL, 'url' => self::TEST_URL,
'depot' => self::TEST_DEPOT, 'depot' => self::TEST_DEPOT,
'branch' => self::TEST_BRANCH, 'branch' => self::TEST_BRANCH,
); );
} }

View File

@ -47,7 +47,7 @@ class SvnDriverTest extends TestCase
{ {
$console = $this->getMock('Composer\IO\IOInterface'); $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 .= " authorization failed: Could not authenticate to server:";
$output .= " rejected Basic challenge (https://corp.svn.local/)"; $output .= " rejected Basic challenge (https://corp.svn.local/)";

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

@ -229,7 +229,7 @@ class FilesystemTest extends TestCase
*/ */
public function testUnlinkSymlinkedDirectory() public function testUnlinkSymlinkedDirectory()
{ {
$basepath = $this->workingDir; $basepath = $this->workingDir;
$symlinked = $basepath . "/linked"; $symlinked = $basepath . "/linked";
@mkdir($basepath . "/real", 0777, true); @mkdir($basepath . "/real", 0777, true);
touch($basepath . "/real/FILE"); 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).'); $this->fail('Precondition assertion failed (is_dir is false on symbolic link to directory).');
} }
$fs = new Filesystem(); $fs = new Filesystem();
$result = $fs->unlink($symlinked); $result = $fs->unlink($symlinked);
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFalse(file_exists($symlinked)); $this->assertFalse(file_exists($symlinked));
@ -258,7 +258,7 @@ class FilesystemTest extends TestCase
{ {
@mkdir($this->workingDir . "/real", 0777, true); @mkdir($this->workingDir . "/real", 0777, true);
touch($this->workingDir . "/real/FILE"); touch($this->workingDir . "/real/FILE");
$symlinked = $this->workingDir . "/linked"; $symlinked = $this->workingDir . "/linked";
$symlinkedTrailingSlash = $symlinked . "/"; $symlinkedTrailingSlash = $symlinked . "/";
$result = @symlink($this->workingDir . "/real", $symlinked); $result = @symlink($this->workingDir . "/real", $symlinked);

View File

@ -24,12 +24,12 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
protected $processExecutor; protected $processExecutor;
protected $io; protected $io;
const TEST_DEPOT = 'depot'; const TEST_DEPOT = 'depot';
const TEST_BRANCH = 'branch'; const TEST_BRANCH = 'branch';
const TEST_P4USER = 'user'; const TEST_P4USER = 'user';
const TEST_CLIENT_NAME = 'TEST'; const TEST_CLIENT_NAME = 'TEST';
const TEST_PORT = 'port'; const TEST_PORT = 'port';
const TEST_PATH = 'path'; const TEST_PATH = 'path';
protected function setUp() protected function setUp()
{ {
@ -41,18 +41,18 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
protected function tearDown() protected function tearDown()
{ {
$this->perforce = null; $this->perforce = null;
$this->io = null; $this->io = null;
$this->repoConfig = null; $this->repoConfig = null;
$this->processExecutor = null; $this->processExecutor = null;
} }
public function getTestRepoConfig() public function getTestRepoConfig()
{ {
return array( return array(
'depot' => self::TEST_DEPOT, 'depot' => self::TEST_DEPOT,
'branch' => self::TEST_BRANCH, 'branch' => self::TEST_BRANCH,
'p4user' => self::TEST_P4USER, 'p4user' => self::TEST_P4USER,
'unique_perforce_client_name' => self::TEST_CLIENT_NAME, 'unique_perforce_client_name' => self::TEST_CLIENT_NAME,
); );
} }
@ -140,10 +140,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->perforce->setUser(null); $this->perforce->setUser(null);
$expectedCommand = 'p4 set'; $expectedCommand = 'p4 set';
$callback = function ($command, &$output) { $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
@ -158,10 +158,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->perforce->setUser(null); $this->perforce->setUser(null);
$expectedCommand = 'echo $P4USER'; $expectedCommand = 'echo $P4USER';
$callback = function ($command, &$output) { $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
@ -187,7 +187,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->createNewPerforceWithWindowsFlag(true); $this->createNewPerforceWithWindowsFlag(true);
$this->perforce->setUser(null); $this->perforce->setUser(null);
$expectedQuestion = 'Enter P4 User:'; $expectedQuestion = 'Enter P4 User:';
$expectedCommand = 'p4 set P4USER=TEST_QUERY_USER'; $expectedCommand = 'p4 set P4USER=TEST_QUERY_USER';
$this->io->expects($this->at(0)) $this->io->expects($this->at(0))
->method('ask') ->method('ask')
->with($this->equalTo($expectedQuestion)) ->with($this->equalTo($expectedQuestion))
@ -204,7 +204,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->createNewPerforceWithWindowsFlag(false); $this->createNewPerforceWithWindowsFlag(false);
$this->perforce->setUser(null); $this->perforce->setUser(null);
$expectedQuestion = 'Enter P4 User:'; $expectedQuestion = 'Enter P4 User:';
$expectedCommand = 'export P4USER=TEST_QUERY_USER'; $expectedCommand = 'export P4USER=TEST_QUERY_USER';
$this->io->expects($this->at(0)) $this->io->expects($this->at(0))
->method('ask') ->method('ask')
->with($this->equalTo($expectedQuestion)) ->with($this->equalTo($expectedQuestion))
@ -219,9 +219,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testQueryP4PasswordWithPasswordAlreadySet() public function testQueryP4PasswordWithPasswordAlreadySet()
{ {
$repoConfig = array( $repoConfig = array(
'depot' => 'depot', 'depot' => 'depot',
'branch' => 'branch', 'branch' => 'branch',
'p4user' => 'user', 'p4user' => 'user',
'p4password' => 'TEST_PASSWORD', 'p4password' => 'TEST_PASSWORD',
); );
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, $this->getMockIOInterface(), 'TEST'); $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); $this->createNewPerforceWithWindowsFlag(true);
$expectedCommand = 'p4 set'; $expectedCommand = 'p4 set';
$callback = function ($command, &$output) { $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
@ -251,10 +251,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->createNewPerforceWithWindowsFlag(false); $this->createNewPerforceWithWindowsFlag(false);
$expectedCommand = 'echo $P4PASSWD'; $expectedCommand = 'echo $P4PASSWD';
$callback = function ($command, &$output) { $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
@ -358,10 +358,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
); );
$expectedCommand2 = 'p4 -u user -p port changes //depot/branch/...'; $expectedCommand2 = 'p4 -u user -p port changes //depot/branch/...';
$expectedCallback = function ($command, &$output) { $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)) $this->processExecutor->expects($this->at(1))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand2)) ->with($this->equalTo($expectedCommand2))
@ -375,10 +375,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$expectedCommand = 'p4 -u user -p port changes //depot/...'; $expectedCommand = 'p4 -u user -p port changes //depot/...';
$expectedCallback = function ($command, &$output) { $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()) $this->processExecutor->expects($this->once())
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
@ -473,10 +473,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$result = $this->perforce->getComposerInformation('//depot'); $result = $this->perforce->getComposerInformation('//depot');
$expected = array( $expected = array(
'name' => 'test/perforce', 'name' => 'test/perforce',
'description' => 'Basic project for testing', 'description' => 'Basic project for testing',
'minimum-stability' => 'dev', 'minimum-stability' => 'dev',
'autoload' => array('psr-0' => array()), 'autoload' => array('psr-0' => array()),
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -514,10 +514,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$result = $this->perforce->getComposerInformation('//depot@0.0.1'); $result = $this->perforce->getComposerInformation('//depot@0.0.1');
$expected = array( $expected = array(
'name' => 'test/perforce', 'name' => 'test/perforce',
'description' => 'Basic project for testing', 'description' => 'Basic project for testing',
'minimum-stability' => 'dev', 'minimum-stability' => 'dev',
'autoload' => array('psr-0' => array()), 'autoload' => array('psr-0' => array()),
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -543,10 +543,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$result = $this->perforce->getComposerInformation('//depot/branch'); $result = $this->perforce->getComposerInformation('//depot/branch');
$expected = array( $expected = array(
'name' => 'test/perforce', 'name' => 'test/perforce',
'description' => 'Basic project for testing', 'description' => 'Basic project for testing',
'minimum-stability' => 'dev', 'minimum-stability' => 'dev',
'autoload' => array('psr-0' => array()), 'autoload' => array('psr-0' => array()),
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -585,10 +585,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$result = $this->perforce->getComposerInformation('//depot/branch@0.0.1'); $result = $this->perforce->getComposerInformation('//depot/branch@0.0.1');
$expected = array( $expected = array(
'name' => 'test/perforce', 'name' => 'test/perforce',
'description' => 'Basic project for testing', 'description' => 'Basic project for testing',
'minimum-stability' => 'dev', 'minimum-stability' => 'dev',
'autoload' => array('psr-0' => array()), 'autoload' => array('psr-0' => array()),
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }

View File

@ -28,7 +28,7 @@ class PlatformTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath')); $this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath'));
$this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test')); $this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test'));
} }
public function testIsWindows() public function testIsWindows()
{ {
// Compare 2 common tests for Windows to the built-in Windows test // Compare 2 common tests for Windows to the built-in Windows test

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),
), ),
); );
} }