@@ -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() |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * getItem() call in delete() method |
66 | 66 | */ |
67 | 67 | $this->driverDelete($item); |
68 | - }else{ |
|
68 | + } else { |
|
69 | 69 | $item->setHit(true); |
70 | 70 | } |
71 | 71 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key))); |
76 | 76 | } |
77 | 77 | |
78 | - return $this->itemInstances[ $key ]; |
|
78 | + return $this->itemInstances[$key]; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function setItem(CacheItemInterface $item) |
87 | 87 | { |
88 | 88 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
89 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
89 | + $this->itemInstances[$item->getKey()] = $item; |
|
90 | 90 | |
91 | 91 | return $this; |
92 | 92 | } else { |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | $collection = []; |
105 | 105 | foreach ($keys as $key) { |
106 | - $collection[ $key ] = $this->getItem($key); |
|
106 | + $collection[$key] = $this->getItem($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | return $collection; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | if ($this->hasItem($key) && $this->driverDelete($item)) { |
147 | 147 | $item->setHit(false); |
148 | 148 | CacheManager::$WriteHits++; |
149 | - unset($this->itemInstances[ $key ]); |
|
149 | + unset($this->itemInstances[$key]); |
|
150 | 150 | |
151 | 151 | return true; |
152 | 152 | } |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @var ExtendedCacheItemInterface $item |
184 | 184 | */ |
185 | 185 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
186 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
186 | + $this->itemInstances[$item->getKey()] = $item; |
|
187 | 187 | } |
188 | - if($this->driverWrite($item) && $this->driverWriteTags($item)) |
|
188 | + if ($this->driverWrite($item) && $this->driverWriteTags($item)) |
|
189 | 189 | { |
190 | 190 | $item->setHit(true); |
191 | 191 | CacheManager::$WriteHits++; |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | public function saveDeferred(CacheItemInterface $item) |
203 | 203 | { |
204 | 204 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
205 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
205 | + $this->itemInstances[$item->getKey()] = $item; |
|
206 | 206 | } |
207 | 207 | |
208 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
208 | + return $this->deferredList[$item->getKey()] = $item; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | foreach ($this->deferredList as $key => $item) { |
219 | 219 | $result = $this->save($item); |
220 | 220 | if ($return !== false) { |
221 | - unset($this->deferredList[ $key ]); |
|
221 | + unset($this->deferredList[$key]); |
|
222 | 222 | $return = $result; |
223 | 223 | } |
224 | 224 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | * getItem() call in delete() method |
66 | 66 | */ |
67 | 67 | $this->driverDelete($item); |
68 | - }else{ |
|
68 | + } else{ |
|
69 | 69 | $item->setHit(true); |
70 | 70 | } |
71 | 71 | } |
@@ -128,7 +128,7 @@ |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @return bool |
|
131 | + * @return boolean|null |
|
132 | 132 | */ |
133 | 133 | public function driverConnect() |
134 | 134 | { |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
143 | 143 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
144 | 144 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
145 | - [ |
|
145 | + [ |
|
146 | 146 | 'bucket' => 'default', |
147 | 147 | 'password' => '', |
148 | - ], |
|
148 | + ], |
|
149 | 149 | ]; |
150 | 150 | |
151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | { |
210 | 210 | $info = $this->getBucket()->manager()->info(); |
211 | 211 | return (new driverStatistic()) |
212 | - ->setSize($info['basicStats']['diskUsed']) |
|
213 | - ->setRawData($info) |
|
214 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
212 | + ->setSize($info['basicStats']['diskUsed']) |
|
213 | + ->setRawData($info) |
|
214 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
215 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |
@@ -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' => '', |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | $this->instance = $this->instance ?: new CouchbaseClient("couchbase://{$host}", $username, $password); |
152 | 152 | |
153 | 153 | foreach ($buckets as $bucket) { |
154 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
155 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
154 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
155 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | protected function getBucket() |
164 | 164 | { |
165 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
165 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
174 | 174 | { |
175 | 175 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
176 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
176 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
177 | 177 | } else { |
178 | 178 | throw new \LogicException('A bucket instance with this name already exists.'); |
179 | 179 | } |
@@ -212,6 +212,6 @@ discard block |
||
212 | 212 | ->setSize($info['basicStats']['diskUsed']) |
213 | 213 | ->setRawData($info) |
214 | 214 | ->setData(implode(', ', array_keys($this->itemInstances))) |
215 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][0]['version'] . ', Uptime (in days): ' . round($info[ 'nodes' ][0][ 'uptime' ] / 86400, 1). "\n For more information see RawData."); |
|
215 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @param \Psr\Cache\CacheItemInterface $item |
56 | - * @return mixed |
|
56 | + * @return boolean |
|
57 | 57 | * @throws \InvalidArgumentException |
58 | 58 | */ |
59 | 59 | public function driverWrite(CacheItemInterface $item) |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @param $key |
73 | - * @return mixed |
|
73 | + * @return boolean |
|
74 | 74 | */ |
75 | 75 | public function driverRead($key) |
76 | 76 | { |
@@ -140,9 +140,9 @@ |
||
140 | 140 | { |
141 | 141 | $stat = new driverStatistic(); |
142 | 142 | $stat->setInfo('[Devtrue] A void info string') |
143 | - ->setSize(0) |
|
144 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
145 | - ->setRawData(true); |
|
143 | + ->setSize(0) |
|
144 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
145 | + ->setRawData(true); |
|
146 | 146 | |
147 | 147 | return $stat; |
148 | 148 | } |
@@ -14,7 +14,6 @@ |
||
14 | 14 | |
15 | 15 | namespace phpFastCache\Drivers\Files; |
16 | 16 | |
17 | -use phpFastCache\Cache\ExtendedCacheItemInterface; |
|
18 | 17 | use phpFastCache\Core\DriverAbstract; |
19 | 18 | use phpFastCache\Core\PathSeekerTrait; |
20 | 19 | use phpFastCache\Core\StandardPsr6StructureTrait; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @param \Psr\Cache\CacheItemInterface $item |
58 | - * @return mixed |
|
58 | + * @return boolean|null |
|
59 | 59 | * @throws \InvalidArgumentException |
60 | 60 | */ |
61 | 61 | public function driverWrite(CacheItemInterface $item) |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | /** |
212 | 212 | * @param string $optionName |
213 | 213 | * @param mixed $optionValue |
214 | - * @return bool |
|
214 | + * @return boolean|null |
|
215 | 215 | * @throws \InvalidArgumentException |
216 | 216 | */ |
217 | 217 | public static function isValidOption($optionName, $optionValue) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | /** |
242 | - * @return array |
|
242 | + * @return string[] |
|
243 | 243 | */ |
244 | 244 | public static function getValidOptions() |
245 | 245 | { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | - * @return array |
|
250 | + * @return string[] |
|
251 | 251 | */ |
252 | 252 | public static function getRequiredOptions() |
253 | 253 | { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /* |
77 | 77 | * Skip if Existing Caching in Options |
78 | 78 | */ |
79 | - if (isset($option[ 'skipExisting' ]) && $option[ 'skipExisting' ] == true && file_exists($file_path)) { |
|
79 | + if (isset($option['skipExisting']) && $option['skipExisting'] == true && file_exists($file_path)) { |
|
80 | 80 | $content = $this->readfile($file_path); |
81 | 81 | $old = $this->decode($content); |
82 | 82 | $toWrite = false; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public static function isValidOption($optionName, $optionValue) |
223 | 223 | { |
224 | 224 | parent::isValidOption($optionName, $optionValue); |
225 | - switch($optionName) |
|
225 | + switch ($optionName) |
|
226 | 226 | { |
227 | 227 | case 'path': |
228 | 228 | return is_string($optionValue); |
@@ -254,9 +254,9 @@ |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
257 | - ->setRawData([]) |
|
258 | - ->setSize(Directory::dirSize($path)) |
|
259 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
257 | + ->setRawData([]) |
|
258 | + ->setSize(Directory::dirSize($path)) |
|
259 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
260 | 260 | |
261 | 261 | return $stat; |
262 | 262 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | - * @param $keyword |
|
214 | + * @param string $keyword |
|
215 | 215 | * @param bool $reset |
216 | 216 | * @return PDO |
217 | 217 | */ |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | /** |
250 | 250 | * @param \Psr\Cache\CacheItemInterface $item |
251 | - * @return mixed |
|
251 | + * @return boolean |
|
252 | 252 | * @throws \InvalidArgumentException |
253 | 253 | */ |
254 | 254 | public function driverWrite(CacheItemInterface $item) |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
402 | - * @return bool |
|
402 | + * @return boolean|null |
|
403 | 403 | */ |
404 | 404 | public function driverConnect() |
405 | 405 | { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
153 | 153 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
154 | - PDO::ERRMODE_EXCEPTION); |
|
154 | + PDO::ERRMODE_EXCEPTION); |
|
155 | 155 | |
156 | 156 | if ($createTable == true) { |
157 | 157 | $this->initIndexing($PDO); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | // look for keyword |
187 | 187 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
188 | 188 | $stm->execute([ |
189 | - ':keyword' => $keyword, |
|
189 | + ':keyword' => $keyword, |
|
190 | 190 | ]); |
191 | 191 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
192 | 192 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | $db = $this->currentDB; |
199 | 199 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
200 | 200 | $stm->execute([ |
201 | - ':keyword' => $keyword, |
|
202 | - ':db' => $db, |
|
201 | + ':keyword' => $keyword, |
|
202 | + ':db' => $db, |
|
203 | 203 | ]); |
204 | 204 | } |
205 | 205 | |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | if ($toWrite == true) { |
271 | 271 | try { |
272 | 272 | $stm = $this->getDb($item->getKey()) |
273 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
273 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
274 | 274 | $stm->execute([ |
275 | - ':keyword' => $item->getKey(), |
|
276 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
277 | - ':exp' => time() + $item->getTtl(), |
|
275 | + ':keyword' => $item->getKey(), |
|
276 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
277 | + ':exp' => time() + $item->getTtl(), |
|
278 | 278 | ]); |
279 | 279 | |
280 | 280 | return true; |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | |
283 | 283 | try { |
284 | 284 | $stm = $this->getDb($item->getKey(), true) |
285 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
285 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
286 | 286 | $stm->execute([ |
287 | - ':keyword' => $item->getKey(), |
|
288 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
289 | - ':exp' => time() + $item->getTtl(), |
|
287 | + ':keyword' => $item->getKey(), |
|
288 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
289 | + ':exp' => time() + $item->getTtl(), |
|
290 | 290 | ]); |
291 | 291 | } catch (PDOException $e) { |
292 | 292 | return false; |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | { |
309 | 309 | try { |
310 | 310 | $stm = $this->getDb($item->getKey()) |
311 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
311 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
312 | 312 | $stm->execute([ |
313 | - ':keyword' => $item->getKey(), |
|
314 | - ':U' => time(), |
|
313 | + ':keyword' => $item->getKey(), |
|
314 | + ':U' => time(), |
|
315 | 315 | ]); |
316 | 316 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
317 | 317 | |
318 | 318 | } catch (PDOException $e) { |
319 | 319 | try { |
320 | 320 | $stm = $this->getDb($item->getKey(), true) |
321 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
321 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword AND (`exp` >= :U) LIMIT 1"); |
|
322 | 322 | $stm->execute([ |
323 | - ':keyword' => $item->getKey(), |
|
324 | - ':U' => time(), |
|
323 | + ':keyword' => $item->getKey(), |
|
324 | + ':U' => time(), |
|
325 | 325 | ]); |
326 | 326 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
327 | 327 | } catch (PDOException $e) { |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | if ($item instanceof Item) { |
360 | 360 | try { |
361 | 361 | $stm = $this->getDb($item->getKey()) |
362 | - //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
363 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
362 | + //->prepare("DELETE FROM `caching` WHERE (`id`=:id) OR (`exp` <= :U) "); |
|
363 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
364 | 364 | |
365 | 365 | return $stm->execute([ |
366 | 366 | // ':id' => $row[ 'id' ], |
367 | - ':keyword' => $item->getKey(), |
|
368 | - ':U' => time(), |
|
367 | + ':keyword' => $item->getKey(), |
|
368 | + ':U' => time(), |
|
369 | 369 | ]); |
370 | 370 | } catch (PDOException $e) { |
371 | 371 | return false; |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | } |
429 | 429 | |
430 | 430 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
431 | - ->setRawData([]) |
|
432 | - ->setSize(Directory::dirSize($path)) |
|
433 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
431 | + ->setRawData([]) |
|
432 | + ->setSize(Directory::dirSize($path)) |
|
433 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
434 | 434 | |
435 | 435 | return $stat; |
436 | 436 | } |
@@ -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; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | return; |
28 | 28 | } else if (strpos($entity, 'Psr\Cache') === 0) { |
29 | 29 | trigger_error('If you cannot use <b>composer</b>, you have to include manually the Psr\\Cache interfaces.<br />See: https://github.com/php-fig/cache/tree/master/src<br /> Called ' . $entity, |
30 | - E_USER_ERROR); |
|
30 | + E_USER_ERROR); |
|
31 | 31 | |
32 | 32 | return; |
33 | 33 | } |
@@ -42,5 +42,5 @@ discard block |
||
42 | 42 | |
43 | 43 | if (class_exists('Composer\Autoload\ClassLoader')) { |
44 | 44 | trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
45 | - E_USER_WARNING); |
|
45 | + E_USER_WARNING); |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -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. |
@@ -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 | } |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | protected static function cleanFileName($filename) |
161 | 161 | { |
162 | 162 | $regex = [ |
163 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
164 | - '/\.$/', |
|
165 | - '/^\./', |
|
163 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
164 | + '/\.$/', |
|
165 | + '/^\./', |
|
166 | 166 | ]; |
167 | 167 | $replace = ['-', '', '']; |
168 | 168 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | chmod($path, 0777); |
183 | 183 | } catch (phpFastCacheDriverException $e) { |
184 | 184 | throw new phpFastCacheDriverException('PLEASE CHMOD ' . $path . ' - 0777 OR ANY WRITABLE PERMISSION!', |
185 | - 92); |
|
185 | + 92); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 |
@@ -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 | */ |
@@ -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 |
@@ -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); |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | public function driverConnect() |
128 | 128 | { |
129 | 129 | $server = isset($this->config[ 'redis' ]) ? $this->config[ 'redis' ] : [ |
130 | - 'host' => '127.0.0.1', |
|
131 | - 'port' => '6379', |
|
132 | - 'password' => '', |
|
133 | - 'database' => '', |
|
130 | + 'host' => '127.0.0.1', |
|
131 | + 'port' => '6379', |
|
132 | + 'password' => '', |
|
133 | + 'database' => '', |
|
134 | 134 | ]; |
135 | 135 | |
136 | 136 | $config = [ |
137 | - 'host' => $server[ 'host' ], |
|
137 | + 'host' => $server[ 'host' ], |
|
138 | 138 | ]; |
139 | 139 | |
140 | 140 | $port = isset($server[ 'port' ]) ? $server[ 'port' ] : ''; |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | public function getStats() |
197 | 197 | { |
198 | 198 | return (new driverStatistic()) |
199 | - ->setRawData($this->instance->info()) |
|
200 | - ->setSize(0) |
|
201 | - ->setInfo(''); |
|
199 | + ->setRawData($this->instance->info()) |
|
200 | + ->setSize(0) |
|
201 | + ->setInfo(''); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |