@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
12 | 12 | * |
13 | 13 | */ |
14 | -declare(strict_types=1); |
|
14 | +declare(strict_types = 1); |
|
15 | 15 | |
16 | 16 | namespace Phpfastcache\Core\Pool; |
17 | 17 | |
@@ -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->getConfigOption('cacheSlamsTimeout') < \time()) { |
100 | 100 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $item->set($driverData); |
129 | 129 | $item->expiresAt($this->driverUnwrapEdate($driverArray)); |
130 | 130 | |
131 | - if ($this->getConfigOption( 'itemDetailedDate')) { |
|
131 | + if ($this->getConfigOption('itemDetailedDate')) { |
|
132 | 132 | /** |
133 | 133 | * If the itemDetailedDate has been |
134 | 134 | * set after caching, we MUST inject |
@@ -155,10 +155,10 @@ 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 | - if ($this->getConfigOption( 'itemDetailedDate')) { |
|
161 | + if ($this->getConfigOption('itemDetailedDate')) { |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * If the itemDetailedDate has been |
@@ -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 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
12 | 12 | * |
13 | 13 | */ |
14 | -declare(strict_types=1); |
|
14 | +declare(strict_types = 1); |
|
15 | 15 | |
16 | 16 | namespace Phpfastcache\Core\Pool; |
17 | 17 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512): string |
38 | 38 | { |
39 | - $callback = function (CacheItemInterface $item) { |
|
39 | + $callback = function(CacheItemInterface $item) { |
|
40 | 40 | return $item->get(); |
41 | 41 | }; |
42 | 42 | return \json_encode(\array_map($callback, \array_values($this->getItems($keys))), $option, $depth); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | if (\is_string($tagName)) { |
51 | 51 | $driverResponse = $this->getItem($this->getTagKey($tagName)); |
52 | 52 | if ($driverResponse->isHit()) { |
53 | - $items = (array)$driverResponse->get(); |
|
53 | + $items = (array) $driverResponse->get(); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * getItems() may provides expired item(s) |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * #headache |
64 | 64 | */ |
65 | - return \array_filter($this->getItems(\array_unique(\array_keys($items))), function (ExtendedCacheItemInterface $item) { |
|
65 | + return \array_filter($this->getItems(\array_unique(\array_keys($items))), function(ExtendedCacheItemInterface $item) { |
|
66 | 66 | return $item->isHit(); |
67 | 67 | }); |
68 | 68 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | foreach ($items as $key => $item) { |
101 | 101 | if (\array_diff($tagNames, $item->getTags())) { |
102 | - unset($items[ $key ]); |
|
102 | + unset($items[$key]); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function getItemsByTagsAsJsonString(array $tagNames, $option = 0, $depth = 512) |
114 | 114 | { |
115 | - $callback = function (CacheItemInterface $item) { |
|
115 | + $callback = function(CacheItemInterface $item) { |
|
116 | 116 | return $item->get(); |
117 | 117 | }; |
118 | 118 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | */ |
384 | 384 | public function detachItem(CacheItemInterface $item) |
385 | 385 | { |
386 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
386 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
387 | 387 | $this->deregisterItem($item); |
388 | 388 | } |
389 | 389 | } |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | */ |
404 | 404 | public function attachItem(CacheItemInterface $item) |
405 | 405 | { |
406 | - if (isset($this->itemInstances[ $item->getKey() ]) && \spl_object_hash($item) !== \spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
406 | + if (isset($this->itemInstances[$item->getKey()]) && \spl_object_hash($item) !== \spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
407 | 407 | throw new PhpfastcacheLogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.'); |
408 | 408 | } |
409 | 409 | |
410 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
410 | + $this->itemInstances[$item->getKey()] = $item; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | protected function deregisterItem($item) |
420 | 420 | { |
421 | 421 | if ($item instanceof CacheItemInterface) { |
422 | - unset($this->itemInstances[ $item->getKey() ]); |
|
422 | + unset($this->itemInstances[$item->getKey()]); |
|
423 | 423 | |
424 | 424 | } else if (\is_string($item)) { |
425 | - unset($this->itemInstances[ $item ]); |
|
425 | + unset($this->itemInstances[$item]); |
|
426 | 426 | } else { |
427 | 427 | throw new PhpfastcacheInvalidArgumentException('Invalid type for $item variable'); |
428 | 428 | } |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public function isAttached(CacheItemInterface $item) |
451 | 451 | { |
452 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
453 | - return \spl_object_hash($item) === \spl_object_hash($this->itemInstances[ $item->getKey() ]); |
|
452 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
453 | + return \spl_object_hash($item) === \spl_object_hash($this->itemInstances[$item->getKey()]); |
|
454 | 454 | } |
455 | 455 | return null; |
456 | 456 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | */ |
474 | 474 | public function saveMultiple(...$items): bool |
475 | 475 | { |
476 | - if (isset($items[ 0 ]) && \is_array($items[ 0 ])) { |
|
477 | - foreach ($items[ 0 ] as $item) { |
|
476 | + if (isset($items[0]) && \is_array($items[0])) { |
|
477 | + foreach ($items[0] as $item) { |
|
478 | 478 | $this->save($item); |
479 | 479 | } |
480 | 480 | return true; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
12 | 12 | * |
13 | 13 | */ |
14 | -declare(strict_types=1); |
|
14 | +declare(strict_types = 1); |
|
15 | 15 | |
16 | 16 | namespace Phpfastcache\Util; |
17 | 17 | |
@@ -87,8 +87,7 @@ discard block |
||
87 | 87 | return \unlink($source); |
88 | 88 | } |
89 | 89 | |
90 | - $files = new RecursiveIteratorIterator |
|
91 | - ( |
|
90 | + $files = new RecursiveIteratorIterator( |
|
92 | 91 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
93 | 92 | RecursiveIteratorIterator::CHILD_FIRST |
94 | 93 | ); |
@@ -138,8 +137,8 @@ discard block |
||
138 | 137 | /** |
139 | 138 | * Allows to dereference char |
140 | 139 | */ |
141 | - $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc. |
|
142 | - $prefix = $__FILE__[ 0 ] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
|
140 | + $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc. |
|
141 | + $prefix = $__FILE__[0] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
|
143 | 142 | return $prefix . \implode(DIRECTORY_SEPARATOR, $absolutes); |
144 | 143 | } |
145 | 144 | } |
146 | 145 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
12 | 12 | * |
13 | 13 | */ |
14 | -declare(strict_types=1); |
|
14 | +declare(strict_types = 1); |
|
15 | 15 | |
16 | 16 | namespace Phpfastcache\Util; |
17 | 17 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | $map = []; |
57 | 57 | |
58 | - if(\is_array($dir) || $dir instanceof \Traversable){ |
|
58 | + if (\is_array($dir) || $dir instanceof \Traversable) { |
|
59 | 59 | foreach ($dir as $file) { |
60 | 60 | if (!$file->isFile()) { |
61 | 61 | continue; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | \gc_mem_caches(); |
71 | 71 | } |
72 | 72 | foreach ($classes as $class) { |
73 | - $map[ $class ] = $path; |
|
73 | + $map[$class] = $path; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | } |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | $tokens = \token_get_all($contents); |
95 | 95 | $classes = []; |
96 | 96 | $namespace = ''; |
97 | - for ($i = 0; isset($tokens[ $i ]); ++$i) { |
|
98 | - $token = $tokens[ $i ]; |
|
99 | - if (!isset($token[ 1 ])) { |
|
97 | + for ($i = 0; isset($tokens[$i]); ++$i) { |
|
98 | + $token = $tokens[$i]; |
|
99 | + if (!isset($token[1])) { |
|
100 | 100 | continue; |
101 | 101 | } |
102 | 102 | $class = ''; |
103 | - switch ($token[ 0 ]) { |
|
103 | + switch ($token[0]) { |
|
104 | 104 | case T_NAMESPACE: |
105 | 105 | $namespace = ''; |
106 | 106 | // If there is a namespace, extract it |
107 | - while (isset($tokens[ ++$i ][ 1 ])) { |
|
108 | - if (\in_array($tokens[ $i ][ 0 ], [T_STRING, T_NS_SEPARATOR])) { |
|
109 | - $namespace .= $tokens[ $i ][ 1 ]; |
|
107 | + while (isset($tokens[ ++$i][1])) { |
|
108 | + if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR])) { |
|
109 | + $namespace .= $tokens[$i][1]; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $namespace .= '\\'; |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | // Skip usage of ::class constant |
118 | 118 | $isClassConstant = false; |
119 | 119 | for ($j = $i - 1; $j > 0; --$j) { |
120 | - if (!isset($tokens[ $j ][ 1 ])) { |
|
120 | + if (!isset($tokens[$j][1])) { |
|
121 | 121 | break; |
122 | 122 | } |
123 | - if (T_DOUBLE_COLON === $tokens[ $j ][ 0 ]) { |
|
123 | + if (T_DOUBLE_COLON === $tokens[$j][0]) { |
|
124 | 124 | $isClassConstant = true; |
125 | 125 | break; |
126 | - } elseif (!\in_array($tokens[ $j ][ 0 ], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT], false)) { |
|
126 | + } elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT], false)) { |
|
127 | 127 | break; |
128 | 128 | } |
129 | 129 | } |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | break; |
132 | 132 | } |
133 | 133 | // Find the classname |
134 | - while (isset($tokens[ ++$i ][ 1 ])) { |
|
135 | - $t = $tokens[ $i ]; |
|
136 | - if (T_STRING === $t[ 0 ]) { |
|
137 | - $class .= $t[ 1 ]; |
|
138 | - } elseif ('' !== $class && T_WHITESPACE === $t[ 0 ]) { |
|
134 | + while (isset($tokens[ ++$i][1])) { |
|
135 | + $t = $tokens[$i]; |
|
136 | + if (T_STRING === $t[0]) { |
|
137 | + $class .= $t[1]; |
|
138 | + } elseif ('' !== $class && T_WHITESPACE === $t[0]) { |
|
139 | 139 | break; |
140 | 140 | } |
141 | 141 | } |
@@ -92,33 +92,33 @@ discard block |
||
92 | 92 | public function __construct(...$args) |
93 | 93 | { |
94 | 94 | parent::__construct(...$args); |
95 | - $array =& $this->getArray(); |
|
95 | + $array = & $this->getArray(); |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Detect unwanted keys and throw an exception. |
99 | 99 | * No more kidding now, it's 21th century. |
100 | 100 | */ |
101 | - if(array_diff_key($array, get_object_vars($this))){ |
|
101 | + if (array_diff_key($array, get_object_vars($this))) { |
|
102 | 102 | throw new PhpfastcacheInvalidConfigurationException(\sprintf( |
103 | 103 | 'Invalid option(s) for the config %s: %s', |
104 | 104 | static::class, |
105 | - implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
105 | + implode(', ', array_keys(array_diff_key($array, get_object_vars($this)))) |
|
106 | 106 | )); |
107 | 107 | } |
108 | 108 | |
109 | 109 | foreach (get_object_vars($this) as $property => $value) { |
110 | 110 | |
111 | - if(array_key_exists($property, $array)){ |
|
112 | - $this->$property = &$array[ $property ]; |
|
113 | - }else{ |
|
114 | - $array[ $property ] = &$this->$property; |
|
111 | + if (array_key_exists($property, $array)) { |
|
112 | + $this->$property = &$array[$property]; |
|
113 | + } else { |
|
114 | + $array[$property] = &$this->$property; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | foreach (get_class_methods($this) as $method) { |
119 | - if(strpos($method, 'set') === 0){ |
|
119 | + if (strpos($method, 'set') === 0) { |
|
120 | 120 | $value = null; |
121 | - try{ |
|
121 | + try { |
|
122 | 122 | /** |
123 | 123 | * We use property instead of getter |
124 | 124 | * because of is/get conditions and |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | $value = $this->{lcfirst(substr($method, 3))}; |
129 | 129 | $this->{$method}($value); |
130 | - }catch(\TypeError $e){ |
|
130 | + } catch (\TypeError $e) { |
|
131 | 131 | $typeHintGot = \is_object($value) ? \get_class($value) : \gettype($value); |
132 | 132 | $reflectionMethod = new \ReflectionMethod($this, $method); |
133 | 133 | $parameter = $reflectionMethod->getParameters()[0] ?? null; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function setIgnoreSymfonyNotice(bool $ignoreSymfonyNotice): self |
216 | 216 | { |
217 | - if($ignoreSymfonyNotice){ |
|
217 | + if ($ignoreSymfonyNotice) { |
|
218 | 218 | trigger_error('Configuration option "ignoreSymfonyNotice" is deprecated as of the V7', E_USER_DEPRECATED); |
219 | 219 | } |
220 | 220 | $this->ignoreSymfonyNotice = $ignoreSymfonyNotice; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function setFallbackConfig($fallbackConfig): self |
331 | 331 | { |
332 | - if($fallbackConfig !== null && !($fallbackConfig instanceof self)){ |
|
332 | + if ($fallbackConfig !== null && !($fallbackConfig instanceof self)) { |
|
333 | 333 | throw new PhpfastcacheInvalidArgumentException(\sprintf( |
334 | 334 | 'Invalid argument "%s" for %s', |
335 | 335 | gettype($fallbackConfig) === 'object' ? get_class($fallbackConfig) : gettype($fallbackConfig), |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @author Fabio Covolo Mazzo (fabiocmazzo) <[email protected]> |
13 | 13 | * |
14 | 14 | */ |
15 | -declare(strict_types=1); |
|
15 | +declare(strict_types = 1); |
|
16 | 16 | |
17 | 17 | namespace Phpfastcache\Drivers\Mongodb; |
18 | 18 | |
@@ -71,16 +71,16 @@ discard block |
||
71 | 71 | |
72 | 72 | if ($document) { |
73 | 73 | $return = [ |
74 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
75 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
76 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
74 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
75 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
76 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
77 | 77 | ]; |
78 | 78 | |
79 | - if(!empty($this->getConfigOption('itemDetailedDate'))){ |
|
79 | + if (!empty($this->getConfigOption('itemDetailedDate'))) { |
|
80 | 80 | $return += [ |
81 | - self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime() |
|
81 | + self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime() |
|
82 | 82 | ->getTimestamp()), |
83 | - self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime() |
|
83 | + self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime() |
|
84 | 84 | ->getTimestamp()), |
85 | 85 | ]; |
86 | 86 | } |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((\time() + $item->getTtl()) * 1000) : new UTCDateTime(\time() * 1000)), |
111 | 111 | ]; |
112 | 112 | |
113 | - if(!empty($this->getConfigOption('itemDetailedDate'))){ |
|
113 | + if (!empty($this->getConfigOption('itemDetailedDate'))) { |
|
114 | 114 | $set += [ |
115 | 115 | self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
116 | 116 | self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
117 | 117 | ]; |
118 | 118 | } |
119 | - $result = (array)$this->getCollection()->updateOne( |
|
119 | + $result = (array) $this->getCollection()->updateOne( |
|
120 | 120 | ['_id' => $item->getEncodedKey()], |
121 | 121 | [ |
122 | 122 | '$set' => $set, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | throw new PhpfastcacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
128 | 128 | } |
129 | 129 | |
130 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
130 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | $this->save($this->getItem('__PFC_CACHE_CLEARED__')->set(true)); |
173 | 173 | |
174 | - return !empty($result[ 'ok' ]); |
|
174 | + return !empty($result['ok']); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | * @todo make an url builder |
192 | 192 | */ |
193 | 193 | $this->instance = $this->instance ?: (new MongodbManager('mongodb://' . |
194 | - ($clientConfig[ 'username' ] ?: '') . |
|
195 | - ($clientConfig[ 'password' ] ? ":{$clientConfig['password']}" : '') . |
|
196 | - ($clientConfig[ 'username' ] ? '@' : '') . "{$clientConfig['host']}" . |
|
197 | - ($clientConfig[ 'port' ] != 27017 ? ":{$clientConfig['port']}" : ''), ['connectTimeoutMS' => $clientConfig[ 'timeout' ] * 1000])); |
|
198 | - $this->collection = $this->collection ?: new Collection($this->instance, $clientConfig[ 'databaseName' ], $clientConfig[ 'collectionName' ]); |
|
194 | + ($clientConfig['username'] ?: '') . |
|
195 | + ($clientConfig['password'] ? ":{$clientConfig['password']}" : '') . |
|
196 | + ($clientConfig['username'] ? '@' : '') . "{$clientConfig['host']}" . |
|
197 | + ($clientConfig['port'] != 27017 ? ":{$clientConfig['port']}" : ''), ['connectTimeoutMS' => $clientConfig['timeout'] * 1000])); |
|
198 | + $this->collection = $this->collection ?: new Collection($this->instance, $clientConfig['databaseName'], $clientConfig['collectionName']); |
|
199 | 199 | |
200 | 200 | return true; |
201 | 201 | } |
@@ -225,14 +225,14 @@ discard block |
||
225 | 225 | 'recordStats' => 0, |
226 | 226 | 'repl' => 0, |
227 | 227 | 'metrics' => 0, |
228 | - ]))->toArray()[ 0 ]; |
|
228 | + ]))->toArray()[0]; |
|
229 | 229 | |
230 | 230 | $collectionStats = $this->instance->executeCommand($this->getConfigOption('databaseName'), new Command([ |
231 | 231 | 'collStats' => ($this->config->getOption('collectionName') !== null ? $this->config->getOption('collectionName') : 'Cache'), |
232 | 232 | 'verbose' => true, |
233 | - ]))->toArray()[ 0 ]; |
|
233 | + ]))->toArray()[0]; |
|
234 | 234 | |
235 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
235 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
236 | 236 | $array = $callback($array); |
237 | 237 | |
238 | 238 | if (\is_object($array) || \is_array($array)) { |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | return $array; |
245 | 245 | }; |
246 | 246 | |
247 | - $callback = function ($item) { |
|
247 | + $callback = function($item) { |
|
248 | 248 | /** |
249 | 249 | * Remove unserializable properties |
250 | 250 | */ |
251 | 251 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
252 | - return (string)$item; |
|
252 | + return (string) $item; |
|
253 | 253 | } |
254 | 254 | return $item; |
255 | 255 | }; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @author Georges.L (Geolim4) <[email protected]> |
13 | 13 | * |
14 | 14 | */ |
15 | -declare(strict_types=1); |
|
15 | +declare(strict_types = 1); |
|
16 | 16 | |
17 | 17 | namespace Phpfastcache\Drivers\Predis; |
18 | 18 | |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | */ |
56 | 56 | protected function driverConnect(): bool |
57 | 57 | { |
58 | - if(!empty($this->config->getOption('path'))){ |
|
58 | + if (!empty($this->config->getOption('path'))) { |
|
59 | 59 | $this->instance = new PredisClient([ |
60 | 60 | 'scheme' => 'unix', |
61 | 61 | 'path' => $this->config->getOption('path') |
62 | 62 | ]); |
63 | - }else{ |
|
63 | + } else { |
|
64 | 64 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
65 | 65 | } |
66 | 66 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @see https://redis.io/commands/expire |
107 | 107 | */ |
108 | 108 | if ($ttl <= 0) { |
109 | - return (bool)$this->instance->expire($item->getKey(), 0); |
|
109 | + return (bool) $this->instance->expire($item->getKey(), 0); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload() === 'OK'; |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | public function getStats(): DriverStatistic |
167 | 167 | { |
168 | 168 | $info = $this->instance->info(); |
169 | - $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
170 | - $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
171 | - $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(\time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
169 | + $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
|
170 | + $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
|
171 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(\time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
172 | 172 | |
173 | 173 | return (new DriverStatistic()) |
174 | 174 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
12 | 12 | * |
13 | 13 | */ |
14 | -declare(strict_types=1); |
|
14 | +declare(strict_types = 1); |
|
15 | 15 | |
16 | 16 | namespace Phpfastcache\Drivers\Wincache; |
17 | 17 | |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | { |
119 | 119 | $memInfo = wincache_ucache_meminfo(); |
120 | 120 | $info = wincache_ucache_info(); |
121 | - $date = (new \DateTime())->setTimestamp(\time() - $info[ 'total_cache_uptime' ]); |
|
121 | + $date = (new \DateTime())->setTimestamp(\time() - $info['total_cache_uptime']); |
|
122 | 122 | |
123 | 123 | return (new DriverStatistic()) |
124 | 124 | ->setInfo(\sprintf("The Wincache daemon is up since %s.\n For more information see RawData.", $date->format(DATE_RFC2822))) |
125 | - ->setSize($memInfo[ 'memory_free' ] - $memInfo[ 'memory_total' ]) |
|
125 | + ->setSize($memInfo['memory_free'] - $memInfo['memory_total']) |
|
126 | 126 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
127 | 127 | ->setRawData($memInfo); |
128 | 128 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @author Georges.L (Geolim4) <[email protected]> |
12 | 12 | * |
13 | 13 | */ |
14 | -declare(strict_types=1); |
|
14 | +declare(strict_types = 1); |
|
15 | 15 | |
16 | 16 | namespace Phpfastcache\Drivers\Apcu; |
17 | 17 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | if ($item instanceof Item) { |
62 | 62 | $ttl = $item->getExpirationDate()->getTimestamp() - \time(); |
63 | 63 | |
64 | - return (bool)apcu_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
64 | + return (bool) apcu_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0)); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * Check for Cross-Driver type confusion |
93 | 93 | */ |
94 | 94 | if ($item instanceof Item) { |
95 | - return (bool)apcu_delete($item->getKey()); |
|
95 | + return (bool) apcu_delete($item->getKey()); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getStats(): DriverStatistic |
119 | 119 | { |
120 | - $stats = (array)apcu_cache_info(); |
|
121 | - $date = (new \DateTime())->setTimestamp($stats[ 'start_time' ]); |
|
120 | + $stats = (array) apcu_cache_info(); |
|
121 | + $date = (new \DateTime())->setTimestamp($stats['start_time']); |
|
122 | 122 | |
123 | 123 | return (new DriverStatistic()) |
124 | 124 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
125 | 125 | ->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), |
126 | - $stats[ 'num_entries' ])) |
|
126 | + $stats['num_entries'])) |
|
127 | 127 | ->setRawData($stats) |
128 | - ->setSize($stats[ 'mem_size' ]); |
|
128 | + ->setSize($stats['mem_size']); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | \ No newline at end of file |