From 514a3cde77d2ebe78fabb4ca966f5867f2cf9cb5 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 5 Jan 2013 20:01:58 +0100 Subject: [PATCH] CS fixes --- src/Composer/Autoload/ClassMapGenerator.php | 2 +- src/Composer/Cache.php | 14 +++++++------- src/Composer/Command/ShowCommand.php | 8 ++++---- src/Composer/Config.php | 3 ++- src/Composer/Console/HtmlOutputFormatter.php | 2 +- src/Composer/DependencyResolver/Solver.php | 2 +- src/Composer/Downloader/PearPackageExtractor.php | 8 ++++---- src/Composer/Factory.php | 4 ++-- src/Composer/Installer.php | 2 +- src/Composer/Package/Version/VersionParser.php | 2 +- src/Composer/Repository/PearRepository.php | 4 ++-- src/Composer/Util/Filesystem.php | 6 ++++-- .../Test/Autoload/Fixtures/template/template_3.php | 2 +- tests/Composer/Test/Util/FilesystemTest.php | 1 - 14 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 0a4db9bdc..cb8a548f2 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -52,7 +52,7 @@ class ClassMapGenerator if (is_string($path)) { if (is_file($path)) { $path = array(new \SplFileInfo($path)); - } else if (is_dir($path)) { + } elseif (is_dir($path)) { $path = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); } else { throw new \RuntimeException( diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index d2249127c..27007a0bb 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -31,8 +31,8 @@ class Cache /** * @param IOInterface $io - * @param string $cacheDir location of the cache - * @param string $whitelist List of characters that are allowed in path names (used in a regex character class) + * @param string $cacheDir location of the cache + * @param string $whitelist List of characters that are allowed in path names (used in a regex character class) * @param Filesystem $filesystem optional filesystem instance */ public function __construct(IOInterface $io, $cacheDir, $whitelist = 'a-z0-9.', Filesystem $filesystem = null) @@ -114,7 +114,7 @@ class Cache return false; } - public function gc($ttl, $cacheMaxSize) + public function gc($ttl, $maxSize) { $expire = new \DateTime(); $expire->modify('-'.$ttl.' seconds'); @@ -124,12 +124,12 @@ class Cache unlink($file->getRealPath()); } - $totalCacheSize = $this->filesystem->size($this->root); - if ($totalCacheSize > $cacheMaxSize) { + $totalSize = $this->filesystem->size($this->root); + if ($totalSize > $maxSize) { $iterator = $this->getFinder()->sortByAccessedTime()->getIterator(); - while ($totalCacheSize > $cacheMaxSize && $iterator->valid()) { + while ($totalSize > $maxSize && $iterator->valid()) { $filepath = $iterator->current()->getRealPath(); - $totalCacheSize -= $this->filesystem->size($filepath); + $totalSize -= $this->filesystem->size($filepath); unlink($filepath); $iterator->next(); } diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index ea3f9f38e..2f8a4585a 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -150,10 +150,10 @@ EOT /** * finds a package by name and version if provided * - * @param RepositoryInterface $installedRepo - * @param RepositoryInterface $repos - * @param string $name - * @param string $version + * @param RepositoryInterface $installedRepo + * @param RepositoryInterface $repos + * @param string $name + * @param string $version * @return array array(CompletePackageInterface, array of versions) * @throws \InvalidArgumentException */ diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 23be57468..6f34837b4 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -141,7 +141,7 @@ class Config case 'cache-files-maxsize': if (!preg_match('/^\s*(\d+)\s*([kmg]ib)?\s*$/i', $this->config[$key], $matches)) { throw new \RuntimeException( - "composer.json contains invalid 'cache-files-maxsize' value: {$this->config[$key]}" + "Could not parse the value of 'cache-files-maxsize' from your config: {$this->config[$key]}" ); } $size = $matches[1]; @@ -155,6 +155,7 @@ class Config $size *= 1024; } } + return $size; case 'cache-files-ttl': diff --git a/src/Composer/Console/HtmlOutputFormatter.php b/src/Composer/Console/HtmlOutputFormatter.php index 264377ee2..56652bb69 100644 --- a/src/Composer/Console/HtmlOutputFormatter.php +++ b/src/Composer/Console/HtmlOutputFormatter.php @@ -48,7 +48,7 @@ class HtmlOutputFormatter extends OutputFormatter ); /** - * @param array $styles Array of "name => FormatterStyle" instances + * @param array $styles Array of "name => FormatterStyle" instances */ public function __construct(array $styles = array()) { diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index 1d736d009..3c46c0c41 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -204,7 +204,7 @@ class Solver * Evaluates each term affected by the decision (linked through watches) * If we find unit rules we make new decisions based on them * - * @param integer $level + * @param integer $level * @return Rule|null A rule on conflict, otherwise null. */ protected function propagate($level) diff --git a/src/Composer/Downloader/PearPackageExtractor.php b/src/Composer/Downloader/PearPackageExtractor.php index 4cd7fea02..9268bd66d 100644 --- a/src/Composer/Downloader/PearPackageExtractor.php +++ b/src/Composer/Downloader/PearPackageExtractor.php @@ -127,10 +127,10 @@ class PearPackageExtractor /** * Builds list of copy and list of remove actions that would transform extracted PEAR tarball into installed package. * - * @param string $source string path to extracted files - * @param array $roles array [role => roleRoot] relative root for files having that role - * @param array $vars list of values can be used for replacement tasks - * @return array array of 'source' => 'target', where source is location of file in the tarball (relative to source + * @param string $source string path to extracted files + * @param array $roles array [role => roleRoot] relative root for files having that role + * @param array $vars list of values can be used for replacement tasks + * @return array array of 'source' => 'target', where source is location of file in the tarball (relative to source * path, and target is destination of file (also relative to $source path) * @throws \RuntimeException */ diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index d02f68d41..a5d6fb789 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -284,8 +284,8 @@ class Factory } /** - * @param IO\IOInterface $io - * @param Config $config + * @param IO\IOInterface $io + * @param Config $config * @return Downloader\DownloadManager */ public function createDownloadManager(IOInterface $io, Config $config) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index c6c0ebfa5..0f515b473 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -812,7 +812,7 @@ class Installer /** * Whether or not generated autoloader are optimized * - * @param bool $optimizeAutoloader + * @param bool $optimizeAutoloader * @return Installer */ public function setOptimizeAutoloader($optimizeAutoloader = false) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 43f2b87e2..ff60c3d0d 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -340,7 +340,7 @@ class VersionParser /** * Parses a name/version pairs and returns an array of pairs + the * - * @param array $pairs a set of package/version pairs separated by ":", "=" or " " + * @param array $pairs a set of package/version pairs separated by ":", "=" or " " * @return array[] array of arrays containing a name and (if provided) a version */ public function parseNameVersionPairs(array $pairs) diff --git a/src/Composer/Repository/PearRepository.php b/src/Composer/Repository/PearRepository.php index 8c5d9362b..82097e26a 100644 --- a/src/Composer/Repository/PearRepository.php +++ b/src/Composer/Repository/PearRepository.php @@ -84,8 +84,8 @@ class PearRepository extends ArrayRepository /** * Builds CompletePackages from PEAR package definition data. * - * @param ChannelInfo $channelInfo - * @param VersionParser $versionParser + * @param ChannelInfo $channelInfo + * @param VersionParser $versionParser * @return CompletePackage */ private function buildComposerPackages(ChannelInfo $channelInfo, VersionParser $versionParser) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index dfe0d07e3..aec3ef326 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -47,7 +47,7 @@ class Filesystem * Uses the process component if proc_open is enabled on the PHP * installation. * - * @param string $directory + * @param string $directory * @return bool */ public function removeDirectory($directory) @@ -81,7 +81,7 @@ class Filesystem * before directories, creating a single non-recursive loop * to delete files/directories in the correct order. * - * @param string $directory + * @param string $directory * @return bool */ public function removeDirectoryPhp($directory) @@ -284,6 +284,7 @@ class Filesystem if (is_dir($path)) { return $this->directorySize($path); } + return filesize($path); } @@ -298,6 +299,7 @@ class Filesystem $size += $file->getSize(); } } + return $size; } diff --git a/tests/Composer/Test/Autoload/Fixtures/template/template_3.php b/tests/Composer/Test/Autoload/Fixtures/template/template_3.php index 5a0d0e38b..7f20be82f 100644 --- a/tests/Composer/Test/Autoload/Fixtures/template/template_3.php +++ b/tests/Composer/Test/Autoload/Fixtures/template/template_3.php @@ -7,4 +7,4 @@ class inner { } -class trailing { } \ No newline at end of file +class trailing { } diff --git a/tests/Composer/Test/Util/FilesystemTest.php b/tests/Composer/Test/Util/FilesystemTest.php index 4874a165d..0694e24db 100644 --- a/tests/Composer/Test/Util/FilesystemTest.php +++ b/tests/Composer/Test/Util/FilesystemTest.php @@ -128,4 +128,3 @@ class FilesystemTest extends TestCase $this->assertGreaterThanOrEqual(10, $fs->size("$tmp/composer_testdir")); } } -