@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | - ['127.0.0.1', 11211], |
|
134 | + ['127.0.0.1', 11211], |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
162 | 162 | |
163 | 163 | return (new driverStatistic()) |
164 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | - ->setRawData($stats) |
|
167 | - ->setSize($stats[ 'bytes' ]); |
|
164 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | + ->setRawData($stats) |
|
167 | + ->setSize($stats[ 'bytes' ]); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | \ No newline at end of file |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->instance = new MemcacheSoftware(); |
53 | 53 | $this->driverConnect(); |
54 | 54 | |
55 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
55 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
56 | 56 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
57 | 57 | } |
58 | 58 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function driverConnect() |
130 | 130 | { |
131 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
131 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | 134 | ['127.0.0.1', 11211], |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | foreach ($servers as $server) { |
139 | 139 | try { |
140 | - if (!$this->instance->addserver($server[ 0 ], $server[ 1 ])) { |
|
140 | + if (!$this->instance->addserver($server[0], $server[1])) { |
|
141 | 141 | $this->fallback = true; |
142 | 142 | } |
143 | 143 | } catch (\Exception $e) { |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | public function getStats() |
159 | 159 | { |
160 | 160 | $stats = (array) $this->instance->getstats(); |
161 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
161 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
162 | 162 | |
163 | 163 | return (new driverStatistic()) |
164 | 164 | ->setData(implode(', ', array_keys($this->itemInstances))) |
165 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
165 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
166 | 166 | ->setRawData($stats) |
167 | - ->setSize($stats[ 'bytes' ]); |
|
167 | + ->setSize($stats['bytes']); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | \ 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 | } |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | protected function driverConnect() |
139 | 139 | { |
140 | 140 | try { |
141 | - $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
|
141 | + $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [ |
|
142 | 142 | 'host' => "127.0.0.1", |
143 | 143 | 'port' => 8888, |
144 | 144 | 'password' => '', |
145 | 145 | 'timeout' => 2000, |
146 | 146 | ]; |
147 | 147 | |
148 | - $host = $server[ 'host' ]; |
|
149 | - $port = isset($server[ 'port' ]) ? (int) $server[ 'port' ] : 8888; |
|
150 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
151 | - $timeout = !empty($server[ 'timeout' ]) ? (int) $server[ 'timeout' ] : 2000; |
|
148 | + $host = $server['host']; |
|
149 | + $port = isset($server['port']) ? (int) $server['port'] : 8888; |
|
150 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
151 | + $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000; |
|
152 | 152 | $this->instance = new SimpleSSDB($host, $port, $timeout); |
153 | 153 | if (!empty($password)) { |
154 | 154 | $this->instance->auth($password); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * Data returned by Ssdb are very poorly formatted |
183 | 183 | * using hardcoded offset of pair key-value :-( |
184 | 184 | */ |
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 ])) |
|
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 | 186 | ->setRawData($info) |
187 | 187 | ->setData(implode(', ', array_keys($this->itemInstances))) |
188 | 188 | ->setSize($this->instance->dbsize()); |
@@ -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 | } |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | * @var array |
51 | 51 | */ |
52 | 52 | protected static $config = [ |
53 | - 'itemDetailedDate' => false,// Specify if the item must provide detailed creation/modification dates |
|
54 | - 'defaultTtl' => 900,// Default time-to-live in second |
|
55 | - 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
56 | - 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
57 | - 'default_chmod' => 0777, // 0777 recommended |
|
58 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
59 | - 'fallback' => false, //Fall back when old driver is not support |
|
60 | - 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
61 | - 'compress_data' => false, // compress stored data, if the backend supports it |
|
53 | + 'itemDetailedDate' => false,// Specify if the item must provide detailed creation/modification dates |
|
54 | + 'defaultTtl' => 900,// Default time-to-live in second |
|
55 | + 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
56 | + 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
57 | + 'default_chmod' => 0777, // 0777 recommended |
|
58 | + 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
59 | + 'fallback' => false, //Fall back when old driver is not support |
|
60 | + 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
|
61 | + 'compress_data' => false, // compress stored data, if the backend supports it |
|
62 | 62 | ]; |
63 | 63 | |
64 | 64 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | } |
108 | 108 | } else if(++$badPracticeOmeter[$driver] >= 5){ |
109 | - trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
109 | + trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
110 | 110 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
111 | 111 | } |
112 | 112 | |
@@ -219,21 +219,21 @@ discard block |
||
219 | 219 | public static function getStaticSystemDrivers() |
220 | 220 | { |
221 | 221 | return [ |
222 | - 'Sqlite', |
|
223 | - 'Files', |
|
224 | - 'Apc', |
|
225 | - 'Apcu', |
|
226 | - 'Memcache', |
|
227 | - 'Memcached', |
|
228 | - 'Couchbase', |
|
229 | - 'Mongodb', |
|
230 | - 'Predis', |
|
231 | - 'Redis', |
|
232 | - 'Ssdb', |
|
233 | - 'Leveldb', |
|
234 | - 'Wincache', |
|
235 | - 'Xcache', |
|
236 | - 'Devnull', |
|
222 | + 'Sqlite', |
|
223 | + 'Files', |
|
224 | + 'Apc', |
|
225 | + 'Apcu', |
|
226 | + 'Memcache', |
|
227 | + 'Memcached', |
|
228 | + 'Couchbase', |
|
229 | + 'Mongodb', |
|
230 | + 'Predis', |
|
231 | + 'Redis', |
|
232 | + 'Ssdb', |
|
233 | + 'Leveldb', |
|
234 | + 'Wincache', |
|
235 | + 'Xcache', |
|
236 | + 'Devnull', |
|
237 | 237 | ]; |
238 | 238 | } |
239 | 239 |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | * @var array |
51 | 51 | */ |
52 | 52 | protected static $config = [ |
53 | - 'itemDetailedDate' => false,// Specify if the item must provide detailed creation/modification dates |
|
54 | - 'defaultTtl' => 900,// Default time-to-live in second |
|
55 | - 'securityKey' => 'auto',// The securityKey that will be used to create sub-directory |
|
56 | - 'htaccess' => true,// Auto-generate .htaccess if tit is missing |
|
53 | + 'itemDetailedDate' => false, // Specify if the item must provide detailed creation/modification dates |
|
54 | + 'defaultTtl' => 900, // Default time-to-live in second |
|
55 | + 'securityKey' => 'auto', // The securityKey that will be used to create sub-directory |
|
56 | + 'htaccess' => true, // Auto-generate .htaccess if tit is missing |
|
57 | 57 | 'default_chmod' => 0777, // 0777 recommended |
58 | - 'path' => '',// if not set will be the value of sys_get_temp_dir() |
|
58 | + 'path' => '', // if not set will be the value of sys_get_temp_dir() |
|
59 | 59 | 'fallback' => false, //Fall back when old driver is not support |
60 | 60 | 'limited_memory_each_object' => 4096, // maximum size (bytes) of object store in memory |
61 | 61 | 'compress_data' => false, // compress stored data, if the backend supports it |
@@ -90,27 +90,27 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | $instance = crc32($driver . serialize($config)); |
93 | - if (!isset(self::$instances[ $instance ])) { |
|
93 | + if (!isset(self::$instances[$instance])) { |
|
94 | 94 | $badPracticeOmeter[$driver] = 1; |
95 | 95 | $class = self::getNamespacePath() . $driver . '\Driver'; |
96 | - try{ |
|
97 | - self::$instances[ $instance ] = new $class($config); |
|
98 | - }catch(phpFastCacheDriverCheckException $e){ |
|
96 | + try { |
|
97 | + self::$instances[$instance] = new $class($config); |
|
98 | + } catch (phpFastCacheDriverCheckException $e) { |
|
99 | 99 | $fallback = self::standardizeDriverName($config['fallback']); |
100 | - if($fallback && $fallback !== $driver){ |
|
100 | + if ($fallback && $fallback !== $driver) { |
|
101 | 101 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
102 | - self::$instances[ $instance ] = new $class($config); |
|
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 | } |
108 | - } else if(++$badPracticeOmeter[$driver] >= 5){ |
|
108 | + } else if (++$badPracticeOmeter[$driver] >= 5) { |
|
109 | 109 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
110 | 110 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
111 | 111 | } |
112 | 112 | |
113 | - return self::$instances[ $instance ]; |
|
113 | + return self::$instances[$instance]; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public static function __callStatic($name, $arguments) |
145 | 145 | { |
146 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
146 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
147 | 147 | |
148 | 148 | return self::getInstance($name, $options); |
149 | 149 | } |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | { |
199 | 199 | if (is_array($name)) { |
200 | 200 | self::$config = array_merge(self::$config, $name); |
201 | - } else if (is_string($name)){ |
|
202 | - self::$config[ $name ] = $value; |
|
203 | - }else{ |
|
201 | + } else if (is_string($name)) { |
|
202 | + self::$config[$name] = $value; |
|
203 | + } else { |
|
204 | 204 | throw new \InvalidArgumentException('Invalid variable type: $name'); |
205 | 205 | } |
206 | 206 | } |
@@ -51,5 +51,5 @@ |
||
51 | 51 | |
52 | 52 | if (class_exists('Composer\Autoload\ClassLoader')) { |
53 | 53 | trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
54 | - E_USER_WARNING); |
|
54 | + E_USER_WARNING); |
|
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -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 |
@@ -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 |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @param \Psr\Cache\CacheItemInterface $item |
160 | - * @return mixed |
|
160 | + * @return boolean |
|
161 | 161 | * @throws \InvalidArgumentException |
162 | 162 | */ |
163 | 163 | public function save(CacheItemInterface $item) |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * @return mixed|null |
|
178 | + * @return boolean |
|
179 | 179 | * @throws \InvalidArgumentException |
180 | 180 | */ |
181 | 181 | public function commit() |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $item->set($this->driverUnwrapData($driverArray)); |
62 | 62 | $item->expiresAt($this->driverUnwrapEdate($driverArray)); |
63 | 63 | |
64 | - if($this->config['itemDetailedDate']){ |
|
64 | + if ($this->config['itemDetailedDate']) { |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * If the itemDetailedDate has been |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | } else { |
84 | 84 | $item->setHit(true); |
85 | 85 | } |
86 | - }else{ |
|
87 | - $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
|
86 | + } else { |
|
87 | + $item->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key))); |
93 | 93 | } |
94 | 94 | |
95 | - return $this->itemInstances[ $key ]; |
|
95 | + return $this->itemInstances[$key]; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | public function setItem(CacheItemInterface $item) |
104 | 104 | { |
105 | 105 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
106 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
106 | + $this->itemInstances[$item->getKey()] = $item; |
|
107 | 107 | |
108 | 108 | return $this; |
109 | 109 | } else { |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $collection = []; |
122 | 122 | foreach ($keys as $key) { |
123 | - $collection[ $key ] = $this->getItem($key); |
|
123 | + $collection[$key] = $this->getItem($key); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | return $collection; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | if ($this->hasItem($key) && $this->driverDelete($item)) { |
161 | 161 | $item->setHit(false); |
162 | 162 | CacheManager::$WriteHits++; |
163 | - unset($this->itemInstances[ $key ]); |
|
163 | + unset($this->itemInstances[$key]); |
|
164 | 164 | |
165 | 165 | return true; |
166 | 166 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @var ExtendedCacheItemInterface $item |
198 | 198 | */ |
199 | 199 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
200 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
200 | + $this->itemInstances[$item->getKey()] = $item; |
|
201 | 201 | } |
202 | 202 | if ($this->driverWrite($item) && $this->driverWriteTags($item)) { |
203 | 203 | $item->setHit(true); |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | public function saveDeferred(CacheItemInterface $item) |
217 | 217 | { |
218 | 218 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
219 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
219 | + $this->itemInstances[$item->getKey()] = $item; |
|
220 | 220 | } |
221 | 221 | |
222 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
222 | + return $this->deferredList[$item->getKey()] = $item; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | foreach ($this->deferredList as $key => $item) { |
233 | 233 | $result = $this->save($item); |
234 | 234 | if ($return !== false) { |
235 | - unset($this->deferredList[ $key ]); |
|
235 | + unset($this->deferredList[$key]); |
|
236 | 236 | $return = $result; |
237 | 237 | } |
238 | 238 | } |
@@ -83,7 +83,7 @@ |
||
83 | 83 | } else { |
84 | 84 | $item->setHit(true); |
85 | 85 | } |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
88 | 88 | } |
89 | 89 |
@@ -115,7 +115,7 @@ |
||
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
118 | - * @param $file |
|
118 | + * @param string $file |
|
119 | 119 | * @return string |
120 | 120 | * @throws \Exception |
121 | 121 | */ |
@@ -159,9 +159,9 @@ |
||
159 | 159 | public function driverPreWrap(ExtendedCacheItemInterface $item) |
160 | 160 | { |
161 | 161 | $wrap = [ |
162 | - self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | - self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | - self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
162 | + self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | + self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | + self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
165 | 165 | ]; |
166 | 166 | |
167 | 167 | if($this->config['itemDetailedDate']){ |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if (is_array($config_name)) { |
53 | 53 | $this->config = array_merge($this->config, $config_name); |
54 | 54 | } else { |
55 | - $this->config[ $config_name ] = $value; |
|
55 | + $this->config[$config_name] = $value; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
165 | 165 | ]; |
166 | 166 | |
167 | - if($this->config['itemDetailedDate']){ |
|
168 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
167 | + if ($this->config['itemDetailedDate']) { |
|
168 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
169 | 169 | /** |
170 | 170 | * If the creation date exists |
171 | 171 | * reuse it else set a new Date |
172 | 172 | */ |
173 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
174 | - }else{ |
|
175 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
176 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
173 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
174 | + } else { |
|
175 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
176 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $wrap; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function driverUnwrapData(array $wrapper) |
187 | 187 | { |
188 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
188 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function driverUnwrapTags(array $wrapper) |
196 | 196 | { |
197 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
197 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function driverUnwrapEdate(array $wrapper) |
206 | 206 | { |
207 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
207 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function driverUnwrapCdate(array $wrapper) |
215 | 215 | { |
216 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
216 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function driverUnwrapMdate(array $wrapper) |
225 | 225 | { |
226 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
226 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | foreach ($tagsItems as $tagsItem) { |
278 | 278 | $data = (array) $tagsItem->get(); |
279 | 279 | |
280 | - unset($data[ $item->getKey() ]); |
|
280 | + unset($data[$item->getKey()]); |
|
281 | 281 | $tagsItem->set($data); |
282 | 282 | |
283 | 283 | /** |
@@ -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 |
@@ -25,7 +25,6 @@ discard block |
||
25 | 25 | public $tmp = []; |
26 | 26 | |
27 | 27 | /** |
28 | - * @param bool $skip_create_path |
|
29 | 28 | * @param $config |
30 | 29 | * @return string |
31 | 30 | * @throws \Exception |
@@ -118,7 +117,7 @@ discard block |
||
118 | 117 | } |
119 | 118 | |
120 | 119 | /** |
121 | - * @param $keyword |
|
120 | + * @param string|false $keyword |
|
122 | 121 | * @param bool $skip |
123 | 122 | * @return string |
124 | 123 | * @throws phpFastCacheDriverException |
@@ -165,7 +164,7 @@ discard block |
||
165 | 164 | |
166 | 165 | /** |
167 | 166 | * @param $filename |
168 | - * @return mixed |
|
167 | + * @return string |
|
169 | 168 | */ |
170 | 169 | protected static function cleanFileName($filename) |
171 | 170 | { |
@@ -180,7 +179,7 @@ discard block |
||
180 | 179 | } |
181 | 180 | |
182 | 181 | /** |
183 | - * @param $path |
|
182 | + * @param string $path |
|
184 | 183 | * @param bool $create |
185 | 184 | * @throws \Exception |
186 | 185 | */ |
@@ -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 |
@@ -34,30 +34,30 @@ discard block |
||
34 | 34 | { |
35 | 35 | $tmp_dir = rtrim(ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache'; |
36 | 36 | |
37 | - if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') { |
|
37 | + if (!isset($this->config['path']) || $this->config['path'] == '') { |
|
38 | 38 | if (self::isPHPModule()) { |
39 | 39 | $path = $tmp_dir; |
40 | 40 | } else { |
41 | - $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
|
42 | - $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . 'PathSeekerTrait.php/'; |
|
41 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
42 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . 'PathSeekerTrait.php/'; |
|
43 | 43 | } |
44 | 44 | |
45 | - if ($this->config[ 'path' ] != '') { |
|
46 | - $path = $this->config[ 'path' ]; |
|
45 | + if ($this->config['path'] != '') { |
|
46 | + $path = $this->config['path']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | } else { |
50 | - $path = $this->config[ 'path' ]; |
|
50 | + $path = $this->config['path']; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | if ($getBasePath === true) { |
54 | 54 | return $path; |
55 | 55 | } |
56 | 56 | |
57 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
57 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
58 | 58 | if (!$securityKey || $securityKey === 'auto') { |
59 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
60 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
59 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
60 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
61 | 61 | } else { |
62 | 62 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
63 | 63 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $full_pathx = md5($full_path); |
74 | 74 | |
75 | 75 | |
76 | - if (!isset($this->tmp[ $full_pathx ])) { |
|
76 | + if (!isset($this->tmp[$full_pathx])) { |
|
77 | 77 | |
78 | 78 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
79 | 79 | if (!@file_exists($full_path)) { |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - $this->tmp[ $full_pathx ] = true; |
|
101 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
100 | + $this->tmp[$full_pathx] = true; |
|
101 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return realpath($full_path); |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function setChmodAuto() |
173 | 173 | { |
174 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
174 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
175 | 175 | return 0777; |
176 | 176 | } else { |
177 | - return $this->config[ 'default_chmod' ]; |
|
177 | + return $this->config['default_chmod']; |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | if ($create === true) { |
205 | 205 | if (!is_writable($path)) { |
206 | 206 | try { |
207 | - if(!chmod($path, 0777)){ |
|
207 | + if (!chmod($path, 0777)) { |
|
208 | 208 | throw new phpFastCacheDriverException('Chmod failed on : ' . $path); |
209 | 209 | } |
210 | 210 | } catch (phpFastCacheDriverException $e) { |