@@ -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. |
@@ -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.'); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } else { |
54 | 54 | $this->driverConnect(); |
55 | 55 | |
56 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
56 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
57 | 57 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
58 | 58 | } |
59 | 59 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | protected function driverConnect() |
131 | 131 | { |
132 | 132 | $this->instance = new MemcacheSoftware(); |
133 | - $servers = (!empty($this->config[ 'servers' ]) && is_array($this->config[ 'servers' ]) ? $this->config[ 'servers' ] : []); |
|
133 | + $servers = (!empty($this->config['servers']) && is_array($this->config['servers']) ? $this->config['servers'] : []); |
|
134 | 134 | if (count($servers) < 1) { |
135 | 135 | $servers = [ |
136 | 136 | [ |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | |
145 | 145 | foreach ($servers as $server) { |
146 | 146 | try { |
147 | - if (!$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
147 | + if (!$this->instance->addServer($server['host'], $server['port'])) { |
|
148 | 148 | $this->fallback = true; |
149 | 149 | } |
150 | - if (!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password' ])) { |
|
151 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password' ]); |
|
150 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
151 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
152 | 152 | } |
153 | 153 | } catch (\Exception $e) { |
154 | 154 | $this->fallback = true; |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function getStats() |
169 | 169 | { |
170 | - $stats = (array)$this->instance->getstats(); |
|
171 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
172 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
173 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
170 | + $stats = (array) $this->instance->getstats(); |
|
171 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
172 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
173 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
174 | 174 | |
175 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
175 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
176 | 176 | |
177 | 177 | return (new DriverStatistic()) |
178 | 178 | ->setData(implode(', ', array_keys($this->itemInstances))) |
179 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
179 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
180 | 180 | ->setRawData($stats) |
181 | - ->setSize($stats[ 'bytes' ]); |
|
181 | + ->setSize($stats['bytes']); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | \ No newline at end of file |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | protected function driverConnect() |
126 | 126 | { |
127 | 127 | try { |
128 | - $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
|
128 | + $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [ |
|
129 | 129 | 'host' => "127.0.0.1", |
130 | 130 | 'port' => 8888, |
131 | 131 | 'password' => '', |
132 | 132 | 'timeout' => 2000, |
133 | 133 | ]; |
134 | 134 | |
135 | - $host = $server[ 'host' ]; |
|
136 | - $port = isset($server[ 'port' ]) ? (int)$server[ 'port' ] : 8888; |
|
137 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
138 | - $timeout = !empty($server[ 'timeout' ]) ? (int)$server[ 'timeout' ] : 2000; |
|
135 | + $host = $server['host']; |
|
136 | + $port = isset($server['port']) ? (int) $server['port'] : 8888; |
|
137 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
138 | + $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000; |
|
139 | 139 | $this->instance = new SimpleSSDB($host, $port, $timeout); |
140 | 140 | if (!empty($password)) { |
141 | 141 | $this->instance->auth($password); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * Data returned by Ssdb are very poorly formatted |
170 | 170 | * using hardcoded offset of pair key-value :-( |
171 | 171 | */ |
172 | - $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
|
172 | + $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[2], $info[6])) |
|
173 | 173 | ->setRawData($info) |
174 | 174 | ->setData(implode(', ', array_keys($this->itemInstances))) |
175 | 175 | ->setSize($this->instance->dbsize()); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | if ($item instanceof Item) { |
89 | 89 | try { |
90 | - $result = (array)$this->getCollection()->updateOne( |
|
90 | + $result = (array) $this->getCollection()->updateOne( |
|
91 | 91 | ['_id' => $item->getEncodedKey()], |
92 | 92 | [ |
93 | 93 | '$set' => [ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | throw new phpFastCacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
103 | 103 | } |
104 | 104 | |
105 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
105 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
106 | 106 | } else { |
107 | 107 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
108 | 108 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | |
119 | 119 | if ($document) { |
120 | 120 | return [ |
121 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
122 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
123 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
121 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
122 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
123 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
124 | 124 | ]; |
125 | 125 | } else { |
126 | 126 | return null; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | $this->save($this->getItem('__PFC_CACHE_CLEARED__')->set(true)); |
167 | 167 | |
168 | - return !empty($result[ 'ok' ]); |
|
168 | + return !empty($result['ok']); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | if ($this->instance instanceof \MongoDB\Driver\Manager) { |
179 | 179 | throw new LogicException('Already connected to Mongodb server'); |
180 | 180 | } else { |
181 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
182 | - $port = isset($this->config[ 'port' ]) ? $this->config[ 'port' ] : '27017'; |
|
183 | - $timeout = isset($this->config[ 'timeout' ]) ? $this->config[ 'timeout' ] : 3; |
|
184 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
185 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
186 | - $collectionName = isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'; |
|
187 | - $databaseName = isset($this->config[ 'databaseName' ]) ? $this->config[ 'databaseName' ] : 'phpFastCache'; |
|
181 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
182 | + $port = isset($this->config['port']) ? $this->config['port'] : '27017'; |
|
183 | + $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 3; |
|
184 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
185 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
186 | + $collectionName = isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'; |
|
187 | + $databaseName = isset($this->config['databaseName']) ? $this->config['databaseName'] : 'phpFastCache'; |
|
188 | 188 | |
189 | 189 | |
190 | 190 | /** |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | 'recordStats' => 0, |
227 | 227 | 'repl' => 0, |
228 | 228 | 'metrics' => 0, |
229 | - ]))->toArray()[ 0 ]; |
|
229 | + ]))->toArray()[0]; |
|
230 | 230 | |
231 | 231 | $collectionStats = $this->instance->executeCommand('phpFastCache', new Command([ |
232 | - 'collStats' => (isset($this->config[ 'collectionName' ]) ? $this->config[ 'collectionName' ] : 'Cache'), |
|
232 | + 'collStats' => (isset($this->config['collectionName']) ? $this->config['collectionName'] : 'Cache'), |
|
233 | 233 | 'verbose' => true, |
234 | - ]))->toArray()[ 0 ]; |
|
234 | + ]))->toArray()[0]; |
|
235 | 235 | |
236 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
236 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
237 | 237 | $array = $callback($array); |
238 | 238 | |
239 | 239 | if (is_object($array) || is_array($array)) { |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | return $array; |
246 | 246 | }; |
247 | 247 | |
248 | - $callback = function ($item) { |
|
248 | + $callback = function($item) { |
|
249 | 249 | /** |
250 | 250 | * Remove unserializable properties |
251 | 251 | */ |
252 | 252 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
253 | - return (string)$item; |
|
253 | + return (string) $item; |
|
254 | 254 | } |
255 | 255 | return $item; |
256 | 256 | }; |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | } else { |
137 | 137 | |
138 | 138 | |
139 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
140 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
141 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
142 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
139 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
140 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
141 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
142 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
143 | 143 | [ |
144 | 144 | 'bucket' => 'default', |
145 | 145 | 'password' => '', |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | $this->instance = new CouchbaseClient("couchbase://{$host}", $username, $password); |
150 | 150 | |
151 | 151 | foreach ($buckets as $bucket) { |
152 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
153 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
152 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
153 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -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 phpFastCacheLogicException('A bucket instance with this name already exists.'); |
179 | 179 | } |
@@ -193,10 +193,10 @@ 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, |
|
199 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, |
|
200 | 200 | 1) . "\n For more information see RawData."); |
201 | 201 | } |
202 | 202 | } |
203 | 203 | \ No newline at end of file |
@@ -145,11 +145,11 @@ |
||
145 | 145 | */ |
146 | 146 | public function getStats() |
147 | 147 | { |
148 | - $stats = (array)zend_shm_cache_info(); |
|
148 | + $stats = (array) zend_shm_cache_info(); |
|
149 | 149 | return (new DriverStatistic()) |
150 | 150 | ->setData(implode(', ', array_keys($this->itemInstances))) |
151 | - ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats[ 'items_total' ])) |
|
151 | + ->setInfo(sprintf("The Zend memory have %d item(s) in cache.\n For more information see RawData.", $stats['items_total'])) |
|
152 | 152 | ->setRawData($stats) |
153 | - ->setSize($stats[ 'memory_total' ]); |
|
153 | + ->setSize($stats['memory_total']); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | \ No newline at end of file |