@@ -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 the sub-directory |
|
| 61 | - 'ignoreSymfonyNotice' => false, // Ignore Symfony notices for Symfony projects that do not makes use of PhpFastCache's Symfony Bundle |
|
| 62 | - 'defaultTtl' => 900, // Default time-to-live in seconds |
|
| 63 | - 'htaccess' => true, // Auto-generate .htaccess if it is missing |
|
| 64 | - 'default_chmod' => 0777, // 0777 is 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 supported |
|
| 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 the sub-directory |
|
| 61 | + 'ignoreSymfonyNotice' => false, // Ignore Symfony notices for Symfony projects that do not makes use of PhpFastCache's Symfony Bundle |
|
| 62 | + 'defaultTtl' => 900, // Default time-to-live in seconds |
|
| 63 | + 'htaccess' => true, // Auto-generate .htaccess if it is missing |
|
| 64 | + 'default_chmod' => 0777, // 0777 is 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 supported |
|
| 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 | |
@@ -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 | } |