From 38a19388470de43b8c63bbf4dcb0b3d67abee993 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Wed, 1 May 2013 21:15:57 +0200 Subject: [PATCH] documentation and code style fixes --- framework/caching/ApcCache.php | 2 +- framework/caching/Cache.php | 2 +- framework/caching/DbCache.php | 2 +- framework/caching/DummyCache.php | 2 +- framework/caching/FileCache.php | 2 +- framework/caching/MemCache.php | 2 +- framework/caching/RedisCache.php | 6 +++--- framework/caching/WinCache.php | 2 +- framework/caching/XCache.php | 2 +- framework/caching/ZendDataCache.php | 2 +- framework/db/redis/Connection.php | 5 ++--- tests/unit/framework/caching/CacheTest.php | 1 + 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/framework/caching/ApcCache.php b/framework/caching/ApcCache.php index 391851d..ff3acf5 100644 --- a/framework/caching/ApcCache.php +++ b/framework/caching/ApcCache.php @@ -24,7 +24,7 @@ class ApcCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/Cache.php b/framework/caching/Cache.php index fb56d5e..7edeb19 100644 --- a/framework/caching/Cache.php +++ b/framework/caching/Cache.php @@ -247,7 +247,7 @@ abstract class Cache extends Component implements \ArrayAccess * This method should be implemented by child classes to retrieve the data * from specific cache storage. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ abstract protected function getValue($key); diff --git a/framework/caching/DbCache.php b/framework/caching/DbCache.php index dee8c7a..7e5f12d 100644 --- a/framework/caching/DbCache.php +++ b/framework/caching/DbCache.php @@ -92,7 +92,7 @@ class DbCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/DummyCache.php b/framework/caching/DummyCache.php index 359fa7c..8d900df 100644 --- a/framework/caching/DummyCache.php +++ b/framework/caching/DummyCache.php @@ -24,7 +24,7 @@ class DummyCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/FileCache.php b/framework/caching/FileCache.php index cc1a871..0c6d119 100644 --- a/framework/caching/FileCache.php +++ b/framework/caching/FileCache.php @@ -61,7 +61,7 @@ class FileCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/MemCache.php b/framework/caching/MemCache.php index efa89f5..da1e66d 100644 --- a/framework/caching/MemCache.php +++ b/framework/caching/MemCache.php @@ -145,7 +145,7 @@ class MemCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/RedisCache.php b/framework/caching/RedisCache.php index 5841d66..7651bde 100644 --- a/framework/caching/RedisCache.php +++ b/framework/caching/RedisCache.php @@ -49,11 +49,11 @@ class RedisCache extends Cache */ public $hostname = 'localhost'; /** - * @var int the to use for connecting to the redis server. Default port is 6379. + * @var int the port to use for connecting to the redis server. Default port is 6379. */ public $port = 6379; /** - * @var string the password to use to identify with the redis server. If not set, no AUTH command will be sent. + * @var string the password to use to authenticate with the redis server. If not set, no AUTH command will be sent. */ public $password; /** @@ -102,7 +102,7 @@ class RedisCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/WinCache.php b/framework/caching/WinCache.php index ee6b4a9..e9bf9f5 100644 --- a/framework/caching/WinCache.php +++ b/framework/caching/WinCache.php @@ -24,7 +24,7 @@ class WinCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/XCache.php b/framework/caching/XCache.php index 2108c4f..91f483b 100644 --- a/framework/caching/XCache.php +++ b/framework/caching/XCache.php @@ -25,7 +25,7 @@ class XCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/caching/ZendDataCache.php b/framework/caching/ZendDataCache.php index 5b41a8d..9ff2fd0 100644 --- a/framework/caching/ZendDataCache.php +++ b/framework/caching/ZendDataCache.php @@ -24,7 +24,7 @@ class ZendDataCache extends Cache * Retrieves a value from cache with a specified key. * This is the implementation of the method declared in the parent class. * @param string $key a unique key identifying the cached value - * @return string the value stored in cache, false if the value is not in the cache or expired. + * @return string|boolean the value stored in cache, false if the value is not in the cache or expired. */ protected function getValue($key) { diff --git a/framework/db/redis/Connection.php b/framework/db/redis/Connection.php index ea73fce..aa52179 100644 --- a/framework/db/redis/Connection.php +++ b/framework/db/redis/Connection.php @@ -379,14 +379,13 @@ class Connection extends Component case '-': // Error reply throw new Exception("Redis error: " . $line . "\nRedis command was: " . $command); case ':': // Integer reply - // no cast to integer as it is in the range of a signed 64 bit integer + // no cast to int as it is in the range of a signed 64 bit integer return $line; case '$': // Bulk replies if ($line == '-1') { return null; } - $data = fread($this->_socket, $line + 2); - if($data===false) { + if(($data = fread($this->_socket, $line + 2))===false) { throw new Exception("Failed to read from socket.\nRedis command was: " . $command); } return substr($data, 0, -2); diff --git a/tests/unit/framework/caching/CacheTest.php b/tests/unit/framework/caching/CacheTest.php index 2ce03a1..487a14e 100644 --- a/tests/unit/framework/caching/CacheTest.php +++ b/tests/unit/framework/caching/CacheTest.php @@ -117,6 +117,7 @@ abstract class CacheTest extends TestCase $this->assertEquals(42, $cache->get('number_test')); // should store data if it's not there yet + $this->assertFalse($cache->get('add_test')); $this->assertTrue($cache->add('add_test', 13)); $this->assertEquals(13, $cache->get('add_test')); }