From 3e5fd85768083473bdff475ce3630c03f7783f2e Mon Sep 17 00:00:00 2001 From: Per Bernhardt Date: Thu, 10 Nov 2011 13:10:05 +0100 Subject: [PATCH] Fixed CS and unused variables --- src/Composer/Downloader/HgDownloader.php | 5 +-- src/Composer/Repository/Vcs/HgDriver.php | 42 ++++++++++++------------ 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Composer/Downloader/HgDownloader.php b/src/Composer/Downloader/HgDownloader.php index df0d6ae05..88264eb04 100644 --- a/src/Composer/Downloader/HgDownloader.php +++ b/src/Composer/Downloader/HgDownloader.php @@ -19,6 +19,7 @@ use Composer\Package\PackageInterface; */ class HgDownloader implements DownloaderInterface { + /** * {@inheritDoc} */ @@ -50,8 +51,8 @@ class HgDownloader implements DownloaderInterface throw new \InvalidArgumentException('The given package is missing reference information'); } - $this->enforceCleanDirectory($path); - system(sprintf('cd %s && hg pull && hg up %s', $path, $target->getSourceReference())); + $this->enforceCleanDirectory($path); + system(sprintf('cd %s && hg pull && hg up %s', $path, $target->getSourceReference())); } /** diff --git a/src/Composer/Repository/Vcs/HgDriver.php b/src/Composer/Repository/Vcs/HgDriver.php index 6e58a3dda..cf74621c6 100644 --- a/src/Composer/Repository/Vcs/HgDriver.php +++ b/src/Composer/Repository/Vcs/HgDriver.php @@ -26,7 +26,7 @@ class HgDriver implements VcsDriverInterface protected $infoCache = array(); public function __construct($url) - { + { $this->url = $url; $this->tmpDir = sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9]}i', '-', $url) . '/'; } @@ -53,11 +53,11 @@ class HgDriver implements VcsDriverInterface */ public function getRootIdentifier() { - $tmpDir = escapeshellarg($this->tmpDir); - if (null === $this->rootIdentifier) { - exec(sprintf('cd %s && hg tip --template "{rev}:{node|short}" --color never', $tmpDir), $output); - $this->rootIdentifier = $output[0]; - } + $tmpDir = escapeshellarg($this->tmpDir); + if (null === $this->rootIdentifier) { + exec(sprintf('cd %s && hg tip --template "{rev}:{node|short}" --color never', $tmpDir), $output); + $this->rootIdentifier = $output[0]; + } return $this->rootIdentifier; } @@ -74,7 +74,7 @@ class HgDriver implements VcsDriverInterface */ public function getSource($identifier) { - $label = array_search($identifier, (array) $this->tags) ?: $identifier; + $label = array_search($identifier, (array)$this->tags) ? : $identifier; return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $label); } @@ -98,7 +98,7 @@ class HgDriver implements VcsDriverInterface unset($output); if (!$composer) { - throw new \UnexpectedValueException('Failed to retrieve composer information for identifier '.$identifier.' in '.$this->getUrl()); + throw new \UnexpectedValueException('Failed to retrieve composer information for identifier ' . $identifier . ' in ' . $this->getUrl()); } $composer = JsonFile::parseJson($composer); @@ -111,7 +111,7 @@ class HgDriver implements VcsDriverInterface $this->infoCache[$identifier] = $composer; } - return $this->infoCache[$identifier]; + return $this->infoCache[$identifier]; } /** @@ -121,12 +121,12 @@ class HgDriver implements VcsDriverInterface { if (null === $this->tags) { exec(sprintf('cd %s && hg tags --color never', escapeshellarg($this->tmpDir)), $output); - foreach ($output as $key => $tag) { - preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $tag, $match); - $tags[$match[1]] = $match[2]; - } + foreach ($output as $tag) { + preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $tag, $match); + $tags[$match[1]] = $match[2]; + } unset($tags['tip']); - $this->tags = $tags; + $this->tags = $tags; } return $this->tags; @@ -141,9 +141,9 @@ class HgDriver implements VcsDriverInterface $branches = array(); exec(sprintf('cd %s && hg branches --color never', escapeshellarg($this->tmpDir)), $output); - foreach ($output as $key => $branch) { - preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $branch, $match); - $branches[$match[1]] = $match[2]; + foreach ($output as $branch) { + preg_match('(^([^\s]+)[\s]+[\d+]:(.*)$)', $branch, $match); + $branches[$match[1]] = $match[2]; } $this->branches = $branches; @@ -171,16 +171,16 @@ class HgDriver implements VcsDriverInterface */ public static function supports($url, $deep = false) { - if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) { + if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) { return true; } if (!$deep) { return false; } - - exec(sprintf('hg identify %s', escapeshellarg($url)), $output); - return (boolean) $output; + exec(sprintf('hg identify %s', escapeshellarg($url)), $output); + + return (boolean)$output; } }