@@ -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. |
@@ -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); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
94 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
95 | 95 | } else { |
96 | 96 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
97 | 97 | } |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | $document = $this->getCollection()->findOne(['_id' => $key], [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
107 | 107 | if ($document) { |
108 | 108 | return [ |
109 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
110 | - self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec), |
|
109 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
110 | + self::DRIVER_TIME_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_TIME_WRAPPER_INDEX]->sec), |
|
111 | 111 | ]; |
112 | 112 | } else { |
113 | 113 | return null; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | if ($item instanceof Item) { |
128 | 128 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
129 | 129 | |
130 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
130 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
131 | 131 | } else { |
132 | 132 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
133 | 133 | } |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | if ($this->instance instanceof MongodbClient) { |
152 | 152 | throw new LogicException('Already connected to Mongodb server'); |
153 | 153 | } else { |
154 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
155 | - $port = isset($server[ 'port' ]) ? $server[ 'port' ] : '27017'; |
|
156 | - $timeout = isset($server[ 'timeout' ]) ? $server[ 'timeout' ] : 3; |
|
157 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
158 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
154 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
155 | + $port = isset($server['port']) ? $server['port'] : '27017'; |
|
156 | + $timeout = isset($server['timeout']) ? $server['timeout'] : 3; |
|
157 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
158 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
159 | 159 | |
160 | 160 | |
161 | 161 | /** |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | { |
189 | 189 | $document = $this->getCollection()->findOne(['_id' => $item->getKey()], [self::DRIVER_TIME_WRAPPER_INDEX /*'d', 'e'*/]); |
190 | 190 | if ($document) { |
191 | - return $document[ self::DRIVER_TIME_WRAPPER_INDEX ]->sec >= time(); |
|
191 | + return $document[self::DRIVER_TIME_WRAPPER_INDEX]->sec >= time(); |
|
192 | 192 | } else { |
193 | 193 | return null; |
194 | 194 | } |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | ]); |
218 | 218 | |
219 | 219 | $stats = (new driverStatistic()) |
220 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1)) |
|
221 | - ->setSize((int) $collStats[ 'size' ]) |
|
220 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1)) |
|
221 | + ->setSize((int) $collStats['size']) |
|
222 | 222 | ->setRawData([ |
223 | 223 | 'serverStatus' => $serverStatus, |
224 | 224 | 'collStats' => $collStats, |
@@ -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 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function driverConnect() |
132 | 132 | { |
133 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
133 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
134 | 134 | if (count($servers) < 1) { |
135 | 135 | $servers = [ |
136 | 136 | ['127.0.0.1', 11211], |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | foreach ($servers as $server) { |
141 | 141 | try { |
142 | - if (!$this->instance->addserver($server[ 0 ], $server[ 1 ])) { |
|
142 | + if (!$this->instance->addserver($server[0], $server[1])) { |
|
143 | 143 | $this->fallback = true; |
144 | 144 | } |
145 | 145 | } catch (\Exception $e) { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function driverConnect() |
134 | 134 | { |
135 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
135 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
136 | 136 | if (count($servers) < 1) { |
137 | 137 | $servers = [ |
138 | 138 | ['127.0.0.1', 11211], |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | foreach ($servers as $server) { |
143 | 143 | try { |
144 | - if (!$this->instance->addServer($server[ 0 ], $server[ 1 ])) { |
|
144 | + if (!$this->instance->addServer($server[0], $server[1])) { |
|
145 | 145 | $this->fallback = true; |
146 | 146 | } |
147 | 147 | } catch (\Exception $e) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | gettype($key))); |
190 | 190 | } |
191 | 191 | |
192 | - return $this->itemInstances[ $key ]; |
|
192 | + return $this->itemInstances[$key]; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | public function setItem(CacheItemInterface $item) |
201 | 201 | { |
202 | 202 | if (__NAMESPACE__ . '\\Item' === get_class($item)) { |
203 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
203 | + $this->itemInstances[$item->getKey()] = $item; |
|
204 | 204 | |
205 | 205 | return $this; |
206 | 206 | } else { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | { |
219 | 219 | $collection = []; |
220 | 220 | foreach ($keys as $key) { |
221 | - $collection[ $key ] = $this->getItem($key); |
|
221 | + $collection[$key] = $this->getItem($key); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | return $collection; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function saveDeferred(CacheItemInterface $item) |
292 | 292 | { |
293 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
293 | + return $this->deferredList[$item->getKey()] = $item; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | foreach ($this->deferredList as $key => $item) { |
304 | 304 | $result = $this->driverWrite($item); |
305 | 305 | if ($return !== false) { |
306 | - unset($this->deferredList[ $key ]); |
|
306 | + unset($this->deferredList[$key]); |
|
307 | 307 | $return = $result; |
308 | 308 | } |
309 | 309 | } |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
167 | 167 | $stm->execute(); |
168 | 168 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
169 | - if (!isset($row[ 'db' ])) { |
|
169 | + if (!isset($row['db'])) { |
|
170 | 170 | $db = 1; |
171 | - } elseif ($row[ 'db' ] <= 1) { |
|
171 | + } elseif ($row['db'] <= 1) { |
|
172 | 172 | $db = 1; |
173 | 173 | } else { |
174 | - $db = $row[ 'db' ]; |
|
174 | + $db = $row['db']; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | // check file size |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | ':keyword' => $keyword, |
194 | 194 | ]); |
195 | 195 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
196 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
197 | - $db = $row[ 'db' ]; |
|
196 | + if (isset($row['db']) && $row['db'] != '') { |
|
197 | + $db = $row['db']; |
|
198 | 198 | } else { |
199 | 199 | /* |
200 | 200 | * Insert new to Indexing |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | /** |
226 | 226 | * init instant |
227 | 227 | */ |
228 | - if (!isset($this->instance[ $instant ])) { |
|
228 | + if (!isset($this->instance[$instant])) { |
|
229 | 229 | // check DB Files ready or not |
230 | 230 | $createTable = false; |
231 | 231 | if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | $this->initDB($PDO); |
239 | 239 | } |
240 | 240 | |
241 | - $this->instance[ $instant ] = $PDO; |
|
241 | + $this->instance[$instant] = $PDO; |
|
242 | 242 | unset($PDO); |
243 | 243 | |
244 | 244 | } |
245 | 245 | |
246 | - return $this->instance[ $instant ]; |
|
246 | + return $this->instance[$instant]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * Check for Cross-Driver type confusion |
258 | 258 | */ |
259 | 259 | if ($item instanceof Item) { |
260 | - $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false; |
|
260 | + $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false; |
|
261 | 261 | $toWrite = true; |
262 | 262 | |
263 | 263 | // check in cache first |
@@ -333,18 +333,18 @@ discard block |
||
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - if (isset($row[ 'id' ])) { |
|
336 | + if (isset($row['id'])) { |
|
337 | 337 | /** |
338 | 338 | * @var $item ExtendedCacheItemInterface |
339 | 339 | */ |
340 | - $item = $this->decode($row[ 'object' ]); |
|
340 | + $item = $this->decode($row['object']); |
|
341 | 341 | if ($item instanceof ExtendedCacheItemInterface && $item->isExpired()) { |
342 | 342 | $this->driverDelete($item); |
343 | 343 | |
344 | 344 | return null; |
345 | 345 | } |
346 | 346 | |
347 | - return $this->decode($row[ 'object' ]); |
|
347 | + return $this->decode($row['object']); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | return null; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | ':U' => time(), |
435 | 435 | ]); |
436 | 436 | $data = $stm->fetch(PDO::FETCH_ASSOC); |
437 | - if ($data[ 'total' ] >= 1) { |
|
437 | + if ($data['total'] >= 1) { |
|
438 | 438 | return true; |
439 | 439 | } else { |
440 | 440 | return false; |
@@ -122,11 +122,11 @@ |
||
122 | 122 | } else { |
123 | 123 | $this->instance = $this->instance ?: new RedisClient(); |
124 | 124 | |
125 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
126 | - $port = isset($this->config[ 'port' ]) ? (int) $this->config[ 'port' ] : '6379'; |
|
127 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
128 | - $database = isset($this->config[ 'database' ]) ? $this->config[ 'database' ] : ''; |
|
129 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : ''; |
|
125 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
126 | + $port = isset($this->config['port']) ? (int) $this->config['port'] : '6379'; |
|
127 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
128 | + $database = isset($this->config['database']) ? $this->config['database'] : ''; |
|
129 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : ''; |
|
130 | 130 | |
131 | 131 | if (!$this->instance->connect($host, (int) $port, (int) $timeout)) { |
132 | 132 | return false; |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | |
139 | 139 | |
140 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
140 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
141 | 141 | //$port = isset($server[ 'port' ]) ? $server[ 'port' ] : '11211'; |
142 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
143 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
144 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
142 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
143 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
144 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
145 | 145 | [ |
146 | 146 | 'bucket' => 'default', |
147 | 147 | 'password' => '', |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | |
153 | 153 | |
154 | 154 | foreach ($buckets as $bucket) { |
155 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
156 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
155 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
156 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function getBucket() |
165 | 165 | { |
166 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
166 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
175 | 175 | { |
176 | 176 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
177 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
177 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
178 | 178 | } else { |
179 | 179 | throw new \LogicException('A bucket instance with this name already exists.'); |
180 | 180 | } |
@@ -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; |