@@ -74,9 +74,9 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | public function __call($name, $args) |
| 76 | 76 | { |
| 77 | - if(method_exists($this->instance, $name)){ |
|
| 77 | + if (method_exists($this->instance, $name)) { |
|
| 78 | 78 | return call_user_func_array([$this->instance, $name], $args); |
| 79 | - }else{ |
|
| 79 | + } else { |
|
| 80 | 80 | throw new \BadMethodCallException(sprintf('Method %s does not exists', $name)); |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -273,7 +273,7 @@ |
||
| 273 | 273 | |
| 274 | 274 | if (!is_dir($path)) { |
| 275 | 275 | throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94); |
| 276 | - }else{ |
|
| 276 | + } else{ |
|
| 277 | 277 | $size = Directory::dirSize($path); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 96 | 96 | try{ |
| 97 | 97 | self::$instances[ $instance ] = new $class($config); |
| 98 | - }catch(phpFastCacheDriverCheckException $e){ |
|
| 98 | + } catch(phpFastCacheDriverCheckException $e){ |
|
| 99 | 99 | $fallback = self::standardizeDriverName($config['fallback']); |
| 100 | 100 | if($fallback && $fallback !== $driver){ |
| 101 | 101 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
| 102 | 102 | self::$instances[ $instance ] = new $class($config); |
| 103 | 103 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
| 104 | - }else{ |
|
| 104 | + } else{ |
|
| 105 | 105 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | self::$config = array_merge(self::$config, $name); |
| 199 | 199 | } else if (is_string($name)){ |
| 200 | 200 | self::$config[ $name ] = $value; |
| 201 | - }else{ |
|
| 201 | + } else{ |
|
| 202 | 202 | throw new \InvalidArgumentException('Invalid variable type: $name'); |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | * @var array |
| 58 | 58 | */ |
| 59 | 59 | protected static $config = [ |
| 60 | - 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
| 61 | - 'ignoreSymfonyNotice' => false,// Ignore Symfony notice for Symfony project which do not makes use of PhpFastCache's Symfony Bundle |
|
| 62 | - 'defaultTtl' => 900,// Default time-to-live in second |
|
| 63 | - 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
| 64 | - 'default_chmod' => 0777, // 0777 recommended |
|
| 65 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 66 | - 'fallback' => false, //Fall back when old driver is not support |
|
| 67 | - 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
| 68 | - 'compress_data' => false, // compress stored data, if the backend supports it |
|
| 60 | + 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
| 61 | + 'ignoreSymfonyNotice' => false,// Ignore Symfony notice for Symfony project which do not makes use of PhpFastCache's Symfony Bundle |
|
| 62 | + 'defaultTtl' => 900,// Default time-to-live in second |
|
| 63 | + 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
| 64 | + 'default_chmod' => 0777, // 0777 recommended |
|
| 65 | + 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 66 | + 'fallback' => false, //Fall back when old driver is not support |
|
| 67 | + 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
| 68 | + 'compress_data' => false, // compress stored data, if the backend supports it |
|
| 69 | 69 | ]; |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } else if(++$badPracticeOmeter[$driver] >= 5){ |
| 119 | - trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
| 119 | + trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
| 120 | 120 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -227,23 +227,23 @@ discard block |
||
| 227 | 227 | public static function getStaticSystemDrivers() |
| 228 | 228 | { |
| 229 | 229 | return [ |
| 230 | - 'Sqlite', |
|
| 231 | - 'Files', |
|
| 232 | - 'Apc', |
|
| 233 | - 'Apcu', |
|
| 234 | - 'Memcache', |
|
| 235 | - 'Memcached', |
|
| 236 | - 'Couchbase', |
|
| 237 | - 'Mongodb', |
|
| 238 | - 'Predis', |
|
| 239 | - 'Redis', |
|
| 240 | - 'Ssdb', |
|
| 241 | - 'Leveldb', |
|
| 242 | - 'Wincache', |
|
| 243 | - 'Xcache', |
|
| 244 | - 'Zenddisk', |
|
| 245 | - 'Zendshm', |
|
| 246 | - 'Devnull', |
|
| 230 | + 'Sqlite', |
|
| 231 | + 'Files', |
|
| 232 | + 'Apc', |
|
| 233 | + 'Apcu', |
|
| 234 | + 'Memcache', |
|
| 235 | + 'Memcached', |
|
| 236 | + 'Couchbase', |
|
| 237 | + 'Mongodb', |
|
| 238 | + 'Predis', |
|
| 239 | + 'Redis', |
|
| 240 | + 'Ssdb', |
|
| 241 | + 'Leveldb', |
|
| 242 | + 'Wincache', |
|
| 243 | + 'Xcache', |
|
| 244 | + 'Zenddisk', |
|
| 245 | + 'Zendshm', |
|
| 246 | + 'Devnull', |
|
| 247 | 247 | ]; |
| 248 | 248 | } |
| 249 | 249 | |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | * @var array |
| 58 | 58 | */ |
| 59 | 59 | protected static $config = [ |
| 60 | - 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
| 61 | - 'ignoreSymfonyNotice' => false,// Ignore Symfony notice for Symfony project which do not makes use of PhpFastCache's Symfony Bundle |
|
| 62 | - 'defaultTtl' => 900,// Default time-to-live in second |
|
| 63 | - 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
| 60 | + 'securityKey' => 'auto', // The securityKey that will be used to create sub-directory |
|
| 61 | + 'ignoreSymfonyNotice' => false, // Ignore Symfony notice for Symfony project which do not makes use of PhpFastCache's Symfony Bundle |
|
| 62 | + 'defaultTtl' => 900, // Default time-to-live in second |
|
| 63 | + 'htaccess' => true, // Auto-generate .htaccess if tit is missing |
|
| 64 | 64 | 'default_chmod' => 0777, // 0777 recommended |
| 65 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
| 65 | + 'path' => '', // if not set will be the value of sys_get_temp_dir() |
|
| 66 | 66 | 'fallback' => false, //Fall back when old driver is not support |
| 67 | 67 | 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
| 68 | 68 | 'compress_data' => false, // compress stored data, if the backend supports it |
@@ -97,30 +97,30 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $instance = crc32($driver . serialize($config)); |
| 100 | - if (!isset(self::$instances[ $instance ])) { |
|
| 100 | + if (!isset(self::$instances[$instance])) { |
|
| 101 | 101 | $badPracticeOmeter[$driver] = 1; |
| 102 | - if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){ |
|
| 102 | + if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
| 103 | 103 | trigger_error('A Symfony Bundle to make the PhpFastCache integration more easier is now available here: https://github.com/PHPSocialNetwork/phpfastcache-bundle', E_USER_NOTICE); |
| 104 | 104 | } |
| 105 | 105 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 106 | - try{ |
|
| 107 | - self::$instances[ $instance ] = new $class($config); |
|
| 108 | - }catch(phpFastCacheDriverCheckException $e){ |
|
| 106 | + try { |
|
| 107 | + self::$instances[$instance] = new $class($config); |
|
| 108 | + } catch (phpFastCacheDriverCheckException $e) { |
|
| 109 | 109 | $fallback = self::standardizeDriverName($config['fallback']); |
| 110 | - if($fallback && $fallback !== $driver){ |
|
| 110 | + if ($fallback && $fallback !== $driver) { |
|
| 111 | 111 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
| 112 | - self::$instances[ $instance ] = new $class($config); |
|
| 112 | + self::$instances[$instance] = new $class($config); |
|
| 113 | 113 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
| 114 | - }else{ |
|
| 114 | + } else { |
|
| 115 | 115 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | - } else if(++$badPracticeOmeter[$driver] >= 5){ |
|
| 118 | + } else if (++$badPracticeOmeter[$driver] >= 5) { |
|
| 119 | 119 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 120 | 120 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - return self::$instances[ $instance ]; |
|
| 123 | + return self::$instances[$instance]; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public static function __callStatic($name, $arguments) |
| 155 | 155 | { |
| 156 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 156 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
| 157 | 157 | |
| 158 | 158 | return self::getInstance($name, $options); |
| 159 | 159 | } |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | { |
| 207 | 207 | if (is_array($name)) { |
| 208 | 208 | self::$config = array_merge(self::$config, $name); |
| 209 | - } else if (is_string($name)){ |
|
| 210 | - self::$config[ $name ] = $value; |
|
| 211 | - }else{ |
|
| 209 | + } else if (is_string($name)) { |
|
| 210 | + self::$config[$name] = $value; |
|
| 211 | + } else { |
|
| 212 | 212 | throw new \InvalidArgumentException('Invalid variable type: $name'); |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -185,9 +185,9 @@ |
||
| 185 | 185 | protected static function cleanFileName($filename) |
| 186 | 186 | { |
| 187 | 187 | $regex = [ |
| 188 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 189 | - '/\.$/', |
|
| 190 | - '/^\./', |
|
| 188 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 189 | + '/\.$/', |
|
| 190 | + '/^\./', |
|
| 191 | 191 | ]; |
| 192 | 192 | $replace = ['-', '', '']; |
| 193 | 193 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | - * @param $keyword |
|
| 144 | + * @param string|false $keyword |
|
| 145 | 145 | * @param bool $skip |
| 146 | 146 | * @return string |
| 147 | 147 | * @throws phpFastCacheDriverException |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * @param $filename |
| 190 | - * @return mixed |
|
| 190 | + * @return string |
|
| 191 | 191 | */ |
| 192 | 192 | protected static function cleanFileName($filename) |
| 193 | 193 | { |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
| 205 | - * @param $path |
|
| 205 | + * @param string $path |
|
| 206 | 206 | * @param bool $create |
| 207 | 207 | * @throws \Exception |
| 208 | 208 | */ |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | * Calculate the security key |
| 41 | 41 | */ |
| 42 | 42 | { |
| 43 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
| 43 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
| 44 | 44 | if (!$securityKey || $securityKey === 'auto') { |
| 45 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
| 46 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
| 45 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 46 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
| 47 | 47 | } else { |
| 48 | 48 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
| 49 | 49 | } |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | * with the security key and the driver name |
| 59 | 59 | */ |
| 60 | 60 | $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR; |
| 61 | - if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) { |
|
| 61 | + if (empty($this->config['path']) || !is_string($this->config['path'])) { |
|
| 62 | 62 | $path = $tmp_dir; |
| 63 | 63 | } else { |
| 64 | - $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR; |
|
| 64 | + $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR; |
|
| 65 | 65 | } |
| 66 | 66 | $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName(); |
| 67 | 67 | $full_path = Directory::getAbsolutePath($path . $path_suffix); |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | * return the temp dir |
| 75 | 75 | */ |
| 76 | 76 | if ($readonly === true) { |
| 77 | - if(!@file_exists($full_path) || !@is_writable($full_path)){ |
|
| 77 | + if (!@file_exists($full_path) || !@is_writable($full_path)) { |
|
| 78 | 78 | return $full_path_tmp; |
| 79 | 79 | } |
| 80 | 80 | return $full_path; |
| 81 | - }else{ |
|
| 82 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 81 | + } else { |
|
| 82 | + if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 83 | 83 | if (!@file_exists($full_path)) { |
| 84 | 84 | @mkdir($full_path, $this->setChmodAuto(), true); |
| 85 | 85 | } elseif (!@is_writable($full_path)) { |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
| 103 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 102 | + $this->tmp[$full_path_hash] = $full_path; |
|
| 103 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | return realpath($full_path); |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function setChmodAuto() |
| 176 | 176 | { |
| 177 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
| 177 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
| 178 | 178 | return 0777; |
| 179 | 179 | } else { |
| 180 | - return $this->config[ 'default_chmod' ]; |
|
| 180 | + return $this->config['default_chmod']; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | if ($create === true) { |
| 208 | 208 | if (!is_writable($path)) { |
| 209 | 209 | try { |
| 210 | - if(!chmod($path, 0777)){ |
|
| 210 | + if (!chmod($path, 0777)) { |
|
| 211 | 211 | throw new phpFastCacheDriverException('Chmod failed on : ' . $path); |
| 212 | 212 | } |
| 213 | 213 | } catch (phpFastCacheDriverException $e) { |
@@ -78,11 +78,11 @@ |
||
| 78 | 78 | return $full_path_tmp; |
| 79 | 79 | } |
| 80 | 80 | return $full_path; |
| 81 | - }else{ |
|
| 81 | + } else{ |
|
| 82 | 82 | if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
| 83 | 83 | if (!@file_exists($full_path)) { |
| 84 | 84 | @mkdir($full_path, $this->setChmodAuto(), true); |
| 85 | - }elseif (!@is_writable($full_path)) { |
|
| 85 | + } elseif (!@is_writable($full_path)) { |
|
| 86 | 86 | if (!@chmod($full_path, $this->setChmodAuto())) |
| 87 | 87 | { |
| 88 | 88 | /** |
@@ -18,9 +18,9 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * Register Autoload |
| 20 | 20 | */ |
| 21 | -spl_autoload_register(function ($entity) { |
|
| 21 | +spl_autoload_register(function($entity) { |
|
| 22 | 22 | $module = explode('\\', $entity, 2); |
| 23 | - if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
|
| 23 | + if (!in_array($module[0], ['phpFastCache', 'Psr'])) { |
|
| 24 | 24 | /** |
| 25 | 25 | * Not a part of phpFastCache file |
| 26 | 26 | * then we return here. |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | if (is_readable($path)) { |
| 34 | 34 | require_once $path; |
| 35 | - }else{ |
|
| 35 | + } else { |
|
| 36 | 36 | trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR); |
| 37 | 37 | return; |
| 38 | 38 | } |
@@ -273,7 +273,7 @@ |
||
| 273 | 273 | |
| 274 | 274 | if (!is_dir($path)) { |
| 275 | 275 | throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94); |
| 276 | - }else{ |
|
| 276 | + } else{ |
|
| 277 | 277 | $size = Directory::dirSize($path); |
| 278 | 278 | } |
| 279 | 279 | |
@@ -46,6 +46,6 @@ |
||
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | 48 | if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) { |
| 49 | - trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
|
| 49 | + trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
|
| 50 | 50 | E_USER_WARNING); |
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | if (!class_exists('phpFastCache\CacheManager')) { |
| 19 | 19 | echo "[FAIL] Autoload failed to find the CacheManager\n"; |
| 20 | 20 | $status = 255; |
| 21 | -}else{ |
|
| 21 | +} else { |
|
| 22 | 22 | echo "[PASS] Autoload successfully found the CacheManager\n"; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | if (!interface_exists('Psr\Cache\CacheItemInterface')) { |
| 29 | 29 | echo "[FAIL] Autoload failed to find the Psr CacheItemInterface\n"; |
| 30 | 30 | $status = 255; |
| 31 | -}else{ |
|
| 31 | +} else { |
|
| 32 | 32 | echo "[PASS] Autoload successfully found the Psr CacheItemInterface\n"; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | if (!class_exists('phpFastCache\CacheManager')) { |
| 19 | 19 | echo "[FAIL] Autoload failed to find the CacheManager\n"; |
| 20 | 20 | $status = 255; |
| 21 | -}else{ |
|
| 21 | +} else{ |
|
| 22 | 22 | echo "[PASS] Autoload successfully found the CacheManager\n"; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | if (!interface_exists('Psr\Cache\CacheItemInterface')) { |
| 29 | 29 | echo "[FAIL] Autoload failed to find the Psr CacheItemInterface\n"; |
| 30 | 30 | $status = 255; |
| 31 | -}else{ |
|
| 31 | +} else{ |
|
| 32 | 32 | echo "[PASS] Autoload successfully found the Psr CacheItemInterface\n"; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -42,10 +42,10 @@ |
||
| 42 | 42 | if (!is_object($driverInstance->getItem('test'))) { |
| 43 | 43 | echo '[FAIL] $driverInstance->getItem() returned an invalid var type:' . gettype($driverInstance) . "\n"; |
| 44 | 44 | $status = 1; |
| 45 | -}else if(!($driverInstance->getItem('test') instanceof ExtendedCacheItemInterface)){ |
|
| 45 | +} else if (!($driverInstance->getItem('test') instanceof ExtendedCacheItemInterface)) { |
|
| 46 | 46 | echo '[FAIL] $driverInstance->getItem() returned an invalid class that does not implements ExtendedCacheItemInterface: ' . get_class($driverInstance) . "\n"; |
| 47 | 47 | $status = 1; |
| 48 | -}else{ |
|
| 48 | +} else { |
|
| 49 | 49 | echo '[PASS] $driverInstance->getItem() returned a valid class that implements ExtendedCacheItemInterface: ' . get_class($driverInstance) . "\n"; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -42,10 +42,10 @@ |
||
| 42 | 42 | if (!is_object($driverInstance->getItem('test'))) { |
| 43 | 43 | echo '[FAIL] $driverInstance->getItem() returned an invalid var type:' . gettype($driverInstance) . "\n"; |
| 44 | 44 | $status = 1; |
| 45 | -}else if(!($driverInstance->getItem('test') instanceof ExtendedCacheItemInterface)){ |
|
| 45 | +} else if(!($driverInstance->getItem('test') instanceof ExtendedCacheItemInterface)){ |
|
| 46 | 46 | echo '[FAIL] $driverInstance->getItem() returned an invalid class that does not implements ExtendedCacheItemInterface: ' . get_class($driverInstance) . "\n"; |
| 47 | 47 | $status = 1; |
| 48 | -}else{ |
|
| 48 | +} else{ |
|
| 49 | 49 | echo '[PASS] $driverInstance->getItem() returned a valid class that implements ExtendedCacheItemInterface: ' . get_class($driverInstance) . "\n"; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * @return int|bool Return size in octet or false if no information available |
|
| 55 | + * @return string Return size in octet or false if no information available |
|
| 56 | 56 | */ |
| 57 | 57 | public function getSize() |
| 58 | 58 | { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * @return mixed |
|
| 63 | + * @return string |
|
| 64 | 64 | */ |
| 65 | 65 | public function getData() |
| 66 | 66 | { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * @param $info |
|
| 71 | + * @param string $info |
|
| 72 | 72 | * @return $this |
| 73 | 73 | */ |
| 74 | 74 | public function setInfo($info) |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | if (!is_object($driverInstance)) { |
| 25 | 25 | echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n"; |
| 26 | 26 | $status = 1; |
| 27 | -}else if(!($driverInstance instanceof CacheItemPoolInterface)){ |
|
| 27 | +} else if(!($driverInstance instanceof CacheItemPoolInterface)){ |
|
| 28 | 28 | echo '[FAIL] CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance) . "\n"; |
| 29 | 29 | $status = 1; |
| 30 | -}else{ |
|
| 30 | +} else{ |
|
| 31 | 31 | $key = 'test_attaching_detaching'; |
| 32 | 32 | |
| 33 | 33 | $itemDetached = $driverInstance->getItem($key); |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | if(!$driverInstance->isAttached($itemDetached)) |
| 38 | 38 | { |
| 39 | 39 | echo '[PASS] ExtendedCacheItemPoolInterface::isAttached() identified $itemDetached as being detached.' . "\n"; |
| 40 | - } |
|
| 41 | - else |
|
| 40 | + } else |
|
| 42 | 41 | { |
| 43 | 42 | echo '[FAIL] ExtendedCacheItemPoolInterface::isAttached() failed to identify $itemDetached as to be detached.' . "\n"; |
| 44 | 43 | $status = 1; |
@@ -48,7 +47,7 @@ discard block |
||
| 48 | 47 | $driverInstance->attachItem($itemDetached); |
| 49 | 48 | echo '[FAIL] ExtendedCacheItemPoolInterface::attachItem() attached $itemDetached without trowing an error.' . "\n"; |
| 50 | 49 | $status = 1; |
| 51 | - }catch(\LogicException $e){ |
|
| 50 | + } catch(\LogicException $e){ |
|
| 52 | 51 | echo '[PASS] ExtendedCacheItemPoolInterface::attachItem() failed to attach $itemDetached by trowing a LogicException exception.' . "\n"; |
| 53 | 52 | } |
| 54 | 53 | |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | if (!is_object($driverInstance)) { |
| 25 | 25 | echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n"; |
| 26 | 26 | $status = 1; |
| 27 | -}else if(!($driverInstance instanceof CacheItemPoolInterface)){ |
|
| 27 | +} else if (!($driverInstance instanceof CacheItemPoolInterface)) { |
|
| 28 | 28 | echo '[FAIL] CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance) . "\n"; |
| 29 | 29 | $status = 1; |
| 30 | -}else{ |
|
| 30 | +} else { |
|
| 31 | 31 | $key = 'test_attaching_detaching'; |
| 32 | 32 | |
| 33 | 33 | $itemDetached = $driverInstance->getItem($key); |
| 34 | 34 | $driverInstance->detachItem($itemDetached); |
| 35 | 35 | $itemAttached = $driverInstance->getItem($key); |
| 36 | 36 | |
| 37 | - if($driverInstance->isAttached($itemDetached) !== true) |
|
| 37 | + if ($driverInstance->isAttached($itemDetached) !== true) |
|
| 38 | 38 | { |
| 39 | 39 | echo '[PASS] ExtendedCacheItemPoolInterface::isAttached() identified $itemDetached as being detached.' . "\n"; |
| 40 | 40 | } |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | $status = 1; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - try{ |
|
| 47 | + try { |
|
| 48 | 48 | $driverInstance->attachItem($itemDetached); |
| 49 | 49 | echo '[FAIL] ExtendedCacheItemPoolInterface::attachItem() attached $itemDetached without trowing an error.' . "\n"; |
| 50 | 50 | $status = 1; |
| 51 | - }catch(\LogicException $e){ |
|
| 51 | + } catch (\LogicException $e) { |
|
| 52 | 52 | echo '[PASS] ExtendedCacheItemPoolInterface::attachItem() failed to attach $itemDetached by trowing a LogicException exception.' . "\n"; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -334,7 +334,7 @@ |
||
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @internal This method de-register an item from $this->itemInstances |
| 337 | - * @param CacheItemInterface|string $item |
|
| 337 | + * @param CacheItemInterface $item |
|
| 338 | 338 | * @throws \InvalidArgumentException |
| 339 | 339 | */ |
| 340 | 340 | protected function deregisterItem($item) |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512) |
| 49 | 49 | { |
| 50 | - $callback = function(CacheItemInterface $item){ |
|
| 50 | + $callback = function(CacheItemInterface $item) { |
|
| 51 | 51 | return $item->get(); |
| 52 | 52 | }; |
| 53 | 53 | return json_encode(array_map($callback, array_values($this->getItems($keys))), $option, $depth); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * #headache |
| 77 | 77 | */ |
| 78 | - return array_filter($this->getItems(array_unique(array_keys($items))), function(ExtendedCacheItemInterface $item){ |
|
| 78 | + return array_filter($this->getItems(array_unique(array_keys($items))), function(ExtendedCacheItemInterface $item) { |
|
| 79 | 79 | return $item->isHit(); |
| 80 | 80 | }); |
| 81 | 81 | } else { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function getItemsByTagsAsJsonString(array $tagNames, $option = 0, $depth = 512) |
| 119 | 119 | { |
| 120 | - $callback = function(CacheItemInterface $item){ |
|
| 120 | + $callback = function(CacheItemInterface $item) { |
|
| 121 | 121 | return $item->get(); |
| 122 | 122 | }; |
| 123 | 123 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | public function detachItem(CacheItemInterface $item) |
| 304 | 304 | { |
| 305 | - if(isset($this->itemInstances[$item->getKey()])){ |
|
| 305 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
| 306 | 306 | $this->deregisterItem($item); |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | public function attachItem(CacheItemInterface $item) |
| 326 | 326 | { |
| 327 | - if(isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 327 | + if (isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
| 328 | 328 | throw new \LogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.'); |
| 329 | - }else{ |
|
| 329 | + } else { |
|
| 330 | 330 | $this->itemInstances[$item->getKey()] = $item; |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | protected function deregisterItem($item) |
| 341 | 341 | { |
| 342 | - if($item instanceof CacheItemInterface){ |
|
| 343 | - unset($this->itemInstances[ $item->getKey() ]); |
|
| 342 | + if ($item instanceof CacheItemInterface) { |
|
| 343 | + unset($this->itemInstances[$item->getKey()]); |
|
| 344 | 344 | |
| 345 | - }else if(is_string($item)){ |
|
| 346 | - unset($this->itemInstances[ $item ]); |
|
| 347 | - }else{ |
|
| 345 | + } else if (is_string($item)) { |
|
| 346 | + unset($this->itemInstances[$item]); |
|
| 347 | + } else { |
|
| 348 | 348 | throw new \InvalidArgumentException('Invalid type for $item variable'); |
| 349 | 349 | } |
| 350 | - if(gc_enabled()){ |
|
| 350 | + if (gc_enabled()) { |
|
| 351 | 351 | gc_collect_cycles(); |
| 352 | 352 | } |
| 353 | 353 | } |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function isAttached(CacheItemInterface $item) |
| 365 | 365 | { |
| 366 | - if(isset($this->itemInstances[$item->getKey()])){ |
|
| 367 | - return spl_object_hash($item) === spl_object_hash($this->itemInstances[ $item->getKey() ]); |
|
| 366 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
| 367 | + return spl_object_hash($item) === spl_object_hash($this->itemInstances[$item->getKey()]); |
|
| 368 | 368 | } |
| 369 | 369 | return null; |
| 370 | 370 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | { |
| 327 | 327 | if(isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
| 328 | 328 | throw new \LogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.'); |
| 329 | - }else{ |
|
| 329 | + } else{ |
|
| 330 | 330 | $this->itemInstances[$item->getKey()] = $item; |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -342,9 +342,9 @@ discard block |
||
| 342 | 342 | if($item instanceof CacheItemInterface){ |
| 343 | 343 | unset($this->itemInstances[ $item->getKey() ]); |
| 344 | 344 | |
| 345 | - }else if(is_string($item)){ |
|
| 345 | + } else if(is_string($item)){ |
|
| 346 | 346 | unset($this->itemInstances[ $item ]); |
| 347 | - }else{ |
|
| 347 | + } else{ |
|
| 348 | 348 | throw new \InvalidArgumentException('Invalid type for $item variable'); |
| 349 | 349 | } |
| 350 | 350 | if(gc_enabled()){ |