diff --git a/src/Composer/Repository/Vcs/GitBitbucketDriver.php b/src/Composer/Repository/Vcs/GitBitbucketDriver.php
index a965d150b..9c07fff40 100644
--- a/src/Composer/Repository/Vcs/GitBitbucketDriver.php
+++ b/src/Composer/Repository/Vcs/GitBitbucketDriver.php
@@ -37,8 +37,7 @@ class GitBitbucketDriver extends BitbucketDriver implements VcsDriverInterface
}
if (null === $this->rootIdentifier) {
- $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'
- . $this->owner . '/' . $this->repository;
+ $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository;
$repoData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource, true), $resource);
$this->hasIssues = !empty($repoData['has_issues']);
$this->rootIdentifier = !empty($repoData['main_branch']) ? $repoData['main_branch'] : 'master';
@@ -92,8 +91,7 @@ class GitBitbucketDriver extends BitbucketDriver implements VcsDriverInterface
}
if (null === $this->tags) {
- $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'
- . $this->owner . '/' . $this->repository . '/tags';
+ $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
$tagsData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
$this->tags = array();
foreach ($tagsData as $tag => $data) {
@@ -114,8 +112,7 @@ class GitBitbucketDriver extends BitbucketDriver implements VcsDriverInterface
}
if (null === $this->branches) {
- $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'
- . $this->owner . '/' . $this->repository . '/branches';
+ $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/branches';
$branchData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
$this->branches = array();
foreach ($branchData as $branch => $data) {
@@ -136,11 +133,7 @@ class GitBitbucketDriver extends BitbucketDriver implements VcsDriverInterface
}
if (!extension_loaded('openssl')) {
- $io->writeError(
- 'Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.',
- true,
- IOInterface::VERBOSE
- );
+ $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
return false;
}
diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php
index fdd069aef..a93447c73 100644
--- a/src/Composer/Repository/Vcs/GitDriver.php
+++ b/src/Composer/Repository/Vcs/GitDriver.php
@@ -42,8 +42,7 @@ class GitDriver extends VcsDriver
$this->repoDir = $this->url;
$cacheUrl = realpath($this->url);
} else {
- $this->repoDir = $this->config->get('cache-vcs-dir') . '/'
- . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
+ $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
GitUtil::cleanEnv();
@@ -51,26 +50,16 @@ class GitDriver extends VcsDriver
$fs->ensureDirectoryExists(dirname($this->repoDir));
if (!is_writable(dirname($this->repoDir))) {
- throw new \RuntimeException(
- 'Can not clone ' . $this->url . ' to access package information. The "' . dirname($this->repoDir)
- . '" directory is not writable by the current user.'
- );
+ throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
}
if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
- throw new \InvalidArgumentException(
- 'The source URL ' . $this->url . ' is invalid, ssh URLs should have a port number after ":".'
- . "\n" . 'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want'
- . ' to provide a password or custom port.'
- );
+ throw new \InvalidArgumentException('The source URL '.$this->url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
}
$gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
- $this->io->writeError(
- 'Failed to update ' . $this->url . ', package information from this repository'
- . ' may be outdated'
- );
+ $this->io->writeError('Failed to update '.$this->url.', package information from this repository may be outdated');
}
$cacheUrl = $this->url;
@@ -79,10 +68,7 @@ class GitDriver extends VcsDriver
$this->getTags();
$this->getBranches();
- $this->cache = new Cache(
- $this->io,
- $this->config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $cacheUrl)
- );
+ $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $cacheUrl));
}
/**
diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php
index 775360cf9..2ad00003a 100644
--- a/src/Composer/Repository/Vcs/GitLabDriver.php
+++ b/src/Composer/Repository/Vcs/GitLabDriver.php
@@ -73,30 +73,15 @@ class GitLabDriver extends VcsDriver
public function initialize()
{
if (!preg_match(self::URL_REGEX, $this->url, $match)) {
- throw new \InvalidArgumentException(
- 'The URL provided is invalid. It must be the HTTP URL of a GitLab project.'
- );
+ throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
}
- $this->scheme = !empty($match['scheme']) ?
- $match['scheme'] :
- (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ?
- 'http' :
- 'https'
- );
+ $this->scheme = !empty($match['scheme']) ? $match['scheme'] : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https');
$this->originUrl = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
$this->owner = $match['owner'];
$this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
- $this->cache = new Cache(
- $this->io,
- implode('/', array(
- $this->config->get('cache-repo-dir'),
- $this->originUrl,
- $this->owner,
- $this->repository
- ))
- );
+ $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
$this->fetchProject();
}
@@ -290,8 +275,7 @@ class GitLabDriver extends VcsDriver
*/
public function getApiUrl()
{
- return $this->scheme . '://' . $this->originUrl . '/api/v3/projects/'
- . $this->urlEncodeAll($this->owner) . '%2F' . $this->urlEncodeAll($this->repository);
+ return $this->scheme.'://'.$this->originUrl.'/api/v3/projects/'.$this->urlEncodeAll($this->owner).'%2F'.$this->urlEncodeAll($this->repository);
}
/**
@@ -305,9 +289,7 @@ class GitLabDriver extends VcsDriver
$encoded = '';
for ($i = 0; isset($string[$i]); $i++) {
$character = $string[$i];
- if (!ctype_alnum($character)) {
- $character = '%' . sprintf('%02X', ord($character));
- }
+ if (!ctype_alnum($character)) $character = '%' . sprintf('%02X', ord($character));
$encoded .= $character;
}
return $encoded;
@@ -356,10 +338,7 @@ class GitLabDriver extends VcsDriver
} catch (\RuntimeException $e) {
$this->gitDriver = null;
- $this->io->writeError(
- 'Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
- . ' so that you can enter your credentials'
- );
+ $this->io->writeError('Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your credentials');
throw $e;
}
}
@@ -399,7 +378,7 @@ class GitLabDriver extends VcsDriver
switch ($e->getCode()) {
case 401:
case 404:
- // try to authorize only if we are fetching the main /repos/foo/bar data, otherwise it must be a 404
+ // try to authorize only if we are fetching the main /repos/foo/bar data, otherwise it must be a real 404
if (!$fetchingRepoData) {
throw $e;
}
@@ -411,22 +390,13 @@ class GitLabDriver extends VcsDriver
if (!$this->io->isInteractive()) {
return $this->attemptCloneFallback();
}
- $this->io->writeError(
- 'Failed to download ' . $this->owner . '/' . $this->repository
- . ':' . $e->getMessage() . ''
- );
- $gitLabUtil->authorizeOAuthInteractively(
- $this->scheme,
- $this->originUrl,
- 'Your credentials are required to fetch private repository metadata ('
- . $this->url . ')'
- );
+ $this->io->writeError('Failed to download ' . $this->owner . '/' . $this->repository . ':' . $e->getMessage() . '');
+ $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata ('.$this->url.')');
return parent::getContents($url);
case 403:
- if (!$this->io->hasAuthentication($this->originUrl) &&
- $gitLabUtil->authorizeOAuth($this->originUrl)) {
+ if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
return parent::getContents($url);
}
@@ -462,11 +432,7 @@ class GitLabDriver extends VcsDriver
}
if ('https' === $scheme && !extension_loaded('openssl')) {
- $io->writeError(
- 'Skipping GitLab driver for ' . $url . ' because the OpenSSL PHP extension is missing.',
- true,
- IOInterface::VERBOSE
- );
+ $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
return false;
}
diff --git a/src/Composer/Repository/Vcs/HgBitbucketDriver.php b/src/Composer/Repository/Vcs/HgBitbucketDriver.php
index dc8d32517..6edc1364e 100644
--- a/src/Composer/Repository/Vcs/HgBitbucketDriver.php
+++ b/src/Composer/Repository/Vcs/HgBitbucketDriver.php
@@ -29,14 +29,10 @@ class HgBitbucketDriver extends BitbucketDriver
public function getRootIdentifier()
{
if (null === $this->rootIdentifier) {
- $resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'
- . $this->owner . '/' . $this->repository . '/tags';
+ $resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
$repoData = JsonFile::parseJson($this->getContents($resource), $resource);
if (array() === $repoData || !isset($repoData['tip'])) {
- throw new \RuntimeException(
- $this->url . ' does not appear to be a mercurial repository, use '
- . $this->url . '.git if this is a git bitbucket repository'
- );
+ throw new \RuntimeException($this->url.' does not appear to be a mercurial repository, use '.$this->url.'.git if this is a git bitbucket repository');
}
$this->hasIssues = !empty($repoData['has_issues']);
$this->rootIdentifier = $repoData['tip']['raw_node'];
@@ -77,8 +73,7 @@ class HgBitbucketDriver extends BitbucketDriver
public function getTags()
{
if (null === $this->tags) {
- $resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'
- . $this->owner . '/' . $this->repository . '/tags';
+ $resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
$tagsData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->tags = array();
foreach ($tagsData as $tag => $data) {
@@ -96,8 +91,7 @@ class HgBitbucketDriver extends BitbucketDriver
public function getBranches()
{
if (null === $this->branches) {
- $resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'
- . $this->owner . '/' . $this->repository . '/branches';
+ $resource = $this->getScheme() . '://bitbucket.org/api/1.0/repositories/'.$this->owner.'/'.$this->repository.'/branches';
$branchData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->branches = array();
foreach ($branchData as $branch => $data) {
@@ -118,11 +112,7 @@ class HgBitbucketDriver extends BitbucketDriver
}
if (!extension_loaded('openssl')) {
- $io->writeError(
- 'Skipping Bitbucket hg driver for ' . $url . ' because the OpenSSL PHP extension is missing.',
- true,
- IOInterface::VERBOSE
- );
+ $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
return false;
}
diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php
index e347269b0..bad52bed3 100644
--- a/src/Composer/Repository/Vcs/HgDriver.php
+++ b/src/Composer/Repository/Vcs/HgDriver.php
@@ -45,10 +45,7 @@ class HgDriver extends VcsDriver
$fs->ensureDirectoryExists($cacheDir);
if (!is_writable(dirname($this->repoDir))) {
- throw new \RuntimeException(
- 'Can not clone ' . $this->url . ' to access package information. The "' . $cacheDir
- . '" directory is not writable by the current user.'
- );
+ throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
}
// Ensure we are allowed to use this URL by config
@@ -57,36 +54,20 @@ class HgDriver extends VcsDriver
// update the repo if it is a valid hg repository
if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
- $this->io->writeError(
- 'Failed to update ' . $this->url . ', package information from this repository may be'
- . ' outdated ('.$this->process->getErrorOutput().')'
- );
+ $this->io->writeError('Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')');
}
} else {
// clean up directory and do a fresh clone into it
$fs->removeDirectory($this->repoDir);
- if (0 !== $this->process->execute(
- sprintf(
- 'hg clone --noupdate %s %s',
- ProcessExecutor::escape($this->url),
- ProcessExecutor::escape($this->repoDir)
- ),
- $output,
- $cacheDir
- )) {
+ if (0 !== $this->process->execute(sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoDir)), $output, $cacheDir)) {
$output = $this->process->getErrorOutput();
if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
- throw new \RuntimeException(
- 'Failed to clone ' . $this->url . ', hg was not found, check that it is installed and in'
- . ' your PATH env.' . "\n\n" . $this->process->getErrorOutput()
- );
+ throw new \RuntimeException('Failed to clone '.$this->url.', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
}
- throw new \RuntimeException(
- 'Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" .$output
- );
+ throw new \RuntimeException('Failed to clone '.$this->url.', could not read packages from it' . "\n\n" .$output);
}
}
}
diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php
index 5139d02a7..1d3df7909 100644
--- a/src/Composer/Repository/Vcs/SvnDriver.php
+++ b/src/Composer/Repository/Vcs/SvnDriver.php
@@ -77,10 +77,7 @@ class SvnDriver extends VcsDriver
$this->baseUrl = substr($this->url, 0, $pos);
}
- $this->cache = new Cache(
- $this->io,
- $this->config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->baseUrl)
- );
+ $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->baseUrl));
$this->getBranches();
$this->getTags();
@@ -384,10 +381,7 @@ class SvnDriver extends VcsDriver
return $this->util->execute($command, $url);
} catch (\RuntimeException $e) {
if (0 !== $this->process->execute('svn --version', $ignoredOutput)) {
- throw new \RuntimeException(
- 'Failed to load ' . $this->url . ', svn was not found, check that it is installed and in your'
- . ' PATH env.' . "\n\n" . $this->process->getErrorOutput()
- );
+ throw new \RuntimeException('Failed to load '.$this->url.', svn was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
}
throw new \RuntimeException(
diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php
index 321afbef5..37e9fc01f 100644
--- a/src/Composer/Repository/Vcs/VcsDriver.php
+++ b/src/Composer/Repository/Vcs/VcsDriver.php
@@ -54,13 +54,8 @@ abstract class VcsDriver implements VcsDriverInterface
* @param ProcessExecutor $process Process instance, injectable for mocking
* @param RemoteFilesystem $remoteFilesystem Remote Filesystem, injectable for mocking
*/
- final public function __construct(
- array $repoConfig,
- IOInterface $io,
- Config $config,
- ProcessExecutor $process = null,
- RemoteFilesystem $remoteFilesystem = null
- ) {
+ final public function __construct(array $repoConfig, IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null)
+ {
if (Filesystem::isLocalPath($repoConfig['url'])) {
$repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
}