From 79bf55e505eb2d2b0787e36b66393f16b5409951 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 10 Nov 2012 22:17:46 +0100 Subject: [PATCH] Standardize return valuse of the cache class --- src/Composer/Cache.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php index 7ae277089..5a46b9eb6 100644 --- a/src/Composer/Cache.php +++ b/src/Composer/Cache.php @@ -53,14 +53,19 @@ class Cache if ($this->enabled && file_exists($this->root . $file)) { return file_get_contents($this->root . $file); } + + return false; } public function write($file, $contents) { if ($this->enabled) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); - file_put_contents($this->root . $file, $contents); + + return file_put_contents($this->root . $file, $contents); } + + return false; } public function copyFrom($file, $source) @@ -68,8 +73,11 @@ class Cache if ($this->enabled) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); $this->filesystem->ensureDirectoryExists(dirname($this->root . $file)); - copy($source, $this->root . $file); + + return copy($source, $this->root . $file); } + + return false; } public function copyTo($file, $target) @@ -77,8 +85,11 @@ class Cache $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); if ($this->enabled && file_exists($this->root . $file)) { touch($this->root . $file); + return copy($this->root . $file, $target); } + + return false; } public function gc($expire) @@ -92,6 +103,8 @@ class Cache if ($this->enabled && file_exists($this->root . $file)) { return sha1_file($this->root . $file); } + + return false; } public function sha256($file) @@ -100,5 +113,7 @@ class Cache if ($this->enabled && file_exists($this->root . $file)) { return hash_file('sha256', $this->root . $file); } + + return false; } }