@@ -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. |
@@ -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; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $keyword = self::PREFIX . $item->getKey(); |
| 81 | 81 | $v = json_encode($this->driverPreWrap($item)); |
| 82 | 82 | |
| 83 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
| 83 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | // return null if no caching |
| 102 | 102 | // return value if in caching |
| 103 | 103 | $keyword = self::PREFIX . $item->getKey(); |
| 104 | - $x = isset($_COOKIE[ $keyword ]) ? json_decode($_COOKIE[ $keyword ], true) : false; |
|
| 104 | + $x = isset($_COOKIE[$keyword]) ? json_decode($_COOKIE[$keyword], true) : false; |
|
| 105 | 105 | |
| 106 | 106 | if ($x == false) { |
| 107 | 107 | return null; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | $this->driverConnect(); |
| 124 | 124 | $keyword = self::PREFIX . $key; |
| 125 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
| 125 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
| 126 | 126 | |
| 127 | 127 | return $x ? $x - time() : $x; |
| 128 | 128 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | if ($item instanceof Item) { |
| 141 | 141 | $this->driverConnect(); |
| 142 | 142 | $keyword = self::PREFIX . $item->getKey(); |
| 143 | - $_COOKIE[ $keyword ] = null; |
|
| 143 | + $_COOKIE[$keyword] = null; |
|
| 144 | 144 | |
| 145 | 145 | return @setcookie($keyword, null, -10); |
| 146 | 146 | } else { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $this->driverConnect(); |
| 158 | 158 | foreach ($_COOKIE as $keyword => $value) { |
| 159 | 159 | if (strpos($keyword, self::PREFIX) !== false) { |
| 160 | - $_COOKIE[ $keyword ] = null; |
|
| 160 | + $_COOKIE[$keyword] = null; |
|
| 161 | 161 | $result = @setcookie($keyword, null, -10); |
| 162 | 162 | if ($return !== false) { |
| 163 | 163 | $return = $result; |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | public function getMultiple($keys, $default = null) |
| 111 | 111 | { |
| 112 | 112 | try { |
| 113 | - return array_map(function (ExtendedCacheItemInterface $item) { |
|
| 113 | + return array_map(function(ExtendedCacheItemInterface $item) { |
|
| 114 | 114 | return $item->get(); |
| 115 | 115 | }, $this->internalCacheInstance->getItems($keys)); |
| 116 | 116 | } catch (phpFastCacheInvalidArgumentException $e) { |
@@ -130,11 +130,11 @@ |
||
| 130 | 130 | { |
| 131 | 131 | $memInfo = wincache_ucache_meminfo(); |
| 132 | 132 | $info = wincache_ucache_info(); |
| 133 | - $date = (new \DateTime())->setTimestamp(time() - $info[ 'total_cache_uptime' ]); |
|
| 133 | + $date = (new \DateTime())->setTimestamp(time() - $info['total_cache_uptime']); |
|
| 134 | 134 | |
| 135 | 135 | return (new DriverStatistic()) |
| 136 | 136 | ->setInfo(sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
| 137 | - ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
| 137 | + ->setSize($memInfo['memory_free'] - $memInfo['memory_total']) |
|
| 138 | 138 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 139 | 139 | ->setRawData($memInfo); |
| 140 | 140 | } |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | $info = xcache_info(XC_TYPE_VAR, 0); |
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | - ->setSize(abs($info[ 'size' ] - $info[ 'avail' ])) |
|
| 140 | + ->setSize(abs($info['size'] - $info['avail'])) |
|
| 141 | 141 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 142 | 142 | ->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES))) |
| 143 | 143 | ->setRawData($info); |
@@ -133,14 +133,14 @@ |
||
| 133 | 133 | */ |
| 134 | 134 | public function getStats() |
| 135 | 135 | { |
| 136 | - $stats = (array)apcu_cache_info(); |
|
| 137 | - $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
|
| 136 | + $stats = (array) apcu_cache_info(); |
|
| 137 | + $date = (new \DateTime())->setTimestamp($stats['start_time']); |
|
| 138 | 138 | |
| 139 | 139 | return (new DriverStatistic()) |
| 140 | 140 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 141 | 141 | ->setInfo(sprintf("The APCU cache is up since %s, and have %d item(s) in cache.\n For more information see RawData.", $date->format(DATE_RFC2822), |
| 142 | - $stats[ 'num_entries' ])) |
|
| 142 | + $stats['num_entries'])) |
|
| 143 | 143 | ->setRawData($stats) |
| 144 | - ->setSize($stats[ 'mem_size' ]); |
|
| 144 | + ->setSize($stats['mem_size']); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | \ No newline at end of file |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function driverConnect() |
| 127 | 127 | { |
| 128 | - $config = isset($this->config[ 'predis' ]) ? $this->config[ 'predis' ] : []; |
|
| 128 | + $config = isset($this->config['predis']) ? $this->config['predis'] : []; |
|
| 129 | 129 | |
| 130 | 130 | $this->instance = new PredisClient(array_merge([ |
| 131 | 131 | 'host' => '127.0.0.1', |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | public function getStats() |
| 170 | 170 | { |
| 171 | 171 | $info = $this->instance->info(); |
| 172 | - $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
| 173 | - $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
| 174 | - $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
| 172 | + $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
|
| 173 | + $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
|
| 174 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
| 175 | 175 | |
| 176 | 176 | return (new DriverStatistic()) |
| 177 | 177 | ->setData(implode(', ', array_keys($this->itemInstances))) |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); |
| 134 | 134 | |
| 135 | 135 | if ($results instanceof Cassandra\Rows && $results->count() === 1) { |
| 136 | - return $this->decode($results->first()[ 'cache_data' ]); |
|
| 136 | + return $this->decode($results->first()['cache_data']); |
|
| 137 | 137 | } else { |
| 138 | 138 | return null; |
| 139 | 139 | } |
@@ -206,18 +206,18 @@ discard block |
||
| 206 | 206 | if ($this->instance instanceof CassandraSession) { |
| 207 | 207 | throw new phpFastCacheLogicException('Already connected to Couchbase server'); |
| 208 | 208 | } else { |
| 209 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
| 210 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : 9042; |
|
| 211 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 2; |
|
| 212 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
| 213 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
| 209 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
| 210 | + $port = isset($this->config['port']) ? $this->config['port'] : 9042; |
|
| 211 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 2; |
|
| 212 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
| 213 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
| 214 | 214 | |
| 215 | 215 | $clusterBuilder = Cassandra::cluster() |
| 216 | 216 | ->withContactPoints($host) |
| 217 | 217 | ->withPort($port); |
| 218 | 218 | |
| 219 | - if (!empty($this->config[ 'ssl' ][ 'enabled' ])) { |
|
| 220 | - if (!empty($this->config[ 'ssl' ][ 'verify' ])) { |
|
| 219 | + if (!empty($this->config['ssl']['enabled'])) { |
|
| 220 | + if (!empty($this->config['ssl']['verify'])) { |
|
| 221 | 221 | $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_PEER_CERT); |
| 222 | 222 | } else { |
| 223 | 223 | $sslBuilder = Cassandra::ssl()->withVerifyFlags(Cassandra::VERIFY_NONE); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | ))); |
| 297 | 297 | |
| 298 | 298 | return (new DriverStatistic()) |
| 299 | - ->setSize($result->first()[ 'cache_size' ]) |
|
| 299 | + ->setSize($result->first()['cache_size']) |
|
| 300 | 300 | ->setRawData([]) |
| 301 | 301 | ->setData(implode(', ', array_keys($this->itemInstances))) |
| 302 | 302 | ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |