From 0688ac9ad88a03f1c56cfcd9e3c475b83301344d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 20 Apr 2012 10:25:04 -0400 Subject: Start comment cleanup of libraries --- system/libraries/Cache/drivers/Cache_apc.php | 2 +- system/libraries/Cache/drivers/Cache_dummy.php | 2 +- system/libraries/Cache/drivers/Cache_file.php | 16 +++++++++++---- system/libraries/Cache/drivers/Cache_memcached.php | 24 +++++++++++++++------- system/libraries/Cache/drivers/Cache_wincache.php | 2 +- 5 files changed, 32 insertions(+), 14 deletions(-) (limited to 'system/libraries/Cache/drivers') diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index 59ab67533..c85034f95 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -75,7 +75,7 @@ class CI_Cache_apc extends CI_Driver { * Delete from Cache * * @param mixed unique identifier of the item in the cache - * @param bool true on success/false on failure + * @return bool true on success/false on failure */ public function delete($id) { diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index e8b791c5b..3f2b4b956 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -70,7 +70,7 @@ class CI_Cache_dummy extends CI_Driver { * Delete from Cache * * @param mixed unique identifier of the item in the cache - * @param bool TRUE, simulating success + * @return bool TRUE, simulating success */ public function delete($id) { diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index dd27aa90e..ec4195278 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -36,8 +36,16 @@ */ class CI_Cache_file extends CI_Driver { + /** + * Directory in which to save cache files + * + * @var string + */ protected $_cache_path; + /** + * Initialize file-based cache + */ public function __construct() { $CI =& get_instance(); @@ -86,10 +94,10 @@ class CI_Cache_file extends CI_Driver { public function save($id, $data, $ttl = 60) { $contents = array( - 'time' => time(), - 'ttl' => $ttl, - 'data' => $data - ); + 'time' => time(), + 'ttl' => $ttl, + 'data' => $data + ); if (write_file($this->_cache_path.$id, serialize($contents))) { diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 4cd5f3d6f..813df4b1c 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -36,15 +36,25 @@ */ class CI_Cache_memcached extends CI_Driver { - protected $_memcached; // Holds the memcached object + /** + * Holds the memcached object + * + * @var object + */ + protected $_memcached; + /** + * Memcached configuration + * + * @var array + */ protected $_memcache_conf = array( - 'default' => array( - 'default_host' => '127.0.0.1', - 'default_port' => 11211, - 'default_weight' => 1 - ) - ); + 'default' => array( + 'default_host' => '127.0.0.1', + 'default_port' => 11211, + 'default_weight' => 1 + ) + ); /** * Fetch from cache diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php index b32e66a46..74048d564 100644 --- a/system/libraries/Cache/drivers/Cache_wincache.php +++ b/system/libraries/Cache/drivers/Cache_wincache.php @@ -78,7 +78,7 @@ class CI_Cache_wincache extends CI_Driver { * Delete from Cache * * @param mixed unique identifier of the item in the cache - * @param bool true on success/false on failure + * @return bool true on success/false on failure */ public function delete($id) { -- cgit v1.2.3-24-g4f1b From 5645479c622eb36cf9869797896dc0921568c4a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:32:19 +0300 Subject: Clean up the libraries --- system/libraries/Cache/drivers/Cache_file.php | 2 ++ system/libraries/Cache/drivers/Cache_memcached.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'system/libraries/Cache/drivers') diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index ec4195278..f0eb8bdf7 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -45,6 +45,8 @@ class CI_Cache_file extends CI_Driver { /** * Initialize file-based cache + * + * @return void */ public function __construct() { diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 813df4b1c..1df149c2d 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -77,7 +77,7 @@ class CI_Cache_memcached extends CI_Driver { * @param string unique identifier * @param mixed data being cached * @param int time to live - * @return bool true on success, false on failure + * @return bool true on success, false on failure */ public function save($id, $data, $ttl = 60) { @@ -99,7 +99,7 @@ class CI_Cache_memcached extends CI_Driver { * Delete from Cache * * @param mixed key to be deleted. - * @return bool true on success, false on failure + * @return bool true on success, false on failure */ public function delete($id) { -- cgit v1.2.3-24-g4f1b From d261b1e89c3d4d5191036d5a5660ef6764e593a0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:12:16 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/libraries --- system/libraries/Cache/drivers/Cache_file.php | 2 +- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Cache/drivers') diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index f0eb8bdf7..ce2c2b13a 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -53,7 +53,7 @@ class CI_Cache_file extends CI_Driver { $CI =& get_instance(); $CI->load->helper('file'); $path = $CI->config->item('cache_path'); - $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path; + $this->_cache_path = ($path === '') ? APPPATH.'cache/' : $path; } // ------------------------------------------------------------------------ diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 1df149c2d..bf90f6197 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -212,7 +212,7 @@ class CI_Cache_memcached extends CI_Driver { $cache_server['weight'] = $this->_memcache_conf['default']['default_weight']; } - if (get_class($this->_memcached) == 'Memcache') + if (get_class($this->_memcached) === 'Memcache') { // Third parameter is persistance and defaults to TRUE. $this->_memcached->addServer( -- cgit v1.2.3-24-g4f1b From 0f0b76980cb07f39b20c8591882aeae3854f016c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jun 2012 14:57:04 +0300 Subject: Deprecated do_hash() and read_file() in favor of hash() and file_get_contents() respectively --- system/libraries/Cache/drivers/Cache_file.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Cache/drivers') diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index ce2c2b13a..5170de821 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -71,7 +71,7 @@ class CI_Cache_file extends CI_Driver { return FALSE; } - $data = unserialize(read_file($this->_cache_path.$id)); + $data = unserialize(file_get_contents($this->_cache_path.$id)); if (time() > $data['time'] + $data['ttl']) { @@ -165,7 +165,7 @@ class CI_Cache_file extends CI_Driver { return FALSE; } - $data = unserialize(read_file($this->_cache_path.$id)); + $data = unserialize(file_get_contents($this->_cache_path.$id)); if (is_array($data)) { -- cgit v1.2.3-24-g4f1b