1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 17:12:51 +00:00

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.
This commit is contained in:
Thomas Flori 2016-11-12 09:33:05 +01:00
parent 597f834ae9
commit 33d026bb06
10 changed files with 198 additions and 89 deletions

View file

@ -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;
}
}
}
}