From 33d026bb06197865b9cb59b6fb594df9c22f013b Mon Sep 17 00:00:00 2001 From: Thomas Flori Date: Sat, 12 Nov 2016 09:33:05 +0100 Subject: [PATCH] fix code style to be PSR-2 conform I tried to solve all PSR-2 style guide violations in files that I changed. One I could not solve: const can not concatenate in php 5.3. --- .../Repository/Vcs/BitbucketDriver.php | 55 +++++++++++++----- .../Repository/Vcs/GitBitbucketDriver.php | 48 ++++------------ src/Composer/Repository/Vcs/GitDriver.php | 32 ++++++++--- src/Composer/Repository/Vcs/GitLabDriver.php | 56 +++++++++++++++---- .../Repository/Vcs/HgBitbucketDriver.php | 23 ++++++-- src/Composer/Repository/Vcs/HgDriver.php | 38 +++++++++++-- .../Repository/Vcs/PerforceDriver.php | 3 +- src/Composer/Repository/Vcs/SvnDriver.php | 13 ++++- src/Composer/Repository/Vcs/VcsDriver.php | 9 ++- src/Composer/Util/Perforce.php | 10 +++- 10 files changed, 198 insertions(+), 89 deletions(-) diff --git a/src/Composer/Repository/Vcs/BitbucketDriver.php b/src/Composer/Repository/Vcs/BitbucketDriver.php index 4e3a55f26..5afd767cd 100644 --- a/src/Composer/Repository/Vcs/BitbucketDriver.php +++ b/src/Composer/Repository/Vcs/BitbucketDriver.php @@ -1,9 +1,7 @@ owner = $match[1]; $this->repository = $match[2]; $this->originUrl = 'bitbucket.org'; - $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository); + $this->cache = new Cache( + $this->io, + implode('/', array( + $this->config->get('cache-repo-dir'), + $this->originUrl, + $this->owner, + $this->repository + )) + ); } /** @@ -48,12 +54,17 @@ abstract class BitbucketDriver extends VcsDriver } if (!isset($this->infoCache[$identifier])) { - $composer = parent::getComposerInformation($identifier); // specials for bitbucket if (!isset($composer['support']['source'])) { - $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier; + $label = array_search( + $identifier, + $this->getTags() + ) ?: array_search( + $identifier, + $this->getBranches() + ) ?: $identifier; if (array_key_exists($label, $tags = $this->getTags())) { $hash = $tags[$label]; @@ -62,7 +73,12 @@ abstract class BitbucketDriver extends VcsDriver } if (! isset($hash)) { - $composer['support']['source'] = sprintf('https://%s/%s/%s/src', $this->originUrl, $this->owner, $this->repository); + $composer['support']['source'] = sprintf( + 'https://%s/%s/%s/src', + $this->originUrl, + $this->owner, + $this->repository + ); } else { $composer['support']['source'] = sprintf( 'https://%s/%s/%s/src/%s/?at=%s', @@ -75,7 +91,12 @@ abstract class BitbucketDriver extends VcsDriver } } if (!isset($composer['support']['issues']) && $this->hasIssues) { - $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository); + $composer['support']['issues'] = sprintf( + 'https://%s/%s/%s/issues', + $this->originUrl, + $this->owner, + $this->repository + ); } $this->infoCache[$identifier] = $composer; @@ -87,7 +108,8 @@ abstract class BitbucketDriver extends VcsDriver /** * {@inheritdoc} */ - public function getFileContent($file, $identifier) { + public function getFileContent($file, $identifier) + { if ($this->sshDriver) { return $this->sshDriver->getFileContent($file, $identifier); } @@ -96,7 +118,8 @@ abstract class BitbucketDriver extends VcsDriver return $res; } - $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/src/'.$identifier.'/' . $file; + $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/' + . $this->owner . '/' . $this->repository . '/src/' . $identifier . '/' . $file; $fileData = JsonFile::parseJson($this->getContents($resource), $resource); if (!is_array($fileData) || ! array_key_exists('data', $fileData)) { return null; @@ -112,12 +135,14 @@ abstract class BitbucketDriver extends VcsDriver /** * {@inheritdoc} */ - public function getChangeDate($identifier) { + public function getChangeDate($identifier) + { if ($this->sshDriver) { return $this->sshDriver->getChangeDate($identifier); } - $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/changesets/'.$identifier; + $resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/' + . $this->owner . '/' . $this->repository . '/changesets/' . $identifier; $changeset = JsonFile::parseJson($this->getContents($resource), $resource); return new \DateTime($changeset['timestamp']); @@ -140,7 +165,8 @@ abstract class BitbucketDriver extends VcsDriver switch ($e->getCode()) { case 403: - if (!$this->io->hasAuthentication($this->originUrl) && $bitbucketUtil->authorizeOAuth($this->originUrl)) { + if (!$this->io->hasAuthentication($this->originUrl) + && $bitbucketUtil->authorizeOAuth($this->originUrl)) { return parent::getContents($url); } @@ -175,7 +201,10 @@ abstract class BitbucketDriver extends VcsDriver } catch (\RuntimeException $e) { $this->sshDriver = null; - $this->io->writeError('Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your Bitbucket OAuth consumer credentials'); + $this->io->writeError( + 'Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode' + . ' so that you can enter your Bitbucket OAuth consumer credentials' + ); throw $e; } } diff --git a/src/Composer/Repository/Vcs/GitBitbucketDriver.php b/src/Composer/Repository/Vcs/GitBitbucketDriver.php index 03a9fddaf..a965d150b 100644 --- a/src/Composer/Repository/Vcs/GitBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/GitBitbucketDriver.php @@ -37,7 +37,8 @@ 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'; @@ -91,7 +92,8 @@ 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) { @@ -112,7 +114,8 @@ 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) { @@ -133,7 +136,11 @@ 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; } @@ -155,37 +162,4 @@ class GitBitbucketDriver extends BitbucketDriver implements VcsDriverInterface ); $this->sshDriver->initialize(); } - - /** - * Get the remote content. - * - * @param string $url The URL of content - * @param bool $fetchingRepoData - * - * @return mixed The result - */ - protected function getContentsWithOAuthCredentials($url, $fetchingRepoData = false) - { - try { - return parent::getContents($url); - } catch (TransportException $e) { - $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->remoteFilesystem); - - switch ($e->getCode()) { - case 403: - if (!$this->io->hasAuthentication($this->originUrl) && $bitbucketUtil->authorizeOAuth($this->originUrl)) { - return parent::getContents($url); - } - - if (!$this->io->isInteractive() && $fetchingRepoData) { - return $this->attemptCloneFallback(); - } - - throw $e; - - default: - throw $e; - } - } - } } diff --git a/src/Composer/Repository/Vcs/GitDriver.php b/src/Composer/Repository/Vcs/GitDriver.php index 685088c4b..fdd069aef 100644 --- a/src/Composer/Repository/Vcs/GitDriver.php +++ b/src/Composer/Repository/Vcs/GitDriver.php @@ -42,7 +42,8 @@ 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(); @@ -50,16 +51,26 @@ 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; @@ -68,7 +79,10 @@ 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) + ); } /** @@ -145,8 +159,12 @@ class GitDriver extends VcsDriver /** * {@inheritdoc} */ - public function getChangeDate($identifier) { - $this->process->execute(sprintf('git log -1 --format=%%at %s', ProcessExecutor::escape($identifier)), $output, $this->repoDir); + public function getChangeDate($identifier) + { + $this->process->execute(sprintf( + 'git log -1 --format=%%at %s', + ProcessExecutor::escape($identifier) + ), $output, $this->repoDir); return new \DateTime('@'.trim($output), new \DateTimeZone('UTC')); } diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php index 2ad00003a..775360cf9 100644 --- a/src/Composer/Repository/Vcs/GitLabDriver.php +++ b/src/Composer/Repository/Vcs/GitLabDriver.php @@ -73,15 +73,30 @@ 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, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository); + $this->cache = new Cache( + $this->io, + implode('/', array( + $this->config->get('cache-repo-dir'), + $this->originUrl, + $this->owner, + $this->repository + )) + ); $this->fetchProject(); } @@ -275,7 +290,8 @@ 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); } /** @@ -289,7 +305,9 @@ 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; @@ -338,7 +356,10 @@ 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; } } @@ -378,7 +399,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 real 404 + // try to authorize only if we are fetching the main /repos/foo/bar data, otherwise it must be a 404 if (!$fetchingRepoData) { throw $e; } @@ -390,13 +411,22 @@ 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); } @@ -432,7 +462,11 @@ 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 d2d7cc1be..dc8d32517 100644 --- a/src/Composer/Repository/Vcs/HgBitbucketDriver.php +++ b/src/Composer/Repository/Vcs/HgBitbucketDriver.php @@ -29,10 +29,14 @@ 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']; @@ -73,7 +77,8 @@ 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) { @@ -91,7 +96,8 @@ 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) { @@ -112,7 +118,11 @@ 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; } @@ -120,7 +130,8 @@ class HgBitbucketDriver extends BitbucketDriver return true; } - protected function setupSshDriver($url) { + protected function setupSshDriver($url) + { $this->sshDriver = new HgDriver( array('url' => $url), $this->io, diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 451cec7ff..e347269b0 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -45,7 +45,10 @@ 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 @@ -54,20 +57,36 @@ 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 + ); } } } @@ -134,7 +153,14 @@ class HgDriver extends VcsDriver */ public function getChangeDate($identifier) { - $this->process->execute(sprintf('hg log --template "{date|rfc3339date}" -r %s', ProcessExecutor::escape($identifier)), $output, $this->repoDir); + $this->process->execute( + sprintf( + 'hg log --template "{date|rfc3339date}" -r %s', + ProcessExecutor::escape($identifier) + ), + $output, + $this->repoDir + ); return new \DateTime(trim($output), new \DateTimeZone('UTC')); } diff --git a/src/Composer/Repository/Vcs/PerforceDriver.php b/src/Composer/Repository/Vcs/PerforceDriver.php index 744b4264f..2a011106e 100644 --- a/src/Composer/Repository/Vcs/PerforceDriver.php +++ b/src/Composer/Repository/Vcs/PerforceDriver.php @@ -86,7 +86,8 @@ class PerforceDriver extends VcsDriver /** * {@inheritdoc} */ - public function getChangeDate($identifier) { + public function getChangeDate($identifier) + { return new \DateTime(); } diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index bffe23b46..5139d02a7 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -77,7 +77,10 @@ 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(); @@ -205,7 +208,8 @@ class SvnDriver extends VcsDriver /** * {@inheritdoc} */ - public function getChangeDate($identifier) { + public function getChangeDate($identifier) + { $identifier = '/' . trim($identifier, '/') . '/'; preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match); @@ -380,7 +384,10 @@ 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 37e9fc01f..321afbef5 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -54,8 +54,13 @@ 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']); } diff --git a/src/Composer/Util/Perforce.php b/src/Composer/Util/Perforce.php index 86fd472cd..533af98cc 100644 --- a/src/Composer/Util/Perforce.php +++ b/src/Composer/Util/Perforce.php @@ -304,7 +304,9 @@ class Perforce public function connectClient() { - $p4CreateClientCommand = $this->generateP4Command('client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())); + $p4CreateClientCommand = $this->generateP4Command( + 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec()) + ); $this->executeCommand($p4CreateClientCommand); } @@ -407,7 +409,8 @@ class Perforce return $this->getComposerInformationFromLabel($identifier, $index); } - public function getFileContent($file, $identifier) { + public function getFileContent($file, $identifier) + { $path = $this->getFilePath($file, $identifier); $command = $this->generateP4Command(' print ' . $path); @@ -421,7 +424,8 @@ class Perforce return $result; } - public function getFilePath($file, $identifier) { + public function getFilePath($file, $identifier) + { $index = strpos($identifier, '@'); if ($index === false) { $path = $identifier. '/' . $file;