1
0
Fork 0
pull/1455/head
Jordi Boggiano 2013-01-05 20:01:58 +01:00
parent 6ce285b70c
commit 514a3cde77
14 changed files with 31 additions and 29 deletions

View File

@ -52,7 +52,7 @@ class ClassMapGenerator
if (is_string($path)) { if (is_string($path)) {
if (is_file($path)) { if (is_file($path)) {
$path = array(new \SplFileInfo($path)); $path = array(new \SplFileInfo($path));
} else if (is_dir($path)) { } elseif (is_dir($path)) {
$path = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); $path = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
} else { } else {
throw new \RuntimeException( throw new \RuntimeException(

View File

@ -31,8 +31,8 @@ class Cache
/** /**
* @param IOInterface $io * @param IOInterface $io
* @param string $cacheDir location of the cache * @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 $whitelist List of characters that are allowed in path names (used in a regex character class)
* @param Filesystem $filesystem optional filesystem instance * @param Filesystem $filesystem optional filesystem instance
*/ */
public function __construct(IOInterface $io, $cacheDir, $whitelist = 'a-z0-9.', Filesystem $filesystem = null) public function __construct(IOInterface $io, $cacheDir, $whitelist = 'a-z0-9.', Filesystem $filesystem = null)
@ -114,7 +114,7 @@ class Cache
return false; return false;
} }
public function gc($ttl, $cacheMaxSize) public function gc($ttl, $maxSize)
{ {
$expire = new \DateTime(); $expire = new \DateTime();
$expire->modify('-'.$ttl.' seconds'); $expire->modify('-'.$ttl.' seconds');
@ -124,12 +124,12 @@ class Cache
unlink($file->getRealPath()); unlink($file->getRealPath());
} }
$totalCacheSize = $this->filesystem->size($this->root); $totalSize = $this->filesystem->size($this->root);
if ($totalCacheSize > $cacheMaxSize) { if ($totalSize > $maxSize) {
$iterator = $this->getFinder()->sortByAccessedTime()->getIterator(); $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
while ($totalCacheSize > $cacheMaxSize && $iterator->valid()) { while ($totalSize > $maxSize && $iterator->valid()) {
$filepath = $iterator->current()->getRealPath(); $filepath = $iterator->current()->getRealPath();
$totalCacheSize -= $this->filesystem->size($filepath); $totalSize -= $this->filesystem->size($filepath);
unlink($filepath); unlink($filepath);
$iterator->next(); $iterator->next();
} }

View File

@ -150,10 +150,10 @@ EOT
/** /**
* finds a package by name and version if provided * finds a package by name and version if provided
* *
* @param RepositoryInterface $installedRepo * @param RepositoryInterface $installedRepo
* @param RepositoryInterface $repos * @param RepositoryInterface $repos
* @param string $name * @param string $name
* @param string $version * @param string $version
* @return array array(CompletePackageInterface, array of versions) * @return array array(CompletePackageInterface, array of versions)
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

View File

@ -141,7 +141,7 @@ class Config
case 'cache-files-maxsize': case 'cache-files-maxsize':
if (!preg_match('/^\s*(\d+)\s*([kmg]ib)?\s*$/i', $this->config[$key], $matches)) { if (!preg_match('/^\s*(\d+)\s*([kmg]ib)?\s*$/i', $this->config[$key], $matches)) {
throw new \RuntimeException( 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]; $size = $matches[1];
@ -155,6 +155,7 @@ class Config
$size *= 1024; $size *= 1024;
} }
} }
return $size; return $size;
case 'cache-files-ttl': case 'cache-files-ttl':

View File

@ -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()) public function __construct(array $styles = array())
{ {

View File

@ -204,7 +204,7 @@ class Solver
* Evaluates each term affected by the decision (linked through watches) * Evaluates each term affected by the decision (linked through watches)
* If we find unit rules we make new decisions based on them * 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. * @return Rule|null A rule on conflict, otherwise null.
*/ */
protected function propagate($level) protected function propagate($level)

View File

@ -127,10 +127,10 @@ class PearPackageExtractor
/** /**
* Builds list of copy and list of remove actions that would transform extracted PEAR tarball into installed package. * 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 string $source string path to extracted files
* @param array $roles array [role => roleRoot] relative root for files having that role * @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 * @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 * @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) * path, and target is destination of file (also relative to $source path)
* @throws \RuntimeException * @throws \RuntimeException
*/ */

View File

@ -284,8 +284,8 @@ class Factory
} }
/** /**
* @param IO\IOInterface $io * @param IO\IOInterface $io
* @param Config $config * @param Config $config
* @return Downloader\DownloadManager * @return Downloader\DownloadManager
*/ */
public function createDownloadManager(IOInterface $io, Config $config) public function createDownloadManager(IOInterface $io, Config $config)

View File

@ -812,7 +812,7 @@ class Installer
/** /**
* Whether or not generated autoloader are optimized * Whether or not generated autoloader are optimized
* *
* @param bool $optimizeAutoloader * @param bool $optimizeAutoloader
* @return Installer * @return Installer
*/ */
public function setOptimizeAutoloader($optimizeAutoloader = false) public function setOptimizeAutoloader($optimizeAutoloader = false)

View File

@ -340,7 +340,7 @@ class VersionParser
/** /**
* Parses a name/version pairs and returns an array of pairs + the * 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 * @return array[] array of arrays containing a name and (if provided) a version
*/ */
public function parseNameVersionPairs(array $pairs) public function parseNameVersionPairs(array $pairs)

View File

@ -84,8 +84,8 @@ class PearRepository extends ArrayRepository
/** /**
* Builds CompletePackages from PEAR package definition data. * Builds CompletePackages from PEAR package definition data.
* *
* @param ChannelInfo $channelInfo * @param ChannelInfo $channelInfo
* @param VersionParser $versionParser * @param VersionParser $versionParser
* @return CompletePackage * @return CompletePackage
*/ */
private function buildComposerPackages(ChannelInfo $channelInfo, VersionParser $versionParser) private function buildComposerPackages(ChannelInfo $channelInfo, VersionParser $versionParser)

View File

@ -47,7 +47,7 @@ class Filesystem
* Uses the process component if proc_open is enabled on the PHP * Uses the process component if proc_open is enabled on the PHP
* installation. * installation.
* *
* @param string $directory * @param string $directory
* @return bool * @return bool
*/ */
public function removeDirectory($directory) public function removeDirectory($directory)
@ -81,7 +81,7 @@ class Filesystem
* before directories, creating a single non-recursive loop * before directories, creating a single non-recursive loop
* to delete files/directories in the correct order. * to delete files/directories in the correct order.
* *
* @param string $directory * @param string $directory
* @return bool * @return bool
*/ */
public function removeDirectoryPhp($directory) public function removeDirectoryPhp($directory)
@ -284,6 +284,7 @@ class Filesystem
if (is_dir($path)) { if (is_dir($path)) {
return $this->directorySize($path); return $this->directorySize($path);
} }
return filesize($path); return filesize($path);
} }
@ -298,6 +299,7 @@ class Filesystem
$size += $file->getSize(); $size += $file->getSize();
} }
} }
return $size; return $size;
} }

View File

@ -7,4 +7,4 @@ class inner { }
<?php echo $defaultLocale ?> <?php echo $defaultLocale ?>
class trailing { } class trailing { }

View File

@ -128,4 +128,3 @@ class FilesystemTest extends TestCase
$this->assertGreaterThanOrEqual(10, $fs->size("$tmp/composer_testdir")); $this->assertGreaterThanOrEqual(10, $fs->size("$tmp/composer_testdir"));
} }
} }