From 6a64041055f2df32e2fd5b01ca15b52272b980ac Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 30 Jun 2015 15:38:32 +0100 Subject: [PATCH] CS fixes --- src/Composer/Command/CreateProjectCommand.php | 4 ++-- src/Composer/Command/DiagnoseCommand.php | 2 +- src/Composer/Console/Application.php | 2 +- src/Composer/Console/HtmlOutputFormatter.php | 1 + .../DependencyResolver/SolverProblemsException.php | 2 +- src/Composer/Downloader/ArchiveDownloader.php | 2 +- src/Composer/Package/Version/VersionParser.php | 8 ++++---- src/Composer/Util/ErrorHandler.php | 1 + src/Composer/Util/GitHub.php | 1 + .../Composer/Test/EventDispatcher/EventDispatcherTest.php | 1 - tests/Composer/Test/InstallerTest.php | 1 - tests/Composer/Test/Package/BasePackageTest.php | 2 -- .../Test/Package/Loader/RootPackageLoaderTest.php | 1 - .../Test/Package/Loader/ValidatingArrayLoaderTest.php | 1 - tests/Composer/Test/Plugin/PluginInstallerTest.php | 2 +- tests/Composer/Test/Repository/ComposerRepositoryTest.php | 1 - tests/Composer/Test/Util/RemoteFilesystemTest.php | 1 - tests/Composer/TestCase.php | 1 - 18 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 02aaf6f1b..6efec81be 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -290,8 +290,8 @@ EOT // handler Ctrl+C for unix-like systems if (function_exists('pcntl_signal')) { - declare(ticks = 100); - pcntl_signal(SIGINT, function() use ($directory) { + declare (ticks = 100); + pcntl_signal(SIGINT, function () use ($directory) { $fs = new Filesystem(); $fs->removeDirectory($directory); exit(130); diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index c279d182c..860f85948 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -295,7 +295,7 @@ EOT private function checkDiskSpace($config) { - $minSpaceFree = 1024*1024; + $minSpaceFree = 1024 * 1024; if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree) || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree) ) { diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index ee4f4e9c0..8f92c9c55 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -181,7 +181,7 @@ class Application extends BaseApplication if ($composer) { $config = $composer->getConfig(); - $minSpaceFree = 1024*1024; + $minSpaceFree = 1024 * 1024; if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree) || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree) || (($df = @disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree) diff --git a/src/Composer/Console/HtmlOutputFormatter.php b/src/Composer/Console/HtmlOutputFormatter.php index cb42133c3..f5368b5fe 100644 --- a/src/Composer/Console/HtmlOutputFormatter.php +++ b/src/Composer/Console/HtmlOutputFormatter.php @@ -60,6 +60,7 @@ class HtmlOutputFormatter extends OutputFormatter $formatted = parent::format($message); $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)'; + return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted); } diff --git a/src/Composer/DependencyResolver/SolverProblemsException.php b/src/Composer/DependencyResolver/SolverProblemsException.php index 308172bcc..9973f9d39 100644 --- a/src/Composer/DependencyResolver/SolverProblemsException.php +++ b/src/Composer/DependencyResolver/SolverProblemsException.php @@ -32,7 +32,7 @@ class SolverProblemsException extends \RuntimeException { $text = "\n"; foreach ($this->problems as $i => $problem) { - $text .= " Problem ".($i+1).$problem->getPrettyString($this->installedMap)."\n"; + $text .= " Problem ".($i + 1).$problem->getPrettyString($this->installedMap)."\n"; } if (strpos($text, 'could not be found') || strpos($text, 'no matching package found')) { diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index ff0b9e338..4f41285c8 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/src/Composer/Downloader/ArchiveDownloader.php @@ -115,7 +115,7 @@ abstract class ArchiveDownloader extends FileDownloader // update api archives to the proper reference $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference(); } - } else if ($package->getDistReference() && strpos($url, 'bitbucket.org')) { + } elseif ($package->getDistReference() && strpos($url, 'bitbucket.org')) { if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) { // update Bitbucket archives to the proper reference $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $package->getDistReference() . '.' . $match[4]; diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index c1cd4d229..e199838f2 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -141,10 +141,10 @@ class VersionParser if ('stable' === $matches[$index]) { return $version; } - $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index+1]) ? $matches[$index+1] : ''); + $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? $matches[$index + 1] : ''); } - if (!empty($matches[$index+2])) { + if (!empty($matches[$index + 2])) { $version .= '-dev'; } @@ -530,8 +530,8 @@ class VersionParser for ($i = 0, $count = count($pairs); $i < $count; $i++) { $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i])); - if (false === strpos($pair, ' ') && isset($pairs[$i+1]) && false === strpos($pairs[$i+1], '/')) { - $pair .= ' '.$pairs[$i+1]; + if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/')) { + $pair .= ' '.$pairs[$i + 1]; $i++; } diff --git a/src/Composer/Util/ErrorHandler.php b/src/Composer/Util/ErrorHandler.php index b10cb15d5..399491f8c 100644 --- a/src/Composer/Util/ErrorHandler.php +++ b/src/Composer/Util/ErrorHandler.php @@ -58,6 +58,7 @@ class ErrorHandler if (isset($a['line'], $a['file'])) { return ' '.$a['file'].':'.$a['line'].''; } + return null; }, array_slice(debug_backtrace(), 2)))); } diff --git a/src/Composer/Util/GitHub.php b/src/Composer/Util/GitHub.php index 369214e5d..8aaa7db65 100644 --- a/src/Composer/Util/GitHub.php +++ b/src/Composer/Util/GitHub.php @@ -94,6 +94,7 @@ class GitHub if (!$token) { $this->io->writeError('No token given, aborting.'); $this->io->writeError('You can also add it manually later by using "composer config github-oauth.github.com "'); + return false; } diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php index 06d9c652d..a44c6bc5d 100644 --- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php +++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php @@ -13,7 +13,6 @@ namespace Composer\Test\EventDispatcher; use Composer\EventDispatcher\Event; -use Composer\EventDispatcher\EventDispatcher; use Composer\Installer\InstallerEvents; use Composer\TestCase; use Composer\Script\ScriptEvents; diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 7fa85d76d..16024f517 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -14,7 +14,6 @@ namespace Composer\Test; use Composer\Installer; use Composer\Console\Application; -use Composer\Config; use Composer\Json\JsonFile; use Composer\Repository\ArrayRepository; use Composer\Repository\RepositoryManager; diff --git a/tests/Composer/Test/Package/BasePackageTest.php b/tests/Composer/Test/Package/BasePackageTest.php index 1fe0ece84..23c656a4e 100644 --- a/tests/Composer/Test/Package/BasePackageTest.php +++ b/tests/Composer/Test/Package/BasePackageTest.php @@ -12,8 +12,6 @@ namespace Composer\Test\Package; -use Composer\Package\BasePackage; - class BasePackageTest extends \PHPUnit_Framework_TestCase { public function testSetSameRepository() diff --git a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php index 37c259676..fc3192414 100644 --- a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php @@ -16,7 +16,6 @@ use Composer\Config; use Composer\Package\Loader\RootPackageLoader; use Composer\Package\BasePackage; use Composer\Test\Mock\ProcessExecutorMock; -use Composer\Repository\RepositoryManager; class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index 075ee8253..ab61b6c15 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -12,7 +12,6 @@ namespace Composer\Test\Package\Loader; -use Composer\Package; use Composer\Package\Loader\ValidatingArrayLoader; use Composer\Package\Loader\InvalidPackageException; diff --git a/tests/Composer/Test/Plugin/PluginInstallerTest.php b/tests/Composer/Test/Plugin/PluginInstallerTest.php index cd05b922f..4af7197f7 100644 --- a/tests/Composer/Test/Plugin/PluginInstallerTest.php +++ b/tests/Composer/Test/Plugin/PluginInstallerTest.php @@ -242,7 +242,7 @@ class PluginInstallerTest extends TestCase $this->repository ->expects($this->any()) ->method('getPackages') - ->will($this->returnCallback(function() use($plugApiInternalPackage, $plugins) { + ->will($this->returnCallback(function () use ($plugApiInternalPackage, $plugins) { return array_merge(array($plugApiInternalPackage), $plugins); })); diff --git a/tests/Composer/Test/Repository/ComposerRepositoryTest.php b/tests/Composer/Test/Repository/ComposerRepositoryTest.php index 5109ee41f..6f21f9d9c 100644 --- a/tests/Composer/Test/Repository/ComposerRepositoryTest.php +++ b/tests/Composer/Test/Repository/ComposerRepositoryTest.php @@ -12,7 +12,6 @@ namespace Composer\Test\Repository; -use Composer\Repository\ComposerRepository; use Composer\IO\NullIO; use Composer\Test\Mock\FactoryMock; use Composer\TestCase; diff --git a/tests/Composer/Test/Util/RemoteFilesystemTest.php b/tests/Composer/Test/Util/RemoteFilesystemTest.php index 04502ebdc..1bb3e0689 100644 --- a/tests/Composer/Test/Util/RemoteFilesystemTest.php +++ b/tests/Composer/Test/Util/RemoteFilesystemTest.php @@ -13,7 +13,6 @@ namespace Composer\Test\Util; use Composer\Util\RemoteFilesystem; -use Installer\Exception; class RemoteFilesystemTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Composer/TestCase.php b/tests/Composer/TestCase.php index 760b57291..4abf1a7ff 100644 --- a/tests/Composer/TestCase.php +++ b/tests/Composer/TestCase.php @@ -13,7 +13,6 @@ namespace Composer; use Composer\Package\Version\VersionParser; -use Composer\Package\Package; use Composer\Package\AliasPackage; use Composer\Package\LinkConstraint\VersionConstraint; use Composer\Util\Filesystem;