@@ -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. |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | public function removeTag($tagName) |
350 | 350 | { |
351 | 351 | if (($key = array_search($tagName, $this->tags)) !== false) { |
352 | - unset($this->tags[ $key ]); |
|
352 | + unset($this->tags[$key]); |
|
353 | 353 | $this->removedTags[] = $tagName; |
354 | 354 | } |
355 | 355 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | final public function __debugInfo() |
393 | 393 | { |
394 | 394 | $info = get_object_vars($this); |
395 | - $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')'; |
|
395 | + $info['driver'] = 'object(' . get_class($info['driver']) . ')'; |
|
396 | 396 | |
397 | 397 | return (array) $info; |
398 | 398 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function driverConnect() |
128 | 128 | { |
129 | - $server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [ |
|
129 | + $server = isset($this->config['redis']) ? $this->config['redis'] : [ |
|
130 | 130 | 'host' => '127.0.0.1', |
131 | 131 | 'port' => '6379', |
132 | 132 | 'password' => '', |
@@ -134,32 +134,32 @@ discard block |
||
134 | 134 | ]; |
135 | 135 | |
136 | 136 | $config = [ |
137 | - 'host' => $server[ 'host' ], |
|
137 | + 'host' => $server['host'], |
|
138 | 138 | ]; |
139 | 139 | |
140 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : ''; |
|
140 | + $port = isset($server['port']) ? $server['port'] : ''; |
|
141 | 141 | if ($port != '') { |
142 | - $config[ 'port' ] = $port; |
|
142 | + $config['port'] = $port; |
|
143 | 143 | } |
144 | 144 | |
145 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
145 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
146 | 146 | if ($password != '') { |
147 | - $config[ 'password' ] = $password; |
|
147 | + $config['password'] = $password; |
|
148 | 148 | } |
149 | 149 | |
150 | - $database = isset($server[ 'database' ]) ? $server[ 'database' ] : ''; |
|
150 | + $database = isset($server['database']) ? $server['database'] : ''; |
|
151 | 151 | if ($database != '') { |
152 | - $config[ 'database' ] = $database; |
|
152 | + $config['database'] = $database; |
|
153 | 153 | } |
154 | 154 | |
155 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : ''; |
|
155 | + $timeout = isset($server['timeout']) ? $server['timeout'] : ''; |
|
156 | 156 | if ($timeout != '') { |
157 | - $config[ 'timeout' ] = $timeout; |
|
157 | + $config['timeout'] = $timeout; |
|
158 | 158 | } |
159 | 159 | |
160 | - $read_write_timeout = isset($server[ 'read_write_timeout' ]) ? $server[ 'read_write_timeout' ] : ''; |
|
160 | + $read_write_timeout = isset($server['read_write_timeout']) ? $server['read_write_timeout'] : ''; |
|
161 | 161 | if ($read_write_timeout != '') { |
162 | - $config[ 'read_write_timeout' ] = $read_write_timeout; |
|
162 | + $config['read_write_timeout'] = $read_write_timeout; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | $this->instance = new PredisClient($config); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $keyword = self::PREFIX . $item->getKey(); |
80 | 80 | $v = json_encode($this->driverPreWrap($item)); |
81 | 81 | |
82 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
82 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | // return null if no caching |
101 | 101 | // return value if in caching |
102 | 102 | $keyword = self::PREFIX . $key; |
103 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ], true)) : false; |
|
103 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword], true)) : false; |
|
104 | 104 | |
105 | 105 | if ($x == false) { |
106 | 106 | return null; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | { |
122 | 122 | $this->driverConnect(); |
123 | 123 | $keyword = self::PREFIX . $key; |
124 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
124 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
125 | 125 | |
126 | 126 | return $x ? $x - time() : $x; |
127 | 127 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | if ($item instanceof Item) { |
140 | 140 | $this->driverConnect(); |
141 | 141 | $keyword = self::PREFIX . $item->getKey(); |
142 | - $_COOKIE[ $keyword ] = null; |
|
142 | + $_COOKIE[$keyword] = null; |
|
143 | 143 | |
144 | 144 | return @setcookie($keyword, null, -10); |
145 | 145 | } else { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->driverConnect(); |
157 | 157 | foreach ($_COOKIE as $keyword => $value) { |
158 | 158 | if (strpos($keyword, self::PREFIX) !== false) { |
159 | - $_COOKIE[ $keyword ] = null; |
|
159 | + $_COOKIE[$keyword] = null; |
|
160 | 160 | $result = @setcookie($keyword, null, -10); |
161 | 161 | if ($return !== false) { |
162 | 162 | $return = $result; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | if (is_array($config_name)) { |
68 | 68 | $this->config = array_merge($this->config, $config_name); |
69 | 69 | } else { |
70 | - $this->config[ $config_name ] = $value; |
|
70 | + $this->config[$config_name] = $value; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function driverUnwrapData(array $wrapper) |
186 | 186 | { |
187 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
187 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function driverUnwrapTags(array $wrapper) |
195 | 195 | { |
196 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
196 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function driverUnwrapTime(array $wrapper) |
205 | 205 | { |
206 | - return $wrapper[ self::DRIVER_TIME_WRAPPER_INDEX ]; |
|
206 | + return $wrapper[self::DRIVER_TIME_WRAPPER_INDEX]; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | foreach ($tagsItems as $tagsItem) { |
258 | 258 | $data = (array) $tagsItem->get(); |
259 | 259 | |
260 | - unset($data[ $item->getKey() ]); |
|
260 | + unset($data[$item->getKey()]); |
|
261 | 261 | $tagsItem->set($data); |
262 | 262 | |
263 | 263 | /** |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key))); |
72 | 72 | } |
73 | 73 | |
74 | - return $this->itemInstances[ $key ]; |
|
74 | + return $this->itemInstances[$key]; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function setItem(CacheItemInterface $item) |
83 | 83 | { |
84 | 84 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
85 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
85 | + $this->itemInstances[$item->getKey()] = $item; |
|
86 | 86 | |
87 | 87 | return $this; |
88 | 88 | } else { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | { |
100 | 100 | $collection = []; |
101 | 101 | foreach ($keys as $key) { |
102 | - $collection[ $key ] = $this->getItem($key); |
|
102 | + $collection[$key] = $this->getItem($key); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $collection; |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public function deleteItem($key) |
138 | 138 | { |
139 | 139 | if ($this->hasItem($key) && $this->driverDelete($this->getItem($key))) { |
140 | - unset($this->itemInstances[ $key ]); |
|
140 | + unset($this->itemInstances[$key]); |
|
141 | 141 | |
142 | 142 | return true; |
143 | 143 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | public function save(CacheItemInterface $item) |
172 | 172 | { |
173 | 173 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
174 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
174 | + $this->itemInstances[$item->getKey()] = $item; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $this->driverWrite($item) && $this->driverWriteTags($item); |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | public function saveDeferred(CacheItemInterface $item) |
185 | 185 | { |
186 | 186 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
187 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
187 | + $this->itemInstances[$item->getKey()] = $item; |
|
188 | 188 | } |
189 | 189 | |
190 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
190 | + return $this->deferredList[$item->getKey()] = $item; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | foreach ($this->deferredList as $key => $item) { |
201 | 201 | $result = $this->save($item); |
202 | 202 | if ($return !== false) { |
203 | - unset($this->deferredList[ $key ]); |
|
203 | + unset($this->deferredList[$key]); |
|
204 | 204 | $return = $result; |
205 | 205 | } |
206 | 206 | } |
@@ -81,8 +81,7 @@ discard block |
||
81 | 81 | return unlink($source); |
82 | 82 | } |
83 | 83 | |
84 | - $files = new RecursiveIteratorIterator |
|
85 | - ( |
|
84 | + $files = new RecursiveIteratorIterator( |
|
86 | 85 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
87 | 86 | RecursiveIteratorIterator::CHILD_FIRST |
88 | 87 | ); |
@@ -95,7 +94,7 @@ discard block |
||
95 | 94 | if (self::rrmdir($fileinfo->getRealPath()) === false) { |
96 | 95 | return false; |
97 | 96 | } |
98 | - } else if(unlink($fileinfo->getRealPath()) === false) { |
|
97 | + } else if (unlink($fileinfo->getRealPath()) === false) { |
|
99 | 98 | return false; |
100 | 99 | } |
101 | 100 | } |
@@ -34,30 +34,30 @@ discard block |
||
34 | 34 | { |
35 | 35 | $tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); |
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__, '/') . '/'; |
|
41 | + $document_root_path = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/../'; |
|
42 | + $path = isset($_SERVER['DOCUMENT_ROOT']) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
|
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 |
@@ -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,18 +329,18 @@ discard block |
||
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if (isset($row[ 'id' ])) { |
|
332 | + if (isset($row['id'])) { |
|
333 | 333 | /** |
334 | 334 | * @var $item ExtendedCacheItemInterface |
335 | 335 | */ |
336 | - $item = $this->decode($row[ 'object' ]); |
|
336 | + $item = $this->decode($row['object']); |
|
337 | 337 | if ($item instanceof ExtendedCacheItemInterface && $item->isExpired()) { |
338 | 338 | $this->driverDelete($item); |
339 | 339 | |
340 | 340 | return null; |
341 | 341 | } |
342 | 342 | |
343 | - return $this->decode($row[ 'object' ]); |
|
343 | + return $this->decode($row['object']); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | return null; |