@@ -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); |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | $info = $this->getBucket()->manager()->info(); |
| 194 | 194 | |
| 195 | 195 | return (new driverStatistic()) |
| 196 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 197 | - ->setRawData($info) |
|
| 198 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 199 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
| 196 | + ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 197 | + ->setRawData($info) |
|
| 198 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 199 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | \ 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 | } |
@@ -193,9 +193,9 @@ discard block |
||
| 193 | 193 | $info = $this->getBucket()->manager()->info(); |
| 194 | 194 | |
| 195 | 195 | return (new driverStatistic()) |
| 196 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
| 196 | + ->setSize($info['basicStats']['diskUsed']) |
|
| 197 | 197 | ->setRawData($info) |
| 198 | 198 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 199 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
| 199 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | \ No newline at end of file |
@@ -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 | } |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | |
| 17 | 17 | use PDO; |
| 18 | 18 | use PDOException; |
| 19 | -use phpFastCache\Core\Item\ExtendedCacheItemInterface; |
|
| 20 | 19 | use phpFastCache\Core\Pool\DriverBaseTrait; |
| 21 | 20 | use phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 22 | 21 | use phpFastCache\Core\Pool\IO\PathSeekerTrait; |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
| 163 | 163 | $stm->execute(); |
| 164 | 164 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 165 | - if (!isset($row[ 'db' ])) { |
|
| 165 | + if (!isset($row['db'])) { |
|
| 166 | 166 | $db = 1; |
| 167 | - } elseif ($row[ 'db' ] <= 1) { |
|
| 167 | + } elseif ($row['db'] <= 1) { |
|
| 168 | 168 | $db = 1; |
| 169 | 169 | } else { |
| 170 | - $db = $row[ 'db' ]; |
|
| 170 | + $db = $row['db']; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // check file size |
@@ -189,8 +189,8 @@ discard block |
||
| 189 | 189 | ':keyword' => $keyword, |
| 190 | 190 | ]); |
| 191 | 191 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
| 192 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
| 193 | - $db = $row[ 'db' ]; |
|
| 192 | + if (isset($row['db']) && $row['db'] != '') { |
|
| 193 | + $db = $row['db']; |
|
| 194 | 194 | } else { |
| 195 | 195 | /* |
| 196 | 196 | * Insert new to Indexing |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | /** |
| 222 | 222 | * init instant |
| 223 | 223 | */ |
| 224 | - if (!isset($this->instance[ $instant ])) { |
|
| 224 | + if (!isset($this->instance[$instant])) { |
|
| 225 | 225 | // check DB Files ready or not |
| 226 | 226 | $createTable = false; |
| 227 | 227 | if (!file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | $this->initDB($PDO); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - $this->instance[ $instant ] = $PDO; |
|
| 237 | + $this->instance[$instant] = $PDO; |
|
| 238 | 238 | unset($PDO); |
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return $this->instance[ $instant ]; |
|
| 242 | + return $this->instance[$instant]; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * Check for Cross-Driver type confusion |
| 254 | 254 | */ |
| 255 | 255 | if ($item instanceof Item) { |
| 256 | - $skipExisting = isset($this->config[ 'skipExisting' ]) ? $this->config[ 'skipExisting' ] : false; |
|
| 256 | + $skipExisting = isset($this->config['skipExisting']) ? $this->config['skipExisting'] : false; |
|
| 257 | 257 | $toWrite = true; |
| 258 | 258 | |
| 259 | 259 | // check in cache first |
@@ -329,8 +329,8 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if (isset($row[ 'object' ])) { |
|
| 333 | - return $this->decode($row[ 'object' ]); |
|
| 332 | + if (isset($row['object'])) { |
|
| 333 | + return $this->decode($row['object']); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | return null; |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | $this->driver->setItem($this); |
| 43 | 43 | } else { |
| 44 | 44 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', |
| 45 | - gettype($key))); |
|
| 45 | + gettype($key))); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
@@ -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; |
@@ -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 | { |
@@ -176,9 +176,9 @@ |
||
| 176 | 176 | public function getStats() |
| 177 | 177 | { |
| 178 | 178 | return (new driverStatistic()) |
| 179 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 180 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($this->getLeveldbFile())) |
|
| 181 | - ->setSize(Directory::dirSize($this->getLeveldbFile())); |
|
| 179 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 180 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($this->getLeveldbFile())) |
|
| 181 | + ->setSize(Directory::dirSize($this->getLeveldbFile())); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -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 | { |
@@ -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 | } |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | /** |
| 78 | 78 | * Skip if Existing Caching in Options |
| 79 | 79 | */ |
| 80 | - if (isset($this->config[ 'skipExisting' ]) && $this->config[ 'skipExisting' ] == true && file_exists($file_path)) { |
|
| 80 | + if (isset($this->config['skipExisting']) && $this->config['skipExisting'] == true && file_exists($file_path)) { |
|
| 81 | 81 | $content = $this->readfile($file_path); |
| 82 | 82 | $old = $this->decode($content); |
| 83 | 83 | $toWrite = false; |
@@ -83,8 +83,8 @@ |
||
| 83 | 83 | |
| 84 | 84 | $files = new RecursiveIteratorIterator |
| 85 | 85 | ( |
| 86 | - new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
|
| 87 | - RecursiveIteratorIterator::CHILD_FIRST |
|
| 86 | + new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
|
| 87 | + RecursiveIteratorIterator::CHILD_FIRST |
|
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | foreach ($files as $fileinfo) { |
@@ -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 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @param \Psr\Cache\CacheItemInterface $item |
| 60 | - * @return mixed |
|
| 60 | + * @return boolean |
|
| 61 | 61 | * @throws \InvalidArgumentException |
| 62 | 62 | */ |
| 63 | 63 | public function driverWrite(CacheItemInterface $item) |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | namespace phpFastCache\Drivers\Wincache; |
| 16 | 16 | |
| 17 | 17 | use phpFastCache\Core\DriverAbstract; |
| 18 | -use phpFastCache\Core\StandardPsr6StructureTrait; |
|
| 19 | 18 | use phpFastCache\Entities\driverStatistic; |
| 20 | 19 | use phpFastCache\Exceptions\phpFastCacheDriverCheckException; |
| 21 | 20 | use phpFastCache\Exceptions\phpFastCacheDriverException; |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | protected function driverRead(CacheItemInterface $item) |
| 78 | 78 | { |
| 79 | 79 | return [ |
| 80 | - self::DRIVER_DATA_WRAPPER_INDEX => null, |
|
| 81 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
| 82 | - self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
| 80 | + self::DRIVER_DATA_WRAPPER_INDEX => null, |
|
| 81 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
| 82 | + self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
| 83 | 83 | ]; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | $stat = new driverStatistic(); |
| 131 | 131 | $stat->setInfo('[Devnull] A void info string') |
| 132 | - ->setSize(0) |
|
| 133 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 134 | - ->setRawData(null); |
|
| 132 | + ->setSize(0) |
|
| 133 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 134 | + ->setRawData(null); |
|
| 135 | 135 | |
| 136 | 136 | return $stat; |
| 137 | 137 | } |
@@ -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) |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * @param \Psr\Cache\CacheItemInterface $item |
| 115 | - * @return bool |
|
| 115 | + * @return boolean|null |
|
| 116 | 116 | * @throws \InvalidArgumentException |
| 117 | 117 | */ |
| 118 | 118 | public function driverIsHit(CacheItemInterface $item) |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | if ($item instanceof Item) { |
| 84 | 84 | try { |
| 85 | 85 | $result = (array) $this->getCollection()->update( |
| 86 | - ['_id' => $item->getKey()], |
|
| 87 | - [ |
|
| 86 | + ['_id' => $item->getKey()], |
|
| 87 | + [ |
|
| 88 | 88 | '$set' => [ |
| 89 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
| 90 | - self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
| 91 | - self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
| 89 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new MongoDate(time() + $item->getTtl()) : new MongoDate(time())), |
|
| 90 | + self::DRIVER_DATA_WRAPPER_INDEX => new MongoBinData($this->encode($item->get()), MongoBinData::BYTE_ARRAY), |
|
| 91 | + self::DRIVER_TAGS_WRAPPER_INDEX => new MongoBinData($this->encode($item->getTags()), MongoBinData::BYTE_ARRAY), |
|
| 92 | 92 | ], |
| 93 | - ], |
|
| 94 | - ['upsert' => true, 'multiple' => false] |
|
| 93 | + ], |
|
| 94 | + ['upsert' => true, 'multiple' => false] |
|
| 95 | 95 | ); |
| 96 | 96 | } catch (MongoCursorException $e) { |
| 97 | 97 | return false; |
@@ -110,14 +110,14 @@ discard block |
||
| 110 | 110 | protected function driverRead(CacheItemInterface $item) |
| 111 | 111 | { |
| 112 | 112 | $document = $this->getCollection() |
| 113 | - ->findOne(['_id' => $item->getKey()], |
|
| 113 | + ->findOne(['_id' => $item->getKey()], |
|
| 114 | 114 | [self::DRIVER_DATA_WRAPPER_INDEX, self::DRIVER_EDATE_WRAPPER_INDEX, self::DRIVER_TAGS_WRAPPER_INDEX /*'d', 'e'*/]); |
| 115 | 115 | |
| 116 | 116 | if ($document) { |
| 117 | 117 | return [ |
| 118 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 119 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->sec), |
|
| 120 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
| 118 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 119 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->sec), |
|
| 120 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
| 121 | 121 | ]; |
| 122 | 122 | } else { |
| 123 | 123 | return null; |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | * @todo make an url builder |
| 173 | 173 | */ |
| 174 | 174 | $this->instance = $this->instance ?: (new MongodbClient('mongodb://' . |
| 175 | - ($username ?: '') . |
|
| 176 | - ($password ? ":{$password}" : '') . |
|
| 177 | - ($username ? '@' : '') . "{$host}" . |
|
| 178 | - ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
| 175 | + ($username ?: '') . |
|
| 176 | + ($password ? ":{$password}" : '') . |
|
| 177 | + ($username ? '@' : '') . "{$host}" . |
|
| 178 | + ($port != '27017' ? ":{$port}" : ''), ['connectTimeoutMS' => $timeout * 1000]))->phpFastCache; |
|
| 179 | 179 | // $this->instance->Cache->createIndex([self::DRIVER_TIME_WRAPPER_INDEX => 1], ['expireAfterSeconds' => 0]); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -201,25 +201,25 @@ discard block |
||
| 201 | 201 | public function getStats() |
| 202 | 202 | { |
| 203 | 203 | $serverStatus = $this->getCollection()->db->command([ |
| 204 | - 'serverStatus' => 1, |
|
| 205 | - 'recordStats' => 0, |
|
| 206 | - 'repl' => 0, |
|
| 207 | - 'metrics' => 0, |
|
| 204 | + 'serverStatus' => 1, |
|
| 205 | + 'recordStats' => 0, |
|
| 206 | + 'repl' => 0, |
|
| 207 | + 'metrics' => 0, |
|
| 208 | 208 | ]); |
| 209 | 209 | |
| 210 | 210 | $collStats = $this->getCollection()->db->command([ |
| 211 | - 'collStats' => 'Cache', |
|
| 212 | - 'verbose' => true, |
|
| 211 | + 'collStats' => 'Cache', |
|
| 212 | + 'verbose' => true, |
|
| 213 | 213 | ]); |
| 214 | 214 | |
| 215 | 215 | $stats = (new driverStatistic()) |
| 216 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
| 217 | - ->setSize((int) @$collStats[ 'size' ]) |
|
| 218 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 219 | - ->setRawData([ |
|
| 216 | + ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
| 217 | + ->setSize((int) @$collStats[ 'size' ]) |
|
| 218 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
| 219 | + ->setRawData([ |
|
| 220 | 220 | 'serverStatus' => $serverStatus, |
| 221 | 221 | 'collStats' => $collStats, |
| 222 | - ]); |
|
| 222 | + ]); |
|
| 223 | 223 | |
| 224 | 224 | return $stats; |
| 225 | 225 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function driverCheck() |
| 64 | 64 | { |
| 65 | - if(class_exists('MongoDB\Driver\Manager')){ |
|
| 65 | + if (class_exists('MongoDB\Driver\Manager')) { |
|
| 66 | 66 | trigger_error('PhpFastCache currently only support the pecl Mongo extension.<br /> |
| 67 | 67 | The Support for the MongoDB extension will be added coming soon.', E_USER_ERROR); |
| 68 | 68 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
| 100 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
| 101 | 101 | } else { |
| 102 | 102 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
| 103 | 103 | } |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | if ($document) { |
| 117 | 117 | return [ |
| 118 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->bin), |
|
| 119 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->sec), |
|
| 120 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->bin), |
|
| 118 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->bin), |
|
| 119 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->sec), |
|
| 120 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->bin), |
|
| 121 | 121 | ]; |
| 122 | 122 | } else { |
| 123 | 123 | return null; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | if ($item instanceof Item) { |
| 138 | 138 | $deletionResult = (array) $this->getCollection()->remove(['_id' => $item->getKey()], ["w" => 1]); |
| 139 | 139 | |
| 140 | - return (int) $deletionResult[ 'ok' ] === 1 && !$deletionResult[ 'err' ]; |
|
| 140 | + return (int) $deletionResult['ok'] === 1 && !$deletionResult['err']; |
|
| 141 | 141 | } else { |
| 142 | 142 | throw new \InvalidArgumentException('Cross-Driver type confusion detected'); |
| 143 | 143 | } |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | if ($this->instance instanceof MongodbClient) { |
| 162 | 162 | throw new LogicException('Already connected to Mongodb server'); |
| 163 | 163 | } else { |
| 164 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 165 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017'; |
|
| 166 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 3; |
|
| 167 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 168 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 164 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 165 | + $port = isset($this->config['port']) ? $this->config['port'] : '27017'; |
|
| 166 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 3; |
|
| 167 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 168 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 169 | 169 | |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | ]); |
| 214 | 214 | |
| 215 | 215 | $stats = (new driverStatistic()) |
| 216 | - ->setInfo('MongoDB version ' . $serverStatus[ 'version' ] . ', Uptime (in days): ' . round($serverStatus[ 'uptime' ] / 86400, 1) . "\n For more information see RawData.") |
|
| 217 | - ->setSize((int) @$collStats[ 'size' ]) |
|
| 216 | + ->setInfo('MongoDB version ' . $serverStatus['version'] . ', Uptime (in days): ' . round($serverStatus['uptime'] / 86400, 1) . "\n For more information see RawData.") |
|
| 217 | + ->setSize((int) @$collStats['size']) |
|
| 218 | 218 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 219 | 219 | ->setRawData([ |
| 220 | 220 | 'serverStatus' => $serverStatus, |