@@ -17,9 +17,9 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * Register Autoload |
| 19 | 19 | */ |
| 20 | -spl_autoload_register(function ($entity) { |
|
| 20 | +spl_autoload_register(function($entity) { |
|
| 21 | 21 | $module = explode('\\', $entity, 2); |
| 22 | - if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
|
| 22 | + if (!in_array($module[0], ['phpFastCache', 'Psr'])) { |
|
| 23 | 23 | /** |
| 24 | 24 | * Not a part of phpFastCache file |
| 25 | 25 | * then we return here. |
@@ -56,5 +56,5 @@ |
||
| 56 | 56 | |
| 57 | 57 | if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) { |
| 58 | 58 | trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
| 59 | - E_USER_WARNING); |
|
| 59 | + E_USER_WARNING); |
|
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * @return array |
|
| 173 | + * @return string[] |
|
| 174 | 174 | */ |
| 175 | 175 | public static function getStaticSystemDrivers() |
| 176 | 176 | { |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | - * @return array |
|
| 197 | + * @return string[] |
|
| 198 | 198 | */ |
| 199 | 199 | public static function getStaticAllDrivers() |
| 200 | 200 | { |
@@ -65,101 +65,101 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * Specify if the item must provide detailed creation/modification dates |
| 67 | 67 | */ |
| 68 | - 'itemDetailedDate' => false, |
|
| 68 | + 'itemDetailedDate' => false, |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * Automatically attempt to fallback to temporary directory |
| 72 | 72 | * if the cache fails to write on the specified directory |
| 73 | 73 | */ |
| 74 | - 'autoTmpFallback' => false, |
|
| 74 | + 'autoTmpFallback' => false, |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Provide a secure file manipulation mechanism, |
| 78 | 78 | * on intensive usage the performance can be affected. |
| 79 | 79 | */ |
| 80 | - 'secureFileManipulation' => false, |
|
| 80 | + 'secureFileManipulation' => false, |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Ignore Symfony notice for Symfony project which |
| 84 | 84 | * do not makes use of PhpFastCache's Symfony Bundle |
| 85 | 85 | */ |
| 86 | - 'ignoreSymfonyNotice' => false, |
|
| 86 | + 'ignoreSymfonyNotice' => false, |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Default time-to-live in second |
| 90 | 90 | */ |
| 91 | - 'defaultTtl' => 900, |
|
| 91 | + 'defaultTtl' => 900, |
|
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * Default key hash function |
| 95 | 95 | * (md5 by default) |
| 96 | 96 | */ |
| 97 | - 'defaultKeyHashFunction' => '', |
|
| 97 | + 'defaultKeyHashFunction' => '', |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * The securityKey that will be used |
| 101 | 101 | * to create sub-directory |
| 102 | 102 | * (Files-based drivers only) |
| 103 | 103 | */ |
| 104 | - 'securityKey' => 'Auto', |
|
| 104 | + 'securityKey' => 'Auto', |
|
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * Auto-generate .htaccess if it's missing |
| 108 | 108 | * (Files-based drivers only) |
| 109 | 109 | */ |
| 110 | - 'htaccess' => true, |
|
| 110 | + 'htaccess' => true, |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Default files chmod |
| 114 | 114 | * 0777 recommended |
| 115 | 115 | * (Files-based drivers only) |
| 116 | 116 | */ |
| 117 | - 'default_chmod' => 0777, |
|
| 117 | + 'default_chmod' => 0777, |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * The path where we will writecache files |
| 121 | 121 | * default value if empty: sys_get_temp_dir() |
| 122 | 122 | * (Files-based drivers only) |
| 123 | 123 | */ |
| 124 | - 'path' => '', |
|
| 124 | + 'path' => '', |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * Driver fallback in case of failure. |
| 128 | 128 | * Caution, in case of failure an E_WARNING |
| 129 | 129 | * error will always be raised |
| 130 | 130 | */ |
| 131 | - 'fallback' => false, |
|
| 131 | + 'fallback' => false, |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * Maximum size (bytes) of object store in memory |
| 135 | 135 | * (Memcache(d) drivers only) |
| 136 | 136 | */ |
| 137 | - 'limited_memory_each_object' => 4096, |
|
| 137 | + 'limited_memory_each_object' => 4096, |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * Compress stored data, if the backend supports it |
| 141 | 141 | * (Memcache(d) drivers only) |
| 142 | 142 | */ |
| 143 | - 'compress_data' => false, |
|
| 143 | + 'compress_data' => false, |
|
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | 146 | * Prevent cache slams when |
| 147 | 147 | * making use of heavy cache |
| 148 | 148 | * items |
| 149 | 149 | */ |
| 150 | - 'preventCacheSlams' => false, |
|
| 150 | + 'preventCacheSlams' => false, |
|
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * Cache slams timeout |
| 154 | 154 | * in seconds |
| 155 | 155 | */ |
| 156 | - 'cacheSlamsTimeout' => 15, |
|
| 156 | + 'cacheSlamsTimeout' => 15, |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * Cache slams timeout |
| 160 | 160 | * in seconds |
| 161 | 161 | */ |
| 162 | - 'cacheFileExtension' => 'txt', |
|
| 162 | + 'cacheFileExtension' => 'txt', |
|
| 163 | 163 | |
| 164 | 164 | ]; |
| 165 | 165 | |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | * @var array |
| 170 | 170 | */ |
| 171 | 171 | protected static $safeFileExtensions = [ |
| 172 | - 'txt', |
|
| 173 | - 'cache', |
|
| 174 | - 'db', |
|
| 175 | - 'pfc', |
|
| 172 | + 'txt', |
|
| 173 | + 'cache', |
|
| 174 | + 'db', |
|
| 175 | + 'pfc', |
|
| 176 | 176 | ]; |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $badPracticeOmeter[ $driver ] = 1; |
| 212 | 212 | if (!$config[ 'ignoreSymfonyNotice' ] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
| 213 | 213 | trigger_error('A Symfony Bundle to make the PhpFastCache integration more easier is now available here: https://github.com/PHPSocialNetwork/phpfastcache-bundle', |
| 214 | - E_USER_NOTICE); |
|
| 214 | + E_USER_NOTICE); |
|
| 215 | 215 | } |
| 216 | 216 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 217 | 217 | try { |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | self::$instances[ $instance ] = new $class($config); |
| 227 | 227 | self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
| 228 | 228 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, |
| 229 | - $fallback), E_USER_WARNING); |
|
| 229 | + $fallback), E_USER_WARNING); |
|
| 230 | 230 | } else { |
| 231 | 231 | throw new phpFastCacheInvalidConfigurationException('The fallback driver cannot be the same than the default driver', 0, $e); |
| 232 | 232 | } |
@@ -379,24 +379,24 @@ discard block |
||
| 379 | 379 | public static function getStaticSystemDrivers() |
| 380 | 380 | { |
| 381 | 381 | return [ |
| 382 | - 'Apc', |
|
| 383 | - 'Apcu', |
|
| 384 | - 'Cassandra', |
|
| 385 | - 'Couchbase', |
|
| 386 | - 'Couchdb', |
|
| 387 | - 'Devnull', |
|
| 388 | - 'Files', |
|
| 389 | - 'Leveldb', |
|
| 390 | - 'Memcache', |
|
| 391 | - 'Memcached', |
|
| 392 | - 'Memstatic', |
|
| 393 | - 'Mongodb', |
|
| 394 | - 'Predis', |
|
| 395 | - 'Redis', |
|
| 396 | - 'Ssdb', |
|
| 397 | - 'Sqlite', |
|
| 398 | - 'Wincache', |
|
| 399 | - 'Xcache', |
|
| 382 | + 'Apc', |
|
| 383 | + 'Apcu', |
|
| 384 | + 'Cassandra', |
|
| 385 | + 'Couchbase', |
|
| 386 | + 'Couchdb', |
|
| 387 | + 'Devnull', |
|
| 388 | + 'Files', |
|
| 389 | + 'Leveldb', |
|
| 390 | + 'Memcache', |
|
| 391 | + 'Memcached', |
|
| 392 | + 'Memstatic', |
|
| 393 | + 'Mongodb', |
|
| 394 | + 'Predis', |
|
| 395 | + 'Redis', |
|
| 396 | + 'Ssdb', |
|
| 397 | + 'Sqlite', |
|
| 398 | + 'Wincache', |
|
| 399 | + 'Xcache', |
|
| 400 | 400 | ]; |
| 401 | 401 | } |
| 402 | 402 | |
@@ -406,9 +406,9 @@ discard block |
||
| 406 | 406 | public static function getStaticAllDrivers() |
| 407 | 407 | { |
| 408 | 408 | return array_merge(self::getStaticSystemDrivers(), [ |
| 409 | - 'Devtrue', |
|
| 410 | - 'Devfalse', |
|
| 411 | - 'Cookie', |
|
| 409 | + 'Devtrue', |
|
| 410 | + 'Devfalse', |
|
| 411 | + 'Cookie', |
|
| 412 | 412 | ]); |
| 413 | 413 | } |
| 414 | 414 | |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | } |
| 510 | 510 | if (!in_array($configValue, self::$safeFileExtensions)) { |
| 511 | 511 | throw new phpFastCacheInvalidConfigurationException( |
| 512 | - "{$configName} is not a safe extension, currently allowed extension: " . implode(', ', self::$safeFileExtensions) |
|
| 512 | + "{$configName} is not a safe extension, currently allowed extension: " . implode(', ', self::$safeFileExtensions) |
|
| 513 | 513 | ); |
| 514 | 514 | } |
| 515 | 515 | break; |
@@ -207,24 +207,24 @@ discard block |
||
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $instance = crc32($driver . serialize($config)); |
| 210 | - if (!isset(self::$instances[ $instance ])) { |
|
| 211 | - $badPracticeOmeter[ $driver ] = 1; |
|
| 212 | - if (!$config[ 'ignoreSymfonyNotice' ] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
| 210 | + if (!isset(self::$instances[$instance])) { |
|
| 211 | + $badPracticeOmeter[$driver] = 1; |
|
| 212 | + if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
| 213 | 213 | trigger_error('A Symfony Bundle to make the PhpFastCache integration more easier is now available here: https://github.com/PHPSocialNetwork/phpfastcache-bundle', |
| 214 | 214 | E_USER_NOTICE); |
| 215 | 215 | } |
| 216 | 216 | $class = self::getNamespacePath() . $driver . '\Driver'; |
| 217 | 217 | try { |
| 218 | - self::$instances[ $instance ] = new $class($config); |
|
| 219 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 218 | + self::$instances[$instance] = new $class($config); |
|
| 219 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 220 | 220 | } catch (phpFastCacheDriverCheckException $e) { |
| 221 | - if ($config[ 'fallback' ]) { |
|
| 221 | + if ($config['fallback']) { |
|
| 222 | 222 | try { |
| 223 | - $fallback = self::standardizeDriverName($config[ 'fallback' ]); |
|
| 223 | + $fallback = self::standardizeDriverName($config['fallback']); |
|
| 224 | 224 | if ($fallback !== $driver) { |
| 225 | 225 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
| 226 | - self::$instances[ $instance ] = new $class($config); |
|
| 227 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 226 | + self::$instances[$instance] = new $class($config); |
|
| 227 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 228 | 228 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, |
| 229 | 229 | $fallback), E_USER_WARNING); |
| 230 | 230 | } else { |
@@ -237,14 +237,14 @@ discard block |
||
| 237 | 237 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | - } else if ($badPracticeOmeter[ $driver ] >= 5) { |
|
| 240 | + } else if ($badPracticeOmeter[$driver] >= 5) { |
|
| 241 | 241 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 242 | 242 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - $badPracticeOmeter[ $driver ]++; |
|
| 245 | + $badPracticeOmeter[$driver]++; |
|
| 246 | 246 | |
| 247 | - return self::$instances[ $instance ]; |
|
| 247 | + return self::$instances[$instance]; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | */ |
| 306 | 306 | public static function __callStatic($name, $arguments) |
| 307 | 307 | { |
| 308 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 308 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
| 309 | 309 | |
| 310 | 310 | return self::getInstance($name, $options); |
| 311 | 311 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | if (is_array($name)) { |
| 348 | 348 | self::$config = array_merge(self::$config, $name); |
| 349 | 349 | } else if (is_string($name)) { |
| 350 | - self::$config[ $name ] = $value; |
|
| 350 | + self::$config[$name] = $value; |
|
| 351 | 351 | } else { |
| 352 | 352 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
| 353 | 353 | } |
@@ -83,8 +83,8 @@ |
||
| 83 | 83 | |
| 84 | 84 | $files = new RecursiveIteratorIterator |
| 85 | 85 | ( |
| 86 | - new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
|
| 87 | - RecursiveIteratorIterator::CHILD_FIRST |
|
| 86 | + new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
|
| 87 | + RecursiveIteratorIterator::CHILD_FIRST |
|
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | foreach ($files as $fileinfo) { |
@@ -86,8 +86,7 @@ discard block |
||
| 86 | 86 | return unlink($source); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $files = new RecursiveIteratorIterator |
|
| 90 | - ( |
|
| 89 | + $files = new RecursiveIteratorIterator( |
|
| 91 | 90 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
| 92 | 91 | RecursiveIteratorIterator::CHILD_FIRST |
| 93 | 92 | ); |
@@ -137,8 +136,8 @@ discard block |
||
| 137 | 136 | /** |
| 138 | 137 | * Allows to dereference char |
| 139 | 138 | */ |
| 140 | - $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc. |
|
| 141 | - $prefix = $__FILE__[ 0 ] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
|
| 139 | + $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc. |
|
| 140 | + $prefix = $__FILE__[0] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
|
| 142 | 141 | return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes); |
| 143 | 142 | } |
| 144 | 143 | } |
| 145 | 144 | \ No newline at end of file |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | try { |
| 141 | 141 | $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
| 142 | - 'host' => "127.0.0.1", |
|
| 143 | - 'port' => 8888, |
|
| 144 | - 'password' => '', |
|
| 145 | - 'timeout' => 2000, |
|
| 142 | + 'host' => "127.0.0.1", |
|
| 143 | + 'port' => 8888, |
|
| 144 | + 'password' => '', |
|
| 145 | + 'timeout' => 2000, |
|
| 146 | 146 | ]; |
| 147 | 147 | |
| 148 | 148 | $host = $server[ 'host' ]; |
@@ -183,9 +183,9 @@ discard block |
||
| 183 | 183 | * using hardcoded offset of pair key-value :-( |
| 184 | 184 | */ |
| 185 | 185 | $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
| 186 | - ->setRawData($info) |
|
| 187 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 188 | - ->setSize($this->instance->dbsize()); |
|
| 186 | + ->setRawData($info) |
|
| 187 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 188 | + ->setSize($this->instance->dbsize()); |
|
| 189 | 189 | |
| 190 | 190 | return $stat; |
| 191 | 191 | } |
@@ -125,17 +125,17 @@ discard block |
||
| 125 | 125 | protected function driverConnect() |
| 126 | 126 | { |
| 127 | 127 | try { |
| 128 | - $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
|
| 128 | + $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [ |
|
| 129 | 129 | 'host' => "127.0.0.1", |
| 130 | 130 | 'port' => 8888, |
| 131 | 131 | 'password' => '', |
| 132 | 132 | 'timeout' => 2000, |
| 133 | 133 | ]; |
| 134 | 134 | |
| 135 | - $host = $server[ 'host' ]; |
|
| 136 | - $port = isset($server[ 'port' ]) ? (int)$server[ 'port' ] : 8888; |
|
| 137 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
| 138 | - $timeout = !empty($server[ 'timeout' ]) ? (int)$server[ 'timeout' ] : 2000; |
|
| 135 | + $host = $server['host']; |
|
| 136 | + $port = isset($server['port']) ? (int) $server['port'] : 8888; |
|
| 137 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
| 138 | + $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000; |
|
| 139 | 139 | $this->instance = new SimpleSSDB($host, $port, $timeout); |
| 140 | 140 | if (!empty($password)) { |
| 141 | 141 | $this->instance->auth($password); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * Data returned by Ssdb are very poorly formatted |
| 170 | 170 | * using hardcoded offset of pair key-value :-( |
| 171 | 171 | */ |
| 172 | - $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
|
| 172 | + $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[2], $info[6])) |
|
| 173 | 173 | ->setRawData($info) |
| 174 | 174 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 175 | 175 | ->setSize($this->instance->dbsize()); |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | return true; |
| 28 | 28 | } else if (constant($CONSTANT_NAME) !== $driverName) { |
| 29 | 29 | trigger_error('Memcache collision detected, you used both Memcache and Memcached driver in your script, this may leads to unexpected behaviours', |
| 30 | - E_USER_WARNING); |
|
| 30 | + E_USER_WARNING); |
|
| 31 | 31 | |
| 32 | 32 | return false; |
| 33 | 33 | } |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
| 163 | 163 | $stm->execute(); |
| 164 | 164 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 165 | - if (!isset($row[ 'db' ])) { |
|
| 165 | + if (!isset($row['db'])) { |
|
| 166 | 166 | $db = 1; |
| 167 | - } elseif ($row[ 'db' ] <= 1) { |
|
| 167 | + } elseif ($row['db'] <= 1) { |
|
| 168 | 168 | $db = 1; |
| 169 | 169 | } else { |
| 170 | - $db = $row[ 'db' ]; |
|
| 170 | + $db = $row['db']; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // check file size |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | ':keyword' => $keyword, |
| 190 | 190 | ]); |
| 191 | 191 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 192 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
| 193 | - $db = $row[ 'db' ]; |
|
| 192 | + if (isset($row['db']) && $row['db'] != '') { |
|
| 193 | + $db = $row['db']; |
|
| 194 | 194 | } else { |
| 195 | 195 | /* |
| 196 | 196 | * Insert new to Indexing |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | /** |
| 222 | 222 | * init instant |
| 223 | 223 | */ |
| 224 | - if (!isset($this->instance[ $instant ])) { |
|
| 224 | + if (!isset($this->instance[$instant])) { |
|
| 225 | 225 | // check DB Files ready or not |
| 226 | 226 | $createTable = false; |
| 227 | 227 | if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | $this->initDB($PDO); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $this->instance[ $instant ] = $PDO; |
|
| 237 | + $this->instance[$instant] = $PDO; |
|
| 238 | 238 | unset($PDO); |
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return $this->instance[ $instant ]; |
|
| 242 | + return $this->instance[$instant]; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * Check for Cross-Driver type confusion |
| 254 | 254 | */ |
| 255 | 255 | if ($item instanceof Item) { |
| 256 | - $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false; |
|
| 256 | + $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false; |
|
| 257 | 257 | $toWrite = true; |
| 258 | 258 | |
| 259 | 259 | // check in cache first |
@@ -329,8 +329,8 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if (isset($row[ 'object' ])) { |
|
| 333 | - return $this->decode($row[ 'object' ]); |
|
| 332 | + if (isset($row['object'])) { |
|
| 333 | + return $this->decode($row['object']); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | return null; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | - * @param $keyword |
|
| 209 | + * @param string $keyword |
|
| 210 | 210 | * @param bool $reset |
| 211 | 211 | * @return PDO |
| 212 | 212 | */ |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | 245 | * @param \Psr\Cache\CacheItemInterface $item |
| 246 | - * @return mixed |
|
| 246 | + * @return boolean |
|
| 247 | 247 | * @throws phpFastCacheInvalidArgumentException |
| 248 | 248 | */ |
| 249 | 249 | protected function driverWrite(CacheItemInterface $item) |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
| 152 | 152 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
| 153 | - PDO::ERRMODE_EXCEPTION); |
|
| 153 | + PDO::ERRMODE_EXCEPTION); |
|
| 154 | 154 | |
| 155 | 155 | if ($createTable == true) { |
| 156 | 156 | $this->initIndexing($PDO); |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // look for keyword |
| 186 | 186 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
| 187 | 187 | $stm->execute([ |
| 188 | - ':keyword' => $keyword, |
|
| 188 | + ':keyword' => $keyword, |
|
| 189 | 189 | ]); |
| 190 | 190 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 191 | 191 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | $db = $this->currentDB; |
| 198 | 198 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
| 199 | 199 | $stm->execute([ |
| 200 | - ':keyword' => $keyword, |
|
| 201 | - ':db' => $db, |
|
| 200 | + ':keyword' => $keyword, |
|
| 201 | + ':db' => $db, |
|
| 202 | 202 | ]); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -269,11 +269,11 @@ discard block |
||
| 269 | 269 | if ($toWrite == true) { |
| 270 | 270 | try { |
| 271 | 271 | $stm = $this->getDb($item->getKey()) |
| 272 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 272 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 273 | 273 | $stm->execute([ |
| 274 | - ':keyword' => $item->getKey(), |
|
| 275 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 276 | - ':exp' => time() + $item->getTtl(), |
|
| 274 | + ':keyword' => $item->getKey(), |
|
| 275 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 276 | + ':exp' => time() + $item->getTtl(), |
|
| 277 | 277 | ]); |
| 278 | 278 | |
| 279 | 279 | return true; |
@@ -281,11 +281,11 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | try { |
| 283 | 283 | $stm = $this->getDb($item->getKey(), true) |
| 284 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 284 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
| 285 | 285 | $stm->execute([ |
| 286 | - ':keyword' => $item->getKey(), |
|
| 287 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 288 | - ':exp' => time() + $item->getTtl(), |
|
| 286 | + ':keyword' => $item->getKey(), |
|
| 287 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
| 288 | + ':exp' => time() + $item->getTtl(), |
|
| 289 | 289 | ]); |
| 290 | 290 | } catch (PDOException $e) { |
| 291 | 291 | return false; |
@@ -307,18 +307,18 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | try { |
| 309 | 309 | $stm = $this->getDb($item->getKey()) |
| 310 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 310 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 311 | 311 | $stm->execute([ |
| 312 | - ':keyword' => $item->getKey(), |
|
| 312 | + ':keyword' => $item->getKey(), |
|
| 313 | 313 | ]); |
| 314 | 314 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 315 | 315 | |
| 316 | 316 | } catch (PDOException $e) { |
| 317 | 317 | try { |
| 318 | 318 | $stm = $this->getDb($item->getKey(), true) |
| 319 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 319 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
| 320 | 320 | $stm->execute([ |
| 321 | - ':keyword' => $item->getKey(), |
|
| 321 | + ':keyword' => $item->getKey(), |
|
| 322 | 322 | ]); |
| 323 | 323 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 324 | 324 | } catch (PDOException $e) { |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | if ($item instanceof Item) { |
| 347 | 347 | try { |
| 348 | 348 | $stm = $this->getDb($item->getKey()) |
| 349 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 349 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
| 350 | 350 | |
| 351 | 351 | return $stm->execute([ |
| 352 | - ':keyword' => $item->getKey(), |
|
| 353 | - ':U' => time(), |
|
| 352 | + ':keyword' => $item->getKey(), |
|
| 353 | + ':U' => time(), |
|
| 354 | 354 | ]); |
| 355 | 355 | } catch (PDOException $e) { |
| 356 | 356 | return false; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $keyword = self::PREFIX . $item->getKey(); |
| 81 | 81 | $v = json_encode($this->driverPreWrap($item)); |
| 82 | 82 | |
| 83 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
| 83 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | // return null if no caching |
| 102 | 102 | // return value if in caching |
| 103 | 103 | $keyword = self::PREFIX . $item->getKey(); |
| 104 | - $x = isset($_COOKIE[ $keyword ]) ? json_decode($_COOKIE[ $keyword ], true) : false; |
|
| 104 | + $x = isset($_COOKIE[$keyword]) ? json_decode($_COOKIE[$keyword], true) : false; |
|
| 105 | 105 | |
| 106 | 106 | if ($x == false) { |
| 107 | 107 | return null; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | $this->driverConnect(); |
| 124 | 124 | $keyword = self::PREFIX . $key; |
| 125 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
| 125 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
| 126 | 126 | |
| 127 | 127 | return $x ? $x - time() : $x; |
| 128 | 128 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | if ($item instanceof Item) { |
| 141 | 141 | $this->driverConnect(); |
| 142 | 142 | $keyword = self::PREFIX . $item->getKey(); |
| 143 | - $_COOKIE[ $keyword ] = null; |
|
| 143 | + $_COOKIE[$keyword] = null; |
|
| 144 | 144 | |
| 145 | 145 | return @setcookie($keyword, null, -10); |
| 146 | 146 | } else { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $this->driverConnect(); |
| 158 | 158 | foreach ($_COOKIE as $keyword => $value) { |
| 159 | 159 | if (strpos($keyword, self::PREFIX) !== false) { |
| 160 | - $_COOKIE[ $keyword ] = null; |
|
| 160 | + $_COOKIE[$keyword] = null; |
|
| 161 | 161 | $result = @setcookie($keyword, null, -10); |
| 162 | 162 | if ($return !== false) { |
| 163 | 163 | $return = $result; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | - * @param $keyword |
|
| 133 | + * @param false|string $keyword |
|
| 134 | 134 | * @param bool $skip |
| 135 | 135 | * @return string |
| 136 | 136 | * @throws phpFastCacheIOException |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | 199 | * @param $filename |
| 200 | - * @return mixed |
|
| 200 | + * @return string |
|
| 201 | 201 | */ |
| 202 | 202 | protected static function cleanFileName($filename) |
| 203 | 203 | { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | - * @param $path |
|
| 215 | + * @param string $path |
|
| 216 | 216 | * @param bool $create |
| 217 | 217 | * @throws phpFastCacheIOException |
| 218 | 218 | */ |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | - * @param $file |
|
| 252 | + * @param string $file |
|
| 253 | 253 | * @return string |
| 254 | 254 | * @throws phpFastCacheIOException |
| 255 | 255 | */ |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | protected static function cleanFileName($filename) |
| 192 | 192 | { |
| 193 | 193 | $regex = [ |
| 194 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 195 | - '/\.$/', |
|
| 196 | - '/^\./', |
|
| 194 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 195 | + '/\.$/', |
|
| 196 | + '/^\./', |
|
| 197 | 197 | ]; |
| 198 | 198 | $replace = ['-', '', '']; |
| 199 | 199 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
| 290 | 290 | str_shuffle(uniqid($this->getDriverName(), false)) |
| 291 | 291 | . str_shuffle(uniqid($this->getDriverName(), false)) |
| 292 | - )); |
|
| 292 | + )); |
|
| 293 | 293 | |
| 294 | 294 | $f = fopen($tmpFilename, 'w+'); |
| 295 | 295 | flock($f, LOCK_EX); |
@@ -331,11 +331,11 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
| 334 | - ->setRawData([ |
|
| 334 | + ->setRawData([ |
|
| 335 | 335 | 'tmp' => $this->tmp, |
| 336 | - ]) |
|
| 337 | - ->setSize(Directory::dirSize($path)) |
|
| 338 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 336 | + ]) |
|
| 337 | + ->setSize(Directory::dirSize($path)) |
|
| 338 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 339 | 339 | |
| 340 | 340 | return $stat; |
| 341 | 341 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | * Calculate the security key |
| 52 | 52 | */ |
| 53 | 53 | { |
| 54 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
| 54 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
| 55 | 55 | if (!$securityKey || $securityKey === 'auto') { |
| 56 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
| 57 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
| 56 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 57 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
| 58 | 58 | } else { |
| 59 | 59 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
| 60 | 60 | } |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR; |
| 75 | 75 | |
| 76 | - if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) { |
|
| 76 | + if (empty($this->config['path']) || !is_string($this->config['path'])) { |
|
| 77 | 77 | $path = $tmp_dir; |
| 78 | 78 | } else { |
| 79 | - $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR; |
|
| 79 | + $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName(); |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | * return the temp dir |
| 92 | 92 | */ |
| 93 | 93 | if ($readonly === true) { |
| 94 | - if ($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 94 | + if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 95 | 95 | return $full_path_tmp; |
| 96 | 96 | } |
| 97 | 97 | return $full_path; |
| 98 | 98 | } else { |
| 99 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 99 | + if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
| 100 | 100 | if (!@file_exists($full_path)) { |
| 101 | 101 | @mkdir($full_path, $this->getDefaultChmod(), true); |
| 102 | 102 | } else if (!@is_writable($full_path)) { |
| 103 | - if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config[ 'autoTmpFallback' ]) { |
|
| 103 | + if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config['autoTmpFallback']) { |
|
| 104 | 104 | /** |
| 105 | 105 | * Switch back to tmp dir |
| 106 | 106 | * again if the path is not writable |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | throw new phpFastCacheIOException('Path "' . $full_path . '" is not writable, please set a chmod 0777 or any writable permission and make sure to make use of an absolute path !'); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
| 125 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
| 124 | + $this->tmp[$full_path_hash] = $full_path; |
|
| 125 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return $path . '/' . $filename . '.' . $this->config[ 'cacheFileExtension' ]; |
|
| 162 | + return $path . '/' . $filename . '.' . $this->config['cacheFileExtension']; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | protected function getDefaultChmod() |
| 179 | 179 | { |
| 180 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
| 180 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
| 181 | 181 | return 0777; |
| 182 | 182 | } else { |
| 183 | - return $this->config[ 'default_chmod' ]; |
|
| 183 | + return $this->config['default_chmod']; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -63,8 +63,8 @@ |
||
| 63 | 63 | { |
| 64 | 64 | try { |
| 65 | 65 | $cacheItem = $this->internalCacheInstance |
| 66 | - ->getItem($key) |
|
| 67 | - ->set($value); |
|
| 66 | + ->getItem($key) |
|
| 67 | + ->set($value); |
|
| 68 | 68 | if (is_int($ttl) || $ttl instanceof \DateInterval) { |
| 69 | 69 | $cacheItem->expiresAfter($ttl); |
| 70 | 70 | } |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | public function getMultiple($keys, $default = null) |
| 111 | 111 | { |
| 112 | 112 | try { |
| 113 | - return array_map(function (ExtendedCacheItemInterface $item) { |
|
| 113 | + return array_map(function(ExtendedCacheItemInterface $item) { |
|
| 114 | 114 | return $item->get(); |
| 115 | 115 | }, $this->internalCacheInstance->getItems($keys)); |
| 116 | 116 | } catch (phpFastCacheInvalidArgumentException $e) { |