main
Jordi Boggiano 7 years ago
parent 7211eedc36
commit 122e422682

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

@ -66,7 +66,7 @@ class AutoloadGenerator
public function setDevMode($devMode = true)
{
$this->devMode = (boolean) $devMode;
$this->devMode = (bool) $devMode;
}
/**
@ -77,7 +77,7 @@ class AutoloadGenerator
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = (boolean) $classMapAuthoritative;
$this->classMapAuthoritative = (bool) $classMapAuthoritative;
}
/**
@ -87,7 +87,7 @@ class AutoloadGenerator
*/
public function setApcu($apcu)
{
$this->apcu = (boolean) $apcu;
$this->apcu = (bool) $apcu;
}
/**
@ -97,7 +97,7 @@ class AutoloadGenerator
*/
public function setRunScripts($runScripts = true)
{
$this->runScripts = (boolean) $runScripts;
$this->runScripts = (bool) $runScripts;
}
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
@ -543,7 +543,7 @@ EOF;
protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
{
$lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode)-1];
$lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
if ("'" === $lastChar || '"' === $lastChar) {
$vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
} else {

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

@ -45,7 +45,7 @@ class ArchiveCommand extends BaseCommand
new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
.' Note that the format will be appended.'),
new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package')
new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
))
->setHelp(<<<EOT
The <info>archive</info> command creates an archive of the specified format
@ -139,7 +139,9 @@ EOT
if (count($packages) > 1) {
$package = reset($packages);
$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>');
} elseif ($packages) {
$package = reset($packages);

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

@ -167,7 +167,7 @@ EOT
$output = '';
foreach ($messages as $style => $msgs) {
foreach ($msgs as $msg) {
$output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
$output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
}
}
@ -390,6 +390,7 @@ EOT
$io = $this->getIO();
if (true === $result) {
$io->write('<info>OK</info>');
return;
}
@ -590,31 +591,31 @@ EOT
foreach ($warnings as $warning => $current) {
switch ($warning) {
case 'apc_cli':
$text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
$text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
$text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
$text .= " apc.enable_cli = Off";
$displayIniMessage = true;
break;
case 'zlib':
$text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
$text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
$text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
$displayIniMessage = true;
break;
case 'sigchild':
$text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
$text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
$text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
$text .= " https://bugs.php.net/bug.php?id=22999";
break;
case 'curlwrappers':
$text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
$text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
$text .= " Recompile it without this flag if possible";
break;
case 'php':
$text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
$text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
$text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
break;
@ -628,12 +629,12 @@ EOT
break;
case 'xdebug_loaded':
$text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
$text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
$text .= " Disabling it when using Composer is recommended.";
break;
case 'xdebug_profile':
$text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
$text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
$text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
$text .= " xdebug.profiler_enabled = 0";
$displayIniMessage = true;

@ -45,7 +45,9 @@ class ExecCommand extends BaseCommand
$binDir = $composer->getConfig()->get('bin-dir');
if ($input->getOption('list') || !$input->getArgument('binary')) {
$bins = glob($binDir . '/*');
$bins = array_merge($bins, array_map(function($e) { return "$e (local)"; }, $composer->getPackage()->getBinaries()));
$bins = array_merge($bins, array_map(function ($e) {
return "$e (local)";
}, $composer->getPackage()->getBinaries()));
if (!$bins) {
throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");

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

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

@ -185,6 +185,7 @@ EOT
}
$io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
return 1;
}
} else {
@ -314,14 +315,13 @@ EOT
if ($showVersion) {
$versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
if ($showLatest) {
$latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly);
if ($latestPackage === false) {
continue;
}
$latestPackages[$package->getPrettyName()] = $latestPackage;
$latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
$latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
}
}
} else {
@ -464,6 +464,7 @@ EOT
protected function getRootRequires()
{
$rootPackage = $this->getComposer()->getPackage();
return array_map(
'strtolower',
array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
@ -775,7 +776,8 @@ EOT
return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
}
private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package) {
private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
{
if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
return 'up-to-date';
}
@ -806,10 +808,10 @@ EOT
/**
* Given a package, this finds the latest package matching it
*
* @param PackageInterface $package
* @param Composer $composer
* @param string $phpVersion
* @param bool $minorOnly
* @param PackageInterface $package
* @param Composer $composer
* @param string $phpVersion
* @param bool $minorOnly
*
* @return PackageInterface|null
*/

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

@ -416,7 +416,7 @@ class Config
{
if (isset($this->repositories[$name])) {
unset($this->repositories[$name]);
} else if ($name === 'packagist') { // BC support for default "packagist" named repo
} elseif ($name === 'packagist') { // BC support for default "packagist" named repo
unset($this->repositories['packagist.org']);
}
}

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

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

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

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

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

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

@ -59,7 +59,8 @@ class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
$cacheOptions = sprintf('--dissociate --reference %s ', ProcessExecutor::escape($cachePath));
$msg = "Cloning ".$this->getShortHash($ref).' from cache';
}
} catch (\RuntimeException $e) {}
} catch (\RuntimeException $e) {
}
}
$command = 'git clone --no-checkout %s %s '.$cacheOptions.'&& cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer';
$this->io->writeError($msg);

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

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

@ -356,7 +356,7 @@ class EventDispatcher
* Add a listener for a particular event
*
* @param string $eventName The event name - typically a constant
* @param Callable $listener A callable expecting an event argument
* @param callable $listener A callable expecting an event argument
* @param int $priority A higher value represents a higher priority
*/
public function addListener($eventName, $listener, $priority = 0)

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

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

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

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

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

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

@ -94,12 +94,12 @@ class ArchiveManager
/**
* Create an archive of the specified package.
*
* @param PackageInterface $package The package to archive
* @param string $format The format of the archive (zip, tar, ...)
* @param string $targetDir The directory where to build the archive
* @param string|null $fileName The relative file name to use for the archive, or null to generate
* the package name. Note that the format will be appended to this name
* @param boolean $ignoreFilters Ignore filters when looking for files in the package
* @param PackageInterface $package The package to archive
* @param string $format The format of the archive (zip, tar, ...)
* @param string $targetDir The directory where to build the archive
* @param string|null $fileName The relative file name to use for the archive, or null to generate
* the package name. Note that the format will be appended to this name
* @param bool $ignoreFilters Ignore filters when looking for files in the package
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @return string The path of the created archive

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

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

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

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

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

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

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

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

@ -65,8 +65,8 @@ interface RepositoryInterface extends \Countable
/**
* Searches the repository for packages containing the query
*
* @param string $query search query
* @param int $mode a set of SEARCH_* constants to search on, implementations should do a best effort only
* @param string $query search query
* @param int $mode a set of SEARCH_* constants to search on, implementations should do a best effort only
*
* @return \array[] an array of array('name' => '...', 'description' => '...')
*/

@ -56,7 +56,7 @@ abstract class BitbucketDriver extends VcsDriver
$this->config->get('cache-repo-dir'),
$this->originUrl,
$this->owner,
$this->repository
$this->repository,
))
);
}
@ -104,6 +104,7 @@ abstract class BitbucketDriver extends VcsDriver
$this->homeUrl = $repoData['links']['html']['href'];
$this->website = $repoData['website'];
$this->vcsType = $repoData['scm'];
return true;
}
@ -268,7 +269,7 @@ abstract class BitbucketDriver extends VcsDriver
array(
'pagelen' => 100,
'fields' => 'values.name,values.target.hash,next',
'sort' => '-target.date'
'sort' => '-target.date',
),
null,
'&'
@ -312,7 +313,7 @@ abstract class BitbucketDriver extends VcsDriver
array(
'pagelen' => 100,
'fields' => 'values.name,values.target.hash,next',
'sort' => '-target.date'
'sort' => '-target.date',
),
null,
'&'
@ -338,8 +339,8 @@ abstract class BitbucketDriver extends VcsDriver
/**
* Get the remote content.
*
* @param string $url The URL of content
* @param bool $fetchingRepoData
* @param string $url The URL of content
* @param bool $fetchingRepoData
*
* @return mixed The result
*/
@ -389,13 +390,13 @@ abstract class BitbucketDriver extends VcsDriver
}
/**
* @param string $url
* @param string $url
* @return void
*/
abstract protected function setupFallbackDriver($url);
/**
* @param array $cloneLinks
* @param array $cloneLinks
* @return void
*/
protected function parseCloneUrls(array $cloneLinks)

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

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

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

@ -127,6 +127,7 @@ class GitLabDriver extends VcsDriver
if ($e->getCode() !== 404) {
throw $e;
}
return null;
}
@ -149,7 +150,6 @@ class GitLabDriver extends VcsDriver
return new \DateTime();
}
/**
* {@inheritDoc}
*/
@ -247,7 +247,7 @@ class GitLabDriver extends VcsDriver
/**
* Urlencode all non alphanumeric characters. rawurlencode() can not be used as it does not encode `.`
*
* @param string $string
* @param string $string
* @return string
*/
private function urlEncodeAll($string)
@ -260,6 +260,7 @@ class GitLabDriver extends VcsDriver
}
$encoded .= $character;
}
return $encoded;
}

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

@ -26,6 +26,7 @@ class PerforceDriver extends VcsDriver
protected $branch;
/** @var Perforce */
protected $perforce;
/**
* {@inheritDoc}
*/
@ -57,7 +58,6 @@ class PerforceDriver extends VcsDriver
$this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
}
/**
* {@inheritdoc}
*/
@ -116,10 +116,10 @@ class PerforceDriver extends VcsDriver
public function getSource($identifier)
{
$source = array(
'type' => 'perforce',
'url' => $this->repoConfig['url'],
'type' => 'perforce',
'url' => $this->repoConfig['url'],
'reference' => $identifier,
'p4user' => $this->perforce->getUser(),
'p4user' => $this->perforce->getUser(),
);
return $source;

@ -37,10 +37,10 @@ class SvnDriver extends VcsDriver
protected $rootIdentifier;
protected $infoCache = array();
protected $trunkPath = 'trunk';
protected $trunkPath = 'trunk';
protected $branchesPath = 'branches';
protected $tagsPath = 'tags';
protected $packagePath = '';
protected $tagsPath = 'tags';
protected $packagePath = '';
protected $cacheCredentials = true;
/**
@ -132,7 +132,6 @@ class SvnDriver extends VcsDriver
$this->infoCache[$identifier] = $composer;
}
return $this->infoCache[$identifier];
}

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

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

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

@ -57,6 +57,7 @@ class Bitbucket
if (!isset($this->token['access_token'])) {
return '';
}
return $this->token['access_token'];
}
@ -213,14 +214,14 @@ class Bitbucket
"consumer-key" => $consumerKey,
"consumer-secret" => $consumerSecret,
"access-token" => $this->token['access_token'],
"access-token-expiration" => $time + $this->token['expires_in']
"access-token-expiration" => $time + $this->token['expires_in'],
);
$this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
}
/**
* @param string $originUrl
* @param string $originUrl
* @return bool
*/
private function getTokenFromConfig($originUrl)
@ -236,7 +237,7 @@ class Bitbucket
}
$this->token = array(
'access_token' => $authConfig[$originUrl]['access-token']
'access_token' => $authConfig[$originUrl]['access-token'],
);
return true;

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

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

@ -285,7 +285,7 @@ class Perforce
public function isLoggedIn()
{
$command = $this->generateP4Command('login -s', false);
$exitCode = $this->executeCommand($command);
$exitCode = $this->executeCommand($command);
if ($exitCode) {
$errorOutput = $this->process->getErrorOutput();
$index = strpos($errorOutput, $this->getUser());
@ -441,6 +441,7 @@ class Perforce
if ($index3 !== false) {
$phrase = trim(substr($result, $index3));
$fields = explode(' ', $phrase);
return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
}
}

@ -22,7 +22,7 @@ class Platform
/**
* Parses tildes and environment variables in paths.
*
* @param string $path
* @param string $path
* @return string
*/
public static function expandPath($path)
@ -30,18 +30,20 @@ class Platform
if (preg_match('#^~[\\/]#', $path)) {
return self::getUserDirectory() . substr($path, 1);
}
return preg_replace_callback('#^(\$|(?P<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
if (Platform::isWindows() && $matches['var'] == 'HOME') {
return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
}
return getenv($matches['var']) . $matches['path'];
}, $path);
}
/**
* @return string The formal user home as detected from environment parameters
* @throws \RuntimeException If the user home could not reliably be determined
* @return string The formal user home as detected from environment parameters
*/
public static function getUserDirectory()
{
@ -55,6 +57,7 @@ class Platform
if (function_exists('posix_getuid') && function_exists('posix_getpwuid')) {
$info = posix_getpwuid(posix_getuid());
return $info['dir'];
}
@ -71,7 +74,7 @@ class Platform
/**
* @param string $str
* @return int return a guaranteed binary length of the string, regardless of silly mbstring configs
* @return int return a guaranteed binary length of the string, regardless of silly mbstring configs
*/
public static function strlen($str)
{

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

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

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

@ -12,7 +12,6 @@
namespace Composer\Util;
use Symfony\Component\Process\PhpProcess;
use Composer\CaBundle\CaBundle;
/**
@ -137,12 +136,12 @@ final class TlsHelper
public static function getCertificateFingerprint($certificate)
{
$pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
$pubkeypem = $pubkeydetails['key'];
$pubkeypem = $pubkeydetails['key'];
//Convert PEM to DER before SHA1'ing
$start = '-----BEGIN PUBLIC KEY-----';
$end = '-----END PUBLIC KEY-----';
$pemtrim = substr($pubkeypem, (strpos($pubkeypem, $start) + strlen($start)), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
$der = base64_decode($pemtrim);
$start = '-----BEGIN PUBLIC KEY-----';
$end = '-----END PUBLIC KEY-----';
$pemtrim = substr($pubkeypem, (strpos($pubkeypem, $start) + strlen($start)), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
$der = base64_decode($pemtrim);
return sha1($der);
}

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

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

@ -24,7 +24,7 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
*
* @dataProvider getLoadClassTests
*
* @param string $class The fully-qualified class name to test, without preceding namespace separator.
* @param string $class The fully-qualified class name to test, without preceding namespace separator.
*/
public function testLoadClass($class)
{

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

@ -17,7 +17,6 @@ use Composer\TestCase;
class InitCommandTest extends TestCase
{
public function testParseValidAuthorString()
{
$command = new InitCommand;
@ -41,31 +40,31 @@ class InitCommandTest extends TestCase
$this->assertEquals('h4x0r', $author['name']);
$this->assertEquals('h4x@example.com', $author['email']);
}
/**
* Test scenario for issue #5631
* @link https://github.com/composer/composer/issues/5631 Issue #5631
*/
public function testParseValidAlias1AuthorString()
{
$command = new InitCommand;
$author = $command->parseAuthorString(
$command = new InitCommand;
$author = $command->parseAuthorString(
'Johnathon "Johnny" Smith <john@example.com>');
$this->assertEquals('Johnathon "Johnny" Smith', $author['name'] );
$this->assertEquals('john@example.com', $author['email']);
$this->assertEquals('Johnathon "Johnny" Smith', $author['name']);
$this->assertEquals('john@example.com', $author['email']);
}
/**
* Test scenario for issue #5631
* @link https://github.com/composer/composer/issues/5631 Issue #5631
*/
public function testParseValidAlias2AuthorString()
{
$command = new InitCommand;
$author = $command->parseAuthorString(
$command = new InitCommand;
$author = $command->parseAuthorString(
'Johnathon (Johnny) Smith <john@example.com>');
$this->assertEquals('Johnathon (Johnny) Smith', $author['name'] );
$this->assertEquals('john@example.com', $author['email']);
$this->assertEquals('Johnathon (Johnny) Smith', $author['name']);
$this->assertEquals('john@example.com', $author['email']);
}
public function testParseEmptyAuthorString()

@ -19,7 +19,6 @@ use Composer\TestCase;
class RunScriptCommandTest extends TestCase
{
/**
* @dataProvider getDevOptions
* @param bool $dev
@ -79,7 +78,7 @@ class RunScriptCommandTest extends TestCase
'getSynopsis',
'initialize',
'isInteractive',
'getComposer'
'getComposer',
))
->getMock();
$command->expects($this->any())->method('getComposer')->willReturn($composer);
@ -101,7 +100,7 @@ class RunScriptCommandTest extends TestCase
private function createComposerInstance()
{
$composer = new Composer;
$config = new Config;
$config = new Config;
$composer->setConfig($config);
return $composer;

@ -261,7 +261,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
'ssh://[user@]host.xz[:port]/path/to/repo.git/',
);
return array_combine($urls, array_map(function ($e) { return array($e); }, $urls));
return array_combine($urls, array_map(function ($e) {
return array($e);
}, $urls));
}
/**
@ -280,7 +282,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
'git://5.6.7.8/git.git',
);
return array_combine($urls, array_map(function ($e) { return array($e); }, $urls));
return array_combine($urls, array_map(function ($e) {
return array($e);
}, $urls));
}
/**

@ -57,7 +57,7 @@ class RuleSetTest extends TestCase
new GenericRule(array(), Rule::RULE_JOB_INSTALL, null),
new GenericRule(array(), Rule::RULE_JOB_INSTALL, null),
new GenericRule(array(), Rule::RULE_JOB_INSTALL, null),
)
),
);
$ruleSet = new RuleSet;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -89,7 +89,7 @@ class ComposerRepositoryTest extends TestCase
),
array('packages' => array(
'bar/foo' => array(
'3.14' => array('name' => 'bar/foo', 'version' => '3.14'),
'3.14' => array('name' => 'bar/foo', 'version' => '3.14'),
'3.145' => array('name' => 'bar/foo', 'version' => '3.145'),
),
)),
@ -178,9 +178,9 @@ class ComposerRepositoryTest extends TestCase
'results' => array(
array(
'name' => 'foo',
'description' => null
)
)
'description' => null,
),
),
);
$rfs = $this->getMockBuilder('Composer\Util\RemoteFilesystem')

@ -58,7 +58,7 @@ class GitBitbucketDriverTest extends TestCase
}
/**
* @param array $repoConfig
* @param array $repoConfig
* @return GitBitbucketDriver
*/
private function getDriver(array $repoConfig)
@ -109,32 +109,32 @@ class GitBitbucketDriverTest extends TestCase
array(
$this->originUrl,
'https://api.bitbucket.org/2.0/repositories/user/repo?fields=-project%2C-owner',
false
false,
),
array(
$this->originUrl,
'https://api.bitbucket.org/1.0/repositories/user/repo/main-branch',
false
false,
),
array(
$this->originUrl,
'https://api.bitbucket.org/2.0/repositories/user/repo/refs/tags?pagelen=100&fields=values.name%2Cvalues.target.hash%2Cnext&sort=-target.date',
false
false,
),
array(
$this->originUrl,
'https://api.bitbucket.org/2.0/repositories/user/repo/refs/branches?pagelen=100&fields=values.name%2Cvalues.target.hash%2Cnext&sort=-target.date',
false
false,
),
array(
$this->originUrl,
'https://api.bitbucket.org/1.0/repositories/user/repo/raw/master/composer.json',
false
false,
),
array(
$this->originUrl,
'https://api.bitbucket.org/2.0/repositories/user/repo/commit/master?fields=date',
false
false,
)
)
->willReturnOnConsecutiveCalls(
@ -154,14 +154,14 @@ class GitBitbucketDriverTest extends TestCase
$this->assertEquals(
array(
'1.0.1' => '9b78a3932143497c519e49b8241083838c8ff8a1',
'1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb'
'1.0.0' => 'd3393d514318a9267d2f8ebbf463a9aaa389f8eb',
),
$driver->getTags()
);
$this->assertEquals(
array(
'master' => '937992d19d72b5116c3e8c4a04f960e5fa270b22'
'master' => '937992d19d72b5116c3e8c4a04f960e5fa270b22',
),
$driver->getBranches()
);
@ -174,20 +174,20 @@ class GitBitbucketDriverTest extends TestCase
'authors' => array(
array(
'name' => 'Name',
'email' => 'local@domain.tld'
)
'email' => 'local@domain.tld',
),
),
'require' => array(
'creator/package' => '^1.0'
'creator/package' => '^1.0',
),
'require-dev' => array(
'phpunit/phpunit' => '~4.8'
'phpunit/phpunit' => '~4.8',
),
'time' => '2016-05-17 13:19:52',
'support' => array(
'source' => 'https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=master'
'source' => 'https://bitbucket.org/user/repo/src/937992d19d72b5116c3e8c4a04f960e5fa270b22/?at=master',
),
'homepage' => 'https://bitbucket.org/user/repo'
'homepage' => 'https://bitbucket.org/user/repo',
),
$driver->getComposerInformation('master')
);
@ -210,7 +210,7 @@ class GitBitbucketDriverTest extends TestCase
'type' => 'zip',
'url' => 'https://bitbucket.org/user/repo/get/reference.zip',
'reference' => 'reference',
'shasum' => ''
'shasum' => '',
),
$driver->getDist('reference')
);

@ -87,7 +87,7 @@ JSON;
->shouldBeCalledTimes(1)
;
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
@ -126,7 +126,7 @@ JSON;
->shouldBeCalledTimes(1)
;
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');
@ -257,7 +257,7 @@ JSON;
$expected = array(
'mymaster' => '97eda36b5c1dd953a3792865c222d4e85e5f302e',
'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd',
'staging' => '502cffe49f136443f2059803f2e7192d1ac066cd',
);
$this->assertEquals($expected, $driver->getBranches());
@ -315,7 +315,7 @@ JSON;
->shouldBeCalledTimes(1)
;
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
$driver = new GitLabDriver(array('url' => $url), $this->io->reveal(), $this->config, $this->process->reveal(), $this->remoteFilesystem->reveal());
$driver->initialize();
$this->assertEquals($apiUrl, $driver->getApiUrl(), 'API URL is derived from the repository URL');

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

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

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

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

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

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

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

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

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

@ -56,7 +56,8 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
),
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')),
array('options' => $a, 'notification' => $f = function () {}), array('notification' => $f),
array('options' => $a, 'notification' => $f = function () {
}), array('notification' => $f),
),
);
}

Loading…
Cancel
Save