@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | $this->printSkipText('A driver could not be initialized due to missing requirement: ' . $exception->getMessage()); |
222 | 222 | } else { |
223 | 223 | $this->printFailText(\sprintf( |
224 | - 'Uncaught exception "%s" in "%s" line %d with message: "%s"', |
|
225 | - \get_class($exception), |
|
226 | - $exception->getFile(), |
|
227 | - $exception->getLine(), |
|
228 | - $exception->getMessage() |
|
224 | + 'Uncaught exception "%s" in "%s" line %d with message: "%s"', |
|
225 | + \get_class($exception), |
|
226 | + $exception->getFile(), |
|
227 | + $exception->getLine(), |
|
228 | + $exception->getMessage() |
|
229 | 229 | )); |
230 | 230 | } |
231 | 231 | $this->terminateTest(); |
@@ -272,17 +272,17 @@ discard block |
||
272 | 272 | |
273 | 273 | if ($errorType === '[FATAL ERROR]') { |
274 | 274 | $this->printFailText(\sprintf( |
275 | - "A critical error has been caught: \"%s\" in %s line %d", |
|
276 | - "$errorType $errstr", |
|
277 | - $errfile, |
|
278 | - $errline |
|
275 | + "A critical error has been caught: \"%s\" in %s line %d", |
|
276 | + "$errorType $errstr", |
|
277 | + $errfile, |
|
278 | + $errline |
|
279 | 279 | )); |
280 | 280 | } else { |
281 | 281 | $this->printDebugText(\sprintf( |
282 | - "A non-critical error has been caught: \"%s\" in %s line %d", |
|
283 | - "$errorType $errstr", |
|
284 | - $errfile, |
|
285 | - $errline |
|
282 | + "A non-critical error has been caught: \"%s\" in %s line %d", |
|
283 | + "$errorType $errstr", |
|
284 | + $errfile, |
|
285 | + $errline |
|
286 | 286 | )); |
287 | 287 | } |
288 | 288 | } |
@@ -160,7 +160,7 @@ |
||
160 | 160 | */ |
161 | 161 | public function printText(string $string, bool $strtoupper = false, string $prefix = ''): self |
162 | 162 | { |
163 | - if($prefix){ |
|
163 | + if ($prefix) { |
|
164 | 164 | $string = "[{$prefix}] {$string}"; |
165 | 165 | } |
166 | 166 | if (!$strtoupper) { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use Phpfastcache\Config\ConfigurationOption; |
19 | 19 | use Phpfastcache\Core\Item\ExtendedCacheItemInterface; |
20 | 20 | use Phpfastcache\Exceptions\{ |
21 | - PhpfastcacheInvalidArgumentException, PhpfastcacheDriverCheckException, PhpfastcacheLogicException |
|
21 | + PhpfastcacheInvalidArgumentException, PhpfastcacheDriverCheckException, PhpfastcacheLogicException |
|
22 | 22 | }; |
23 | 23 | use Phpfastcache\Util\ArrayObject; |
24 | 24 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | public function driverPreWrap(ExtendedCacheItemInterface $item): array |
164 | 164 | { |
165 | 165 | $wrap = [ |
166 | - self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
167 | - self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
168 | - self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
166 | + self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
167 | + self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
168 | + self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
169 | 169 | ]; |
170 | 170 | |
171 | 171 | if ($this->getConfig()->isItemDetailedDate()) { |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | ]; |
160 | 160 | |
161 | 161 | if ($this->getConfig()->isItemDetailedDate()) { |
162 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
162 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
163 | 163 | /** |
164 | 164 | * If the creation date exists |
165 | 165 | * reuse it else set a new Date |
166 | 166 | */ |
167 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
167 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
168 | 168 | } else { |
169 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
170 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
169 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
170 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return $wrap; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function driverUnwrapData(array $wrapper) |
181 | 181 | { |
182 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
182 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function driverUnwrapTags(array $wrapper) |
190 | 190 | { |
191 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
191 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function driverUnwrapEdate(array $wrapper) |
200 | 200 | { |
201 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
201 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function driverUnwrapCdate(array $wrapper) |
209 | 209 | { |
210 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
210 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | public function driverUnwrapMdate(array $wrapper) |
219 | 219 | { |
220 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
220 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * that has slow performances |
275 | 275 | */ |
276 | 276 | |
277 | - $tagsItem->set(\array_merge((array)$data, [$item->getKey() => $expTimestamp])); |
|
277 | + $tagsItem->set(\array_merge((array) $data, [$item->getKey() => $expTimestamp])); |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * Set the expiration date |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | $tagsItems = $this->getItems($this->getTagKeys($item->getRemovedTags())); |
297 | 297 | |
298 | 298 | foreach ($tagsItems as $tagsItem) { |
299 | - $data = (array)$tagsItem->get(); |
|
299 | + $data = (array) $tagsItem->get(); |
|
300 | 300 | |
301 | - unset($data[ $item->getKey() ]); |
|
301 | + unset($data[$item->getKey()]); |
|
302 | 302 | $tagsItem->set($data); |
303 | 303 | |
304 | 304 | /** |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | public static function getConfigClass(): string |
380 | 380 | { |
381 | 381 | $localConfigClass = \substr(static::class, 0, \strrpos(static::class, '\\')) . '\Config'; |
382 | - if(\class_exists($localConfigClass) && is_a($localConfigClass, ConfigurationOption::class, true)){ |
|
382 | + if (\class_exists($localConfigClass) && is_a($localConfigClass, ConfigurationOption::class, true)) { |
|
383 | 383 | return $localConfigClass; |
384 | 384 | } |
385 | 385 | return ConfigurationOption::class; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | use Phpfastcache\Entities\ItemBatch; |
22 | 22 | use Phpfastcache\Util\ClassNamespaceResolverTrait; |
23 | 23 | use Phpfastcache\Exceptions\{ |
24 | - PhpfastcacheInvalidArgumentException, PhpfastcacheCoreException, PhpfastcacheLogicException |
|
24 | + PhpfastcacheInvalidArgumentException, PhpfastcacheCoreException, PhpfastcacheLogicException |
|
25 | 25 | }; |
26 | 26 | use Phpfastcache\Config\ConfigurationOption; |
27 | 27 | use Psr\Cache\CacheItemInterface; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | if ($driverArray) { |
91 | 91 | if (!\is_array($driverArray)) { |
92 | 92 | throw new PhpfastcacheCoreException(\sprintf('The driverRead method returned an unexpected variable type: %s', |
93 | - \gettype($driverArray))); |
|
93 | + \gettype($driverArray))); |
|
94 | 94 | } |
95 | 95 | $driverData = $this->driverUnwrapData($driverArray); |
96 | 96 | |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * Reset the Item |
156 | 156 | */ |
157 | 157 | $item->set(null) |
158 | - ->expiresAfter(\abs((int)$this->getConfig()[ 'defaultTtl' ])) |
|
159 | - ->setHit(false) |
|
160 | - ->setTags([]); |
|
158 | + ->expiresAfter(\abs((int)$this->getConfig()[ 'defaultTtl' ])) |
|
159 | + ->setHit(false) |
|
160 | + ->setTags([]); |
|
161 | 161 | if ($this->getConfig()->isItemDetailedDate()) { |
162 | 162 | |
163 | 163 | /** |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | $class = new \ReflectionClass((new \ReflectionObject($this))->getNamespaceName() . '\Item'); |
342 | 342 | $itemBatch = $class->newInstanceArgs([$this, $item->getKey()]); |
343 | 343 | $itemBatch->setEventManager($this->eventManager) |
344 | - ->set(new ItemBatch($item->getKey(), new \DateTime())) |
|
345 | - ->expiresAfter($this->getConfig()->getCacheSlamsTimeout()); |
|
344 | + ->set(new ItemBatch($item->getKey(), new \DateTime())) |
|
345 | + ->expiresAfter($this->getConfig()->getCacheSlamsTimeout()); |
|
346 | 346 | |
347 | 347 | /** |
348 | 348 | * To avoid SPL mismatches |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * due to performance issue on huge |
72 | 72 | * loop dispatching operations |
73 | 73 | */ |
74 | - if (!isset($this->itemInstances[ $key ])) { |
|
74 | + if (!isset($this->itemInstances[$key])) { |
|
75 | 75 | if (\preg_match('~([' . \preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) { |
76 | - throw new PhpfastcacheInvalidArgumentException('Unsupported key character detected: "' . $matches[ 1 ] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
|
76 | + throw new PhpfastcacheInvalidArgumentException('Unsupported key character detected: "' . $matches[1] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | CacheManager::$ReadHits++; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | $driverData = $this->driverUnwrapData($driverArray); |
96 | 96 | |
97 | - if ($this->getConfig()[ 'preventCacheSlams' ]) { |
|
97 | + if ($this->getConfig()['preventCacheSlams']) { |
|
98 | 98 | while ($driverData instanceof ItemBatch) { |
99 | 99 | if ($driverData->getItemDate()->getTimestamp() + $this->getConfig()->getCacheSlamsTimeout() < \time()) { |
100 | 100 | /** |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * Reset the Item |
156 | 156 | */ |
157 | 157 | $item->set(null) |
158 | - ->expiresAfter(\abs((int)$this->getConfig()[ 'defaultTtl' ])) |
|
158 | + ->expiresAfter(\abs((int) $this->getConfig()['defaultTtl'])) |
|
159 | 159 | ->setHit(false) |
160 | 160 | ->setTags([]); |
161 | 161 | if ($this->getConfig()->isItemDetailedDate()) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $item->setHit(true); |
173 | 173 | } |
174 | 174 | } else { |
175 | - $item->expiresAfter(\abs((int)$this->getConfig()[ 'defaultTtl' ])); |
|
175 | + $item->expiresAfter(\abs((int) $this->getConfig()['defaultTtl'])); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | * @param $this ExtendedCacheItemPoolInterface |
186 | 186 | * @param $this ExtendedCacheItemInterface |
187 | 187 | */ |
188 | - $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[ $key ]); |
|
188 | + $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[$key]); |
|
189 | 189 | |
190 | - return $this->itemInstances[ $key ]; |
|
190 | + return $this->itemInstances[$key]; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | public function setItem(CacheItemInterface $item) |
199 | 199 | { |
200 | 200 | if ($this->getClassNamespace() . '\\Item' === \get_class($item)) { |
201 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
201 | + $this->itemInstances[$item->getKey()] = $item; |
|
202 | 202 | |
203 | 203 | return $this; |
204 | 204 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | { |
216 | 216 | $collection = []; |
217 | 217 | foreach ($keys as $key) { |
218 | - $collection[ $key ] = $this->getItem($key); |
|
218 | + $collection[$key] = $this->getItem($key); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return $collection; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
305 | - return (bool)$return; |
|
305 | + return (bool) $return; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | * due to performance issue on huge |
321 | 321 | * loop dispatching operations |
322 | 322 | */ |
323 | - if (!isset($this->itemInstances[ $item->getKey() ])) { |
|
324 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
325 | - } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
323 | + if (!isset($this->itemInstances[$item->getKey()])) { |
|
324 | + $this->itemInstances[$item->getKey()] = $item; |
|
325 | + } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
326 | 326 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
327 | 327 | } |
328 | 328 | |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | public function saveDeferred(CacheItemInterface $item) |
375 | 375 | { |
376 | 376 | if (!\array_key_exists($item->getKey(), $this->itemInstances)) { |
377 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
378 | - } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
377 | + $this->itemInstances[$item->getKey()] = $item; |
|
378 | + } else if (\spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
379 | 379 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
380 | 380 | } |
381 | 381 | |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | $this->eventManager->dispatch('CacheSaveDeferredItem', $this, $item); |
388 | 388 | |
389 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
389 | + return $this->deferredList[$item->getKey()] = $item; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -406,11 +406,11 @@ discard block |
||
406 | 406 | foreach ($this->deferredList as $key => $item) { |
407 | 407 | $result = $this->save($item); |
408 | 408 | if ($return !== false) { |
409 | - unset($this->deferredList[ $key ]); |
|
409 | + unset($this->deferredList[$key]); |
|
410 | 410 | $return = $result; |
411 | 411 | } |
412 | 412 | } |
413 | 413 | |
414 | - return (bool)$return; |
|
414 | + return (bool) $return; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | \ No newline at end of file |
@@ -60,7 +60,7 @@ |
||
60 | 60 | 'scheme' => 'unix', |
61 | 61 | 'path' => $this->getConfig()->getPath() |
62 | 62 | ]); |
63 | - }else{ |
|
63 | + } else{ |
|
64 | 64 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
65 | 65 | } |
66 | 66 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
20 | 20 | use Phpfastcache\Entities\DriverStatistic; |
21 | 21 | use Phpfastcache\Exceptions\{ |
22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheDriverException, PhpfastcacheLogicException |
|
22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheDriverException, PhpfastcacheLogicException |
|
23 | 23 | }; |
24 | 24 | use Phpfastcache\Util\ArrayObject; |
25 | 25 | use Predis\Client as PredisClient; |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | |
75 | 75 | if(!empty($this->getConfig()->getPath())){ |
76 | 76 | $this->instance = new PredisClient([ |
77 | - 'scheme' => 'unix', |
|
78 | - 'path' => $this->getConfig()->getPath() |
|
77 | + 'scheme' => 'unix', |
|
78 | + 'path' => $this->getConfig()->getPath() |
|
79 | 79 | ]); |
80 | 80 | }else{ |
81 | 81 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(\time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
189 | 189 | |
190 | 190 | return (new DriverStatistic()) |
191 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
192 | - ->setRawData($info) |
|
193 | - ->setSize((int) $size) |
|
194 | - ->setInfo(\sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
191 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
192 | + ->setRawData($info) |
|
193 | + ->setSize((int) $size) |
|
194 | + ->setInfo(\sprintf("The Redis daemon v%s is up since %s.\n For more information see RawData. \n Driver size includes the memory allocation size.", |
|
195 | 195 | $version, $date->format(DATE_RFC2822))); |
196 | 196 | } |
197 | 197 | } |
198 | 198 | \ No newline at end of file |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * In case of an user-provided |
65 | 65 | * Predis client just return here |
66 | 66 | */ |
67 | - if($this->getConfig()->getPredisClient() instanceof PredisClient){ |
|
67 | + if ($this->getConfig()->getPredisClient() instanceof PredisClient) { |
|
68 | 68 | $this->instance = $this->getConfig()->getPredisClient(); |
69 | - if(!$this->instance->isConnected()){ |
|
69 | + if (!$this->instance->isConnected()) { |
|
70 | 70 | $this->instance->connect(); |
71 | 71 | } |
72 | 72 | return true; |
73 | 73 | } |
74 | 74 | |
75 | - if(!empty($this->getConfig()->getPath())){ |
|
75 | + if (!empty($this->getConfig()->getPath())) { |
|
76 | 76 | $this->instance = new PredisClient([ |
77 | 77 | 'scheme' => 'unix', |
78 | 78 | 'path' => $this->getConfig()->getPath() |
79 | 79 | ]); |
80 | - }else{ |
|
80 | + } else { |
|
81 | 81 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
82 | 82 | } |
83 | 83 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @see https://redis.io/commands/expire |
124 | 124 | */ |
125 | 125 | if ($ttl <= 0) { |
126 | - return (bool)$this->instance->expire($item->getKey(), 0); |
|
126 | + return (bool) $this->instance->expire($item->getKey(), 0); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload() === 'OK'; |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | public function getStats(): DriverStatistic |
184 | 184 | { |
185 | 185 | $info = $this->instance->info(); |
186 | - $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
187 | - $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
188 | - $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(\time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
186 | + $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
|
187 | + $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
|
188 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(\time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
189 | 189 | |
190 | 190 | return (new DriverStatistic()) |
191 | 191 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | use PDOException; |
20 | 20 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface, IO\IOHelperTrait}; |
21 | 21 | use Phpfastcache\Exceptions\{ |
22 | - PhpfastcacheInvalidArgumentException, PhpfastcacheIOException |
|
22 | + PhpfastcacheInvalidArgumentException, PhpfastcacheIOException |
|
23 | 23 | }; |
24 | 24 | use Psr\Cache\CacheItemInterface; |
25 | 25 | |
@@ -108,18 +108,18 @@ discard block |
||
108 | 108 | { |
109 | 109 | try { |
110 | 110 | $stm = $this->getDb($item->getKey()) |
111 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
111 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
112 | 112 | $stm->execute([ |
113 | - ':keyword' => $item->getKey(), |
|
113 | + ':keyword' => $item->getKey(), |
|
114 | 114 | ]); |
115 | 115 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
116 | 116 | |
117 | 117 | } catch (PDOException $e) { |
118 | 118 | try { |
119 | 119 | $stm = $this->getDb($item->getKey(), true) |
120 | - ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
120 | + ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1"); |
|
121 | 121 | $stm->execute([ |
122 | - ':keyword' => $item->getKey(), |
|
122 | + ':keyword' => $item->getKey(), |
|
123 | 123 | ]); |
124 | 124 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
125 | 125 | } catch (PDOException $e) { |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | if ($item instanceof Item) { |
148 | 148 | try { |
149 | 149 | $stm = $this->getDb($item->getKey()) |
150 | - ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
150 | + ->prepare("INSERT OR REPLACE INTO `caching` (`keyword`,`object`,`exp`) values(:keyword,:object,:exp)"); |
|
151 | 151 | $stm->execute([ |
152 | - ':keyword' => $item->getKey(), |
|
153 | - ':object' => $this->encode($this->driverPreWrap($item)), |
|
154 | - ':exp' => $item->getExpirationDate()->getTimestamp(), |
|
152 | + ':keyword' => $item->getKey(), |
|
153 | + ':object' => $this->encode($this->driverPreWrap($item)), |
|
154 | + ':exp' => $item->getExpirationDate()->getTimestamp(), |
|
155 | 155 | ]); |
156 | 156 | |
157 | 157 | return true; |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | if ($item instanceof Item) { |
177 | 177 | try { |
178 | 178 | $stm = $this->getDb($item->getKey()) |
179 | - ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
179 | + ->prepare("DELETE FROM `caching` WHERE (`exp` <= :U) OR (`keyword`=:keyword) "); |
|
180 | 180 | |
181 | 181 | return $stm->execute([ |
182 | - ':keyword' => $item->getKey(), |
|
183 | - ':U' => \time(), |
|
182 | + ':keyword' => $item->getKey(), |
|
183 | + ':U' => \time(), |
|
184 | 184 | ]); |
185 | 185 | } catch (PDOException $e) { |
186 | 186 | return false; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE); |
262 | 262 | $PDO->setAttribute(PDO::ATTR_ERRMODE, |
263 | - PDO::ERRMODE_EXCEPTION); |
|
263 | + PDO::ERRMODE_EXCEPTION); |
|
264 | 264 | |
265 | 265 | if ($createTable == true) { |
266 | 266 | $this->initIndexing($PDO); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | // look for keyword |
296 | 296 | $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1"); |
297 | 297 | $stm->execute([ |
298 | - ':keyword' => $keyword, |
|
298 | + ':keyword' => $keyword, |
|
299 | 299 | ]); |
300 | 300 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
301 | 301 | if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | $db = $this->currentDB; |
308 | 308 | $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)"); |
309 | 309 | $stm->execute([ |
310 | - ':keyword' => $keyword, |
|
311 | - ':db' => $db, |
|
310 | + ':keyword' => $keyword, |
|
311 | + ':db' => $db, |
|
312 | 312 | ]); |
313 | 313 | } |
314 | 314 |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | - if (isset($row[ 'object' ])) { |
|
131 | - return $this->decode($row[ 'object' ]); |
|
130 | + if (isset($row['object'])) { |
|
131 | + return $this->decode($row['object']); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | return null; |
@@ -271,12 +271,12 @@ discard block |
||
271 | 271 | $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`"); |
272 | 272 | $stm->execute(); |
273 | 273 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
274 | - if (!isset($row[ 'db' ])) { |
|
274 | + if (!isset($row['db'])) { |
|
275 | 275 | $db = 1; |
276 | - } elseif ($row[ 'db' ] <= 1) { |
|
276 | + } elseif ($row['db'] <= 1) { |
|
277 | 277 | $db = 1; |
278 | 278 | } else { |
279 | - $db = $row[ 'db' ]; |
|
279 | + $db = $row['db']; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // check file size |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | ':keyword' => $keyword, |
299 | 299 | ]); |
300 | 300 | $row = $stm->fetch(PDO::FETCH_ASSOC); |
301 | - if (isset($row[ 'db' ]) && $row[ 'db' ] != '') { |
|
302 | - $db = $row[ 'db' ]; |
|
301 | + if (isset($row['db']) && $row['db'] != '') { |
|
302 | + $db = $row['db']; |
|
303 | 303 | } else { |
304 | 304 | /* |
305 | 305 | * Insert new to Indexing |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | /** |
331 | 331 | * init instant |
332 | 332 | */ |
333 | - if (!isset($this->instance[ $instant ])) { |
|
333 | + if (!isset($this->instance[$instant])) { |
|
334 | 334 | // check DB Files ready or not |
335 | 335 | $createTable = false; |
336 | 336 | if (!\file_exists($this->SqliteDir . '/db' . $instant) || $reset == true) { |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | $this->initDB($PDO); |
344 | 344 | } |
345 | 345 | |
346 | - $this->instance[ $instant ] = $PDO; |
|
346 | + $this->instance[$instant] = $PDO; |
|
347 | 347 | unset($PDO); |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - return $this->instance[ $instant ]; |
|
351 | + return $this->instance[$instant]; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | use LogicException; |
20 | 20 | use MongoDB\{ |
21 | - Client, Database, BSON\Binary, BSON\UTCDateTime, Collection, DeleteResult, Driver\Command, Driver\Exception\Exception as MongoDBException |
|
21 | + Client, Database, BSON\Binary, BSON\UTCDateTime, Collection, DeleteResult, Driver\Command, Driver\Exception\Exception as MongoDBException |
|
22 | 22 | }; |
23 | 23 | use Phpfastcache\Core\Pool\{ |
24 | - DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
24 | + DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
25 | 25 | }; |
26 | 26 | use Phpfastcache\Entities\DriverStatistic; |
27 | 27 | use Phpfastcache\Exceptions\{ |
28 | - PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException |
|
28 | + PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException |
|
29 | 29 | }; |
30 | 30 | |
31 | 31 | use Psr\Cache\CacheItemInterface; |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | |
79 | 79 | if ($document) { |
80 | 80 | $return = [ |
81 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
82 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
83 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
81 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
82 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
83 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
84 | 84 | ]; |
85 | 85 | |
86 | 86 | if(!empty($this->getConfig()->isItemDetailedDate())){ |
87 | 87 | $return += [ |
88 | - self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime() |
|
88 | + self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime() |
|
89 | 89 | ->getTimestamp()), |
90 | - self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime() |
|
90 | + self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime() |
|
91 | 91 | ->getTimestamp()), |
92 | 92 | ]; |
93 | 93 | } |
@@ -112,23 +112,23 @@ discard block |
||
112 | 112 | if ($item instanceof Item) { |
113 | 113 | try { |
114 | 114 | $set = [ |
115 | - self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
116 | - self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
117 | - self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((\time() + $item->getTtl()) * 1000) : new UTCDateTime(\time() * 1000)), |
|
115 | + self::DRIVER_DATA_WRAPPER_INDEX => new Binary($this->encode($item->get()), Binary::TYPE_GENERIC), |
|
116 | + self::DRIVER_TAGS_WRAPPER_INDEX => new Binary($this->encode($item->getTags()), Binary::TYPE_GENERIC), |
|
117 | + self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((\time() + $item->getTtl()) * 1000) : new UTCDateTime(\time() * 1000)), |
|
118 | 118 | ]; |
119 | 119 | |
120 | 120 | if(!empty($this->getConfig()->isItemDetailedDate())){ |
121 | 121 | $set += [ |
122 | - self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
|
123 | - self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
|
122 | + self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
|
123 | + self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
|
124 | 124 | ]; |
125 | 125 | } |
126 | 126 | $result = (array)$this->getCollection()->updateOne( |
127 | - ['_id' => $item->getEncodedKey()], |
|
128 | - [ |
|
127 | + ['_id' => $item->getEncodedKey()], |
|
128 | + [ |
|
129 | 129 | '$set' => $set, |
130 | - ], |
|
131 | - ['upsert' => true, 'multiple' => false] |
|
130 | + ], |
|
131 | + ['upsert' => true, 'multiple' => false] |
|
132 | 132 | ); |
133 | 133 | } catch (MongoDBException $e) { |
134 | 134 | throw new PhpfastcacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
@@ -229,13 +229,13 @@ discard block |
||
229 | 229 | $password = $this->getConfig()->getPassword(); |
230 | 230 | |
231 | 231 | return implode('', [ |
232 | - 'mongodb://', |
|
233 | - ($username ?: ''), |
|
234 | - ($password ? ":{$password}" : ''), |
|
235 | - ($username ? '@' : ''), |
|
236 | - $host, |
|
237 | - ($port !== 27017 ? ":{$port}" : ''), |
|
238 | - ($databaseName ? "/{$databaseName}" : '') |
|
232 | + 'mongodb://', |
|
233 | + ($username ?: ''), |
|
234 | + ($password ? ":{$password}" : ''), |
|
235 | + ($username ? '@' : ''), |
|
236 | + $host, |
|
237 | + ($port !== 27017 ? ":{$port}" : ''), |
|
238 | + ($databaseName ? "/{$databaseName}" : '') |
|
239 | 239 | ]); |
240 | 240 | } |
241 | 241 | |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | public function getStats(): DriverStatistic |
260 | 260 | { |
261 | 261 | $serverStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([ |
262 | - 'serverStatus' => 1, |
|
263 | - 'recordStats' => 0, |
|
264 | - 'repl' => 0, |
|
265 | - 'metrics' => 0, |
|
262 | + 'serverStatus' => 1, |
|
263 | + 'recordStats' => 0, |
|
264 | + 'repl' => 0, |
|
265 | + 'metrics' => 0, |
|
266 | 266 | ]))->toArray()[ 0 ]; |
267 | 267 | |
268 | 268 | $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([ |
269 | - 'collStats' => (isset($this->getConfig()[ 'collectionName' ]) ? $this->getConfig()[ 'collectionName' ] : 'Cache'), |
|
270 | - 'verbose' => true, |
|
269 | + 'collStats' => (isset($this->getConfig()[ 'collectionName' ]) ? $this->getConfig()[ 'collectionName' ] : 'Cache'), |
|
270 | + 'verbose' => true, |
|
271 | 271 | ]))->toArray()[ 0 ]; |
272 | 272 | |
273 | 273 | $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | $collectionStats = $array_filter_recursive($collectionStats, $callback); |
297 | 297 | |
298 | 298 | $stats = (new DriverStatistic()) |
299 | - ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . \round($serverStats->uptime / 86400, |
|
300 | - 1) . "\n For more information see RawData.") |
|
301 | - ->setSize($collectionStats->size) |
|
302 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
303 | - ->setRawData([ |
|
299 | + ->setInfo('MongoDB version ' . $serverStats->version . ', Uptime (in days): ' . \round($serverStats->uptime / 86400, |
|
300 | + 1) . "\n For more information see RawData.") |
|
301 | + ->setSize($collectionStats->size) |
|
302 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
303 | + ->setRawData([ |
|
304 | 304 | 'serverStatus' => $serverStats, |
305 | 305 | 'collStats' => $collectionStats, |
306 | - ]); |
|
306 | + ]); |
|
307 | 307 | |
308 | 308 | return $stats; |
309 | 309 | } |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | |
79 | 79 | if ($document) { |
80 | 80 | $return = [ |
81 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
82 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
83 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
81 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
82 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
83 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
84 | 84 | ]; |
85 | 85 | |
86 | - if(!empty($this->getConfig()->isItemDetailedDate())){ |
|
86 | + if (!empty($this->getConfig()->isItemDetailedDate())) { |
|
87 | 87 | $return += [ |
88 | - self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime() |
|
88 | + self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime() |
|
89 | 89 | ->getTimestamp()), |
90 | - self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime() |
|
90 | + self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime() |
|
91 | 91 | ->getTimestamp()), |
92 | 92 | ]; |
93 | 93 | } |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((\time() + $item->getTtl()) * 1000) : new UTCDateTime(\time() * 1000)), |
118 | 118 | ]; |
119 | 119 | |
120 | - if(!empty($this->getConfig()->isItemDetailedDate())){ |
|
120 | + if (!empty($this->getConfig()->isItemDetailedDate())) { |
|
121 | 121 | $set += [ |
122 | 122 | self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
123 | 123 | self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
124 | 124 | ]; |
125 | 125 | } |
126 | - $result = (array)$this->getCollection()->updateOne( |
|
126 | + $result = (array) $this->getCollection()->updateOne( |
|
127 | 127 | ['_id' => $item->getEncodedKey()], |
128 | 128 | [ |
129 | 129 | '$set' => $set, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | throw new PhpfastcacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
135 | 135 | } |
136 | 136 | |
137 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
137 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $host = $this->getConfig()->getHost(); |
227 | 227 | $port = $this->getConfig()->getPort(); |
228 | 228 | $username = $this->getConfig()->getUsername(); |
229 | - $password = $this->getConfig()->getPassword(); |
|
229 | + $password = $this->getConfig()->getPassword(); |
|
230 | 230 | |
231 | 231 | return implode('', [ |
232 | 232 | 'mongodb://', |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | 'recordStats' => 0, |
264 | 264 | 'repl' => 0, |
265 | 265 | 'metrics' => 0, |
266 | - ]))->toArray()[ 0 ]; |
|
266 | + ]))->toArray()[0]; |
|
267 | 267 | |
268 | 268 | $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([ |
269 | - 'collStats' => (isset($this->getConfig()[ 'collectionName' ]) ? $this->getConfig()[ 'collectionName' ] : 'Cache'), |
|
269 | + 'collStats' => (isset($this->getConfig()['collectionName']) ? $this->getConfig()['collectionName'] : 'Cache'), |
|
270 | 270 | 'verbose' => true, |
271 | - ]))->toArray()[ 0 ]; |
|
271 | + ]))->toArray()[0]; |
|
272 | 272 | |
273 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
273 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
274 | 274 | $array = $callback($array); |
275 | 275 | |
276 | 276 | if (\is_object($array) || \is_array($array)) { |
@@ -282,12 +282,12 @@ discard block |
||
282 | 282 | return $array; |
283 | 283 | }; |
284 | 284 | |
285 | - $callback = function ($item) { |
|
285 | + $callback = function($item) { |
|
286 | 286 | /** |
287 | 287 | * Remove unserializable properties |
288 | 288 | */ |
289 | 289 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
290 | - return (string)$item; |
|
290 | + return (string) $item; |
|
291 | 291 | } |
292 | 292 | return $item; |
293 | 293 | }; |
@@ -9,7 +9,7 @@ |
||
9 | 9 | namespace Phpfastcache\Drivers\Sqlite; |
10 | 10 | |
11 | 11 | use Phpfastcache\Config\{ |
12 | - ConfigurationOption, IOConfigurationOptionTrait |
|
12 | + ConfigurationOption, IOConfigurationOptionTrait |
|
13 | 13 | }; |
14 | 14 | |
15 | 15 | class Config extends ConfigurationOption |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
21 | 21 | use Phpfastcache\Entities\DriverStatistic; |
22 | 22 | use Phpfastcache\Exceptions\{ |
23 | - PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
23 | + PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
24 | 24 | }; |
25 | 25 | use Phpfastcache\Util\ArrayObject; |
26 | 26 | use Psr\Cache\CacheItemInterface; |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | $clientConfig = $this->getConfig(); |
62 | 62 | |
63 | 63 | $clusterBuilder = Cassandra::cluster() |
64 | - ->withContactPoints($clientConfig->getHost()) |
|
65 | - ->withPort($clientConfig->getPort()); |
|
64 | + ->withContactPoints($clientConfig->getHost()) |
|
65 | + ->withPort($clientConfig->getPort()); |
|
66 | 66 | |
67 | 67 | if (!empty($clientConfig->isSslEnabled())) { |
68 | 68 | if (!empty($clientConfig->isSslVerify())) { |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | */ |
91 | 91 | |
92 | 92 | $this->instance->execute(new Cassandra\SimpleStatement(\sprintf( |
93 | - "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", |
|
94 | - self::CASSANDRA_KEY_SPACE |
|
93 | + "CREATE KEYSPACE IF NOT EXISTS %s WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", |
|
94 | + self::CASSANDRA_KEY_SPACE |
|
95 | 95 | ))); |
96 | 96 | $this->instance->execute(new Cassandra\SimpleStatement(\sprintf('USE %s;', self::CASSANDRA_KEY_SPACE))); |
97 | 97 | $this->instance->execute(new Cassandra\SimpleStatement(\sprintf(' |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | { |
118 | 118 | try { |
119 | 119 | $options = new Cassandra\ExecutionOptions([ |
120 | - 'arguments' => ['cache_id' => $item->getKey()], |
|
121 | - 'page_size' => 1, |
|
120 | + 'arguments' => ['cache_id' => $item->getKey()], |
|
121 | + 'page_size' => 1, |
|
122 | 122 | ]); |
123 | 123 | $query =\sprintf( |
124 | - 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', |
|
125 | - self::CASSANDRA_KEY_SPACE, |
|
126 | - self::CASSANDRA_TABLE |
|
124 | + 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', |
|
125 | + self::CASSANDRA_KEY_SPACE, |
|
126 | + self::CASSANDRA_TABLE |
|
127 | 127 | ); |
128 | 128 | $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); |
129 | 129 | |
@@ -151,16 +151,16 @@ discard block |
||
151 | 151 | try { |
152 | 152 | $cacheData = $this->encode($this->driverPreWrap($item)); |
153 | 153 | $options = new Cassandra\ExecutionOptions([ |
154 | - 'arguments' => [ |
|
154 | + 'arguments' => [ |
|
155 | 155 | 'cache_uuid' => new Cassandra\Uuid(), |
156 | 156 | 'cache_id' => $item->getKey(), |
157 | 157 | 'cache_data' => $cacheData, |
158 | 158 | 'cache_creation_date' => new Cassandra\Timestamp((new \DateTime())->getTimestamp()), |
159 | 159 | 'cache_expiration_date' => new Cassandra\Timestamp($item->getExpirationDate()->getTimestamp()), |
160 | 160 | 'cache_length' => strlen($cacheData), |
161 | - ], |
|
162 | - 'consistency' => Cassandra::CONSISTENCY_ALL, |
|
163 | - 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL, |
|
161 | + ], |
|
162 | + 'consistency' => Cassandra::CONSISTENCY_ALL, |
|
163 | + 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL, |
|
164 | 164 | ]); |
165 | 165 | |
166 | 166 | $query =\sprintf('INSERT INTO %s.%s |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | if ($item instanceof Item) { |
204 | 204 | try { |
205 | 205 | $options = new Cassandra\ExecutionOptions([ |
206 | - 'arguments' => [ |
|
206 | + 'arguments' => [ |
|
207 | 207 | 'cache_id' => $item->getKey(), |
208 | - ], |
|
208 | + ], |
|
209 | 209 | ]); |
210 | 210 | $result = $this->instance->execute(new Cassandra\SimpleStatement(\sprintf( |
211 | - 'DELETE FROM %s.%s WHERE cache_id = :cache_id;', |
|
212 | - self::CASSANDRA_KEY_SPACE, |
|
213 | - self::CASSANDRA_TABLE |
|
211 | + 'DELETE FROM %s.%s WHERE cache_id = :cache_id;', |
|
212 | + self::CASSANDRA_KEY_SPACE, |
|
213 | + self::CASSANDRA_TABLE |
|
214 | 214 | )), $options); |
215 | 215 | |
216 | 216 | /** |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | { |
235 | 235 | try { |
236 | 236 | $this->instance->execute(new Cassandra\SimpleStatement(\sprintf( |
237 | - 'TRUNCATE %s.%s;', |
|
238 | - self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE |
|
237 | + 'TRUNCATE %s.%s;', |
|
238 | + self::CASSANDRA_KEY_SPACE, self::CASSANDRA_TABLE |
|
239 | 239 | ))); |
240 | 240 | |
241 | 241 | return true; |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | public function getStats(): DriverStatistic |
273 | 273 | { |
274 | 274 | $result = $this->instance->execute(new Cassandra\SimpleStatement(\sprintf( |
275 | - 'SELECT SUM(cache_length) as cache_size FROM %s.%s', |
|
276 | - self::CASSANDRA_KEY_SPACE, |
|
277 | - self::CASSANDRA_TABLE |
|
275 | + 'SELECT SUM(cache_length) as cache_size FROM %s.%s', |
|
276 | + self::CASSANDRA_KEY_SPACE, |
|
277 | + self::CASSANDRA_TABLE |
|
278 | 278 | ))); |
279 | 279 | |
280 | 280 | return (new DriverStatistic()) |
281 | - ->setSize($result->first()[ 'cache_size' ]) |
|
282 | - ->setRawData([]) |
|
283 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
284 | - ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
|
281 | + ->setSize($result->first()[ 'cache_size' ]) |
|
282 | + ->setRawData([]) |
|
283 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
284 | + ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | \ No newline at end of file |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | 'arguments' => ['cache_id' => $item->getKey()], |
121 | 121 | 'page_size' => 1, |
122 | 122 | ]); |
123 | - $query =\sprintf( |
|
123 | + $query = \sprintf( |
|
124 | 124 | 'SELECT cache_data FROM %s.%s WHERE cache_id = :cache_id;', |
125 | 125 | self::CASSANDRA_KEY_SPACE, |
126 | 126 | self::CASSANDRA_TABLE |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $results = $this->instance->execute(new Cassandra\SimpleStatement($query), $options); |
129 | 129 | |
130 | 130 | if ($results instanceof Cassandra\Rows && $results->count() === 1) { |
131 | - return $this->decode($results->first()[ 'cache_data' ]); |
|
131 | + return $this->decode($results->first()['cache_data']); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | return null; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | 'serial_consistency' => Cassandra::CONSISTENCY_SERIAL, |
164 | 164 | ]); |
165 | 165 | |
166 | - $query =\sprintf('INSERT INTO %s.%s |
|
166 | + $query = \sprintf('INSERT INTO %s.%s |
|
167 | 167 | ( |
168 | 168 | cache_uuid, |
169 | 169 | cache_id, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | ))); |
279 | 279 | |
280 | 280 | return (new DriverStatistic()) |
281 | - ->setSize($result->first()[ 'cache_size' ]) |
|
281 | + ->setSize($result->first()['cache_size']) |
|
282 | 282 | ->setRawData([]) |
283 | 283 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
284 | 284 | ->setInfo('The cache size represents only the cache data itself without counting data structures associated to the cache entries.'); |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | namespace Phpfastcache\Drivers\Couchdb; |
17 | 17 | |
18 | 18 | use Doctrine\CouchDB\{ |
19 | - CouchDBClient as CouchdbClient, CouchDBException |
|
19 | + CouchDBClient as CouchdbClient, CouchDBException |
|
20 | 20 | }; |
21 | 21 | use Phpfastcache\Config\ConfigurationOption; |
22 | 22 | use Phpfastcache\Core\Pool\{ |
23 | - DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
23 | + DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
24 | 24 | }; |
25 | 25 | use Phpfastcache\Exceptions\{ |
26 | - PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
26 | + PhpfastcacheDriverException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
27 | 27 | }; |
28 | 28 | use Phpfastcache\Entities\DriverStatistic; |
29 | 29 | use Phpfastcache\Util\ArrayObject; |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | $url .= $clientConfig->getPath(); |
76 | 76 | |
77 | 77 | $this->instance = CouchDBClient::create([ |
78 | - 'dbname' => $this->getDatabaseName(), |
|
79 | - 'url' => $url, |
|
80 | - 'timeout' => $clientConfig->getTimeout(), |
|
78 | + 'dbname' => $this->getDatabaseName(), |
|
79 | + 'url' => $url, |
|
80 | + 'timeout' => $clientConfig->getTimeout(), |
|
81 | 81 | ]); |
82 | 82 | |
83 | 83 | $this->createDatabase(); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | if ($item instanceof Item) { |
125 | 125 | try { |
126 | 126 | $this->instance->putDocument(['data' => $this->encode($this->driverPreWrap($item))], $item->getEncodedKey(), |
127 | - $this->getLatestDocumentRevision($item->getEncodedKey())); |
|
127 | + $this->getLatestDocumentRevision($item->getEncodedKey())); |
|
128 | 128 | } catch (CouchDBException $e) { |
129 | 129 | throw new PhpfastcacheDriverException('Got error while trying to upsert a document: ' . $e->getMessage(), null, $e); |
130 | 130 | } |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | $path = '/' . $this->getDatabaseName() . '/' . urlencode($docId); |
182 | 182 | |
183 | 183 | $response = $this->instance->getHttpClient()->request( |
184 | - 'HEAD', |
|
185 | - $path, |
|
186 | - null, |
|
187 | - false |
|
184 | + 'HEAD', |
|
185 | + $path, |
|
186 | + null, |
|
187 | + false |
|
188 | 188 | ); |
189 | 189 | if (!empty($response->headers[ 'etag' ])) { |
190 | 190 | return \trim($response->headers[ 'etag' ], " '\"\t\n\r\0\x0B"); |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | $info = $this->instance->getDatabaseInfo(); |
239 | 239 | |
240 | 240 | return (new DriverStatistic()) |
241 | - ->setSize($info[ 'sizes' ][ 'active' ]) |
|
242 | - ->setRawData($info) |
|
243 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
244 | - ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
241 | + ->setSize($info[ 'sizes' ][ 'active' ]) |
|
242 | + ->setRawData($info) |
|
243 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
244 | + ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | \ No newline at end of file |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | throw new PhpfastcacheDriverException('Got error while trying to get a document: ' . $e->getMessage(), null, $e); |
99 | 99 | } |
100 | 100 | |
101 | - if ($response->status === 404 || empty($response->body[ 'data' ])) { |
|
101 | + if ($response->status === 404 || empty($response->body['data'])) { |
|
102 | 102 | return null; |
103 | 103 | } |
104 | 104 | |
105 | 105 | if ($response->status === 200) { |
106 | - return $this->decode($response->body[ 'data' ]); |
|
106 | + return $this->decode($response->body['data']); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | throw new PhpfastcacheDriverException('Got unexpected HTTP status: ' . $response->status); |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | null, |
187 | 187 | false |
188 | 188 | ); |
189 | - if (!empty($response->headers[ 'etag' ])) { |
|
190 | - return \trim($response->headers[ 'etag' ], " '\"\t\n\r\0\x0B"); |
|
189 | + if (!empty($response->headers['etag'])) { |
|
190 | + return \trim($response->headers['etag'], " '\"\t\n\r\0\x0B"); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | return null; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $info = $this->instance->getDatabaseInfo(); |
239 | 239 | |
240 | 240 | return (new DriverStatistic()) |
241 | - ->setSize($info[ 'sizes' ][ 'active' ]) |
|
241 | + ->setSize($info['sizes']['active']) |
|
242 | 242 | ->setRawData($info) |
243 | 243 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
244 | 244 | ->setInfo('Couchdb version ' . $this->instance->getVersion() . "\n For more information see RawData."); |