main
Jordi Boggiano 12 years ago
parent 6ce285b70c
commit 514a3cde77

@ -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(

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

@ -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
*/

@ -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':

@ -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())
{

@ -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)

@ -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
*/

@ -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)

@ -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)

@ -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)

@ -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)

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

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

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

Loading…
Cancel
Save