@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function getStats(): DriverStatistic |
49 | 49 | { |
50 | - $stats = (array)apcu_cache_info(); |
|
50 | + $stats = (array) apcu_cache_info(); |
|
51 | 51 | $date = (new DateTime())->setTimestamp($stats['start_time']); |
52 | 52 | |
53 | 53 | return (new DriverStatistic()) |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | ) |
61 | 61 | ) |
62 | 62 | ->setRawData($stats) |
63 | - ->setSize((int)$stats['mem_size']); |
|
63 | + ->setSize((int) $stats['mem_size']); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * Check for Cross-Driver type confusion |
83 | 83 | */ |
84 | 84 | if ($item instanceof Item) { |
85 | - return (bool)apcu_store($item->getKey(), $this->driverPreWrap($item), $item->getTtl()); |
|
85 | + return (bool) apcu_store($item->getKey(), $this->driverPreWrap($item), $item->getTtl()); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * Check for Cross-Driver type confusion |
115 | 115 | */ |
116 | 116 | if ($item instanceof Item) { |
117 | - return (bool)apcu_delete($item->getKey()); |
|
117 | + return (bool) apcu_delete($item->getKey()); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | if ($item instanceof Item) { |
153 | 153 | try { |
154 | - return (bool)$this->getBucket()->upsert( |
|
154 | + return (bool) $this->getBucket()->upsert( |
|
155 | 155 | $item->getEncodedKey(), |
156 | 156 | $this->encode($this->driverPreWrap($item)), |
157 | 157 | ['expiry' => $item->getTtl()] |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | if ($item instanceof Item) { |
178 | 178 | try { |
179 | - return (bool)$this->getBucket()->remove($item->getEncodedKey()); |
|
179 | + return (bool) $this->getBucket()->remove($item->getEncodedKey()); |
|
180 | 180 | } catch (Exception $e) { |
181 | 181 | return $e->getCode() === COUCHBASE_KEY_ENOENT; |
182 | 182 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | return $this->getStandardizedItem( |
61 | 61 | $this->makeOperation( |
62 | - static function (ExtendedCacheItemPoolInterface $pool) use ($key) { |
|
62 | + static function(ExtendedCacheItemPoolInterface $pool) use ($key) { |
|
63 | 63 | return $pool->getItem($key); |
64 | 64 | } |
65 | 65 | ) ?? new Item($this, $key), |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function hasItem($key) |
113 | 113 | { |
114 | 114 | return $this->makeOperation( |
115 | - static function (ExtendedCacheItemPoolInterface $pool) use ($key) { |
|
115 | + static function(ExtendedCacheItemPoolInterface $pool) use ($key) { |
|
116 | 116 | return $pool->hasItem($key); |
117 | 117 | } |
118 | 118 | ); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | public function clear() |
125 | 125 | { |
126 | 126 | return $this->makeOperation( |
127 | - static function (ExtendedCacheItemPoolInterface $pool) { |
|
127 | + static function(ExtendedCacheItemPoolInterface $pool) { |
|
128 | 128 | return $pool->clear(); |
129 | 129 | } |
130 | 130 | ); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | public function deleteItem($key) |
137 | 137 | { |
138 | 138 | return $this->makeOperation( |
139 | - static function (ExtendedCacheItemPoolInterface $pool) use ($key) { |
|
139 | + static function(ExtendedCacheItemPoolInterface $pool) use ($key) { |
|
140 | 140 | return $pool->deleteItem($key); |
141 | 141 | } |
142 | 142 | ); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public function save(CacheItemInterface $item) |
149 | 149 | { |
150 | 150 | return $this->makeOperation( |
151 | - function (ExtendedCacheItemPoolInterface $pool) use ($item) { |
|
151 | + function(ExtendedCacheItemPoolInterface $pool) use ($item) { |
|
152 | 152 | $item->setHit(true); |
153 | 153 | return $pool->save($this->getStandardizedItem($item, $pool)); |
154 | 154 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | public function commit() |
163 | 163 | { |
164 | 164 | return $this->makeOperation( |
165 | - static function (ExtendedCacheItemPoolInterface $pool) { |
|
165 | + static function(ExtendedCacheItemPoolInterface $pool) { |
|
166 | 166 | return $pool->commit(); |
167 | 167 | } |
168 | 168 | ); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | \implode( |
201 | 201 | ', ', |
202 | 202 | \array_map( |
203 | - static function (ExtendedCacheItemPoolInterface $pool) { |
|
203 | + static function(ExtendedCacheItemPoolInterface $pool) { |
|
204 | 204 | return \get_class($pool); |
205 | 205 | }, |
206 | 206 | $this->clusterPools |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | ); |
211 | 211 | |
212 | 212 | $stats->setSize( |
213 | - (int)\array_sum( |
|
213 | + (int) \array_sum( |
|
214 | 214 | \array_map( |
215 | - static function (ExtendedCacheItemPoolInterface $pool) { |
|
215 | + static function(ExtendedCacheItemPoolInterface $pool) { |
|
216 | 216 | return $pool->getStats()->getSize(); |
217 | 217 | }, |
218 | 218 | $this->clusterPools |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | ); |
222 | 222 | |
223 | 223 | $stats->setData( |
224 | - (int)\array_map( |
|
225 | - static function (ExtendedCacheItemPoolInterface $pool) { |
|
224 | + (int) \array_map( |
|
225 | + static function(ExtendedCacheItemPoolInterface $pool) { |
|
226 | 226 | return $pool->getStats()->getData(); |
227 | 227 | }, |
228 | 228 | $this->clusterPools |
@@ -233,7 +233,7 @@ |
||
233 | 233 | */ |
234 | 234 | protected function decode($value) |
235 | 235 | { |
236 | - return \unserialize((string)$value, ['allowed_classes' => true]); |
|
236 | + return \unserialize((string) $value, ['allowed_classes' => true]); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function getItemsByTagsAsJsonString(array $tagNames, int $option = 0, int $depth = 512, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): string |
36 | 36 | { |
37 | - $callback = static function (CacheItemInterface $item) { |
|
37 | + $callback = static function(CacheItemInterface $item) { |
|
38 | 38 | return $item->get(); |
39 | 39 | }; |
40 | 40 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | if (\is_string($tagName)) { |
88 | 88 | $driverResponse = $this->getItem($this->getTagKey($tagName)); |
89 | 89 | if ($driverResponse->isHit()) { |
90 | - $tagsItems = (array)$driverResponse->get(); |
|
90 | + $tagsItems = (array) $driverResponse->get(); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * getItems() may provides expired item(s) |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | return \array_filter( |
103 | 103 | $this->getItems(\array_unique(\array_keys($tagsItems))), |
104 | - static function (ExtendedCacheItemInterface $item) { |
|
104 | + static function(ExtendedCacheItemInterface $item) { |
|
105 | 105 | return $item->isHit(); |
106 | 106 | } |
107 | 107 | ); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | - return (bool)$return; |
|
137 | + return (bool) $return; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - return (bool)$return; |
|
154 | + return (bool) $return; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string'); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - return (bool)$return; |
|
189 | + return (bool) $return; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $this->saveDeferred($item); |
201 | 201 | } |
202 | 202 | |
203 | - return (bool)$this->commit(); |
|
203 | + return (bool) $this->commit(); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string and $step an integer'); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - return (bool)$return; |
|
222 | + return (bool) $return; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $this->saveDeferred($item); |
234 | 234 | } |
235 | 235 | |
236 | - return (bool)$this->commit(); |
|
236 | + return (bool) $this->commit(); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string and $step an integer'); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | - return (bool)$return; |
|
255 | + return (bool) $return; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $this->saveDeferred($item); |
267 | 267 | } |
268 | 268 | |
269 | - return (bool)$this->commit(); |
|
269 | + return (bool) $this->commit(); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string'); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | - return (bool)$return; |
|
288 | + return (bool) $return; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $this->saveDeferred($item); |
300 | 300 | } |
301 | 301 | |
302 | - return (bool)$this->commit(); |
|
302 | + return (bool) $this->commit(); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string'); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * that has slow performances |
361 | 361 | */ |
362 | 362 | |
363 | - $tagsItem->set(\array_merge((array)$data, [$item->getKey() => $expTimestamp])); |
|
363 | + $tagsItem->set(\array_merge((array) $data, [$item->getKey() => $expTimestamp])); |
|
364 | 364 | |
365 | 365 | /** |
366 | 366 | * Set the expiration date |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $tagsItems = $this->getItems($this->getTagKeys($item->getRemovedTags())); |
383 | 383 | |
384 | 384 | foreach ($tagsItems as $tagsItem) { |
385 | - $data = (array)$tagsItem->get(); |
|
385 | + $data = (array) $tagsItem->get(); |
|
386 | 386 | |
387 | 387 | unset($data[$item->getKey()]); |
388 | 388 | $tagsItem->set($data); |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | protected function getTagKeys(array $keys): array |
414 | 414 | { |
415 | 415 | return \array_map( |
416 | - function (string $key) { |
|
416 | + function(string $key) { |
|
417 | 417 | return $this->getTagKey($key); |
418 | 418 | }, |
419 | 419 | $keys |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function setItem(CacheItemInterface $item) |
67 | 67 | { |
68 | 68 | if ($this->getClassNamespace() . '\\Item' === \get_class($item)) { |
69 | - if(!$this->getConfig()->isUseStaticItemCaching()){ |
|
69 | + if (!$this->getConfig()->isUseStaticItemCaching()) { |
|
70 | 70 | throw new PhpfastcacheLogicException( |
71 | 71 | 'The static item caching option (useStaticItemCaching) is disabled so you cannot attach an item.' |
72 | 72 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * Reset the Item |
209 | 209 | */ |
210 | 210 | $item->set(null) |
211 | - ->expiresAfter(abs((int)$this->getConfig()['defaultTtl'])) |
|
211 | + ->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])) |
|
212 | 212 | ->setHit(false) |
213 | 213 | ->setTags([]); |
214 | 214 | if ($this->getConfig()->isItemDetailedDate()) { |
@@ -224,15 +224,15 @@ discard block |
||
224 | 224 | $item->setHit(true); |
225 | 225 | } |
226 | 226 | } else { |
227 | - $item->expiresAfter(abs((int)$this->getConfig()['defaultTtl'])); |
|
227 | + $item->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])); |
|
228 | 228 | } |
229 | 229 | } |
230 | - }else{ |
|
230 | + } else { |
|
231 | 231 | $item = $this->itemInstances[$key]; |
232 | 232 | } |
233 | 233 | |
234 | 234 | |
235 | - if($item !== null){ |
|
235 | + if ($item !== null) { |
|
236 | 236 | /** |
237 | 237 | * @eventName CacheGetItem |
238 | 238 | * @param $this ExtendedCacheItemPoolInterface |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | } |
294 | 294 | } |
295 | 295 | |
296 | - return (bool)$return; |
|
296 | + return (bool) $return; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - return (bool)$return; |
|
384 | + return (bool) $return; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * loop dispatching operations |
402 | 402 | */ |
403 | 403 | if (!isset($this->itemInstances[$item->getKey()])) { |
404 | - if($this->getConfig()->isUseStaticItemCaching()){ |
|
404 | + if ($this->getConfig()->isUseStaticItemCaching()) { |
|
405 | 405 | $this->itemInstances[$item->getKey()] = $item; |
406 | 406 | } |
407 | 407 | } else { |
@@ -227,7 +227,7 @@ |
||
227 | 227 | $item->expiresAfter(abs((int)$this->getConfig()['defaultTtl'])); |
228 | 228 | } |
229 | 229 | } |
230 | - }else{ |
|
230 | + } else{ |
|
231 | 231 | $item = $this->itemInstances[$key]; |
232 | 232 | } |
233 | 233 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getItemsAsJsonString(array $keys = [], int $option = 0, int $depth = 512): string |
42 | 42 | { |
43 | - $callback = static function (CacheItemInterface $item) { |
|
43 | + $callback = static function(CacheItemInterface $item) { |
|
44 | 44 | return $item->get(); |
45 | 45 | }; |
46 | 46 | return \json_encode(\array_map($callback, \array_values($this->getItems($keys))), $option, $depth); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
94 | - if(!$this->getConfig()->isUseStaticItemCaching()){ |
|
94 | + if (!$this->getConfig()->isUseStaticItemCaching()) { |
|
95 | 95 | throw new PhpfastcacheLogicException( |
96 | 96 | 'The static item caching option (useStaticItemCaching) is disabled so you cannot attach an item.' |
97 | 97 | ); |
@@ -66,7 +66,7 @@ |
||
66 | 66 | |
67 | 67 | if($this->getConfig()->isUseStaticItemCaching()){ |
68 | 68 | $stat->setData(implode(', ', \array_keys($this->itemInstances))); |
69 | - }else{ |
|
69 | + } else{ |
|
70 | 70 | $stat->setData('No data available since static item caching option (useStaticItemCaching) is disabled.'); |
71 | 71 | } |
72 | 72 |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | ->setSize(Directory::dirSize($path)) |
65 | 65 | ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
66 | 66 | |
67 | - if($this->getConfig()->isUseStaticItemCaching()){ |
|
67 | + if ($this->getConfig()->isUseStaticItemCaching()) { |
|
68 | 68 | $stat->setData(implode(', ', \array_keys($this->itemInstances))); |
69 | - }else{ |
|
69 | + } else { |
|
70 | 70 | $stat->setData('No data available since static item caching option (useStaticItemCaching) is disabled.'); |
71 | 71 | } |
72 | 72 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | throw new PhpfastcacheIOException("Cannot read file located at: {$file}"); |
295 | 295 | } |
296 | 296 | if (\function_exists('file_get_contents')) { |
297 | - return (string)\file_get_contents($file); |
|
297 | + return (string) \file_get_contents($file); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | $string = ''; |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | dirname($file) . \DIRECTORY_SEPARATOR . 'tmp_' . $this->getConfig()->getDefaultFileNameHashFunction()( |
339 | 339 | \bin2hex(\random_bytes(16)) |
340 | 340 | ) |
341 | - ) . '.' . $this->getConfig()->getCacheFileExtension() . \random_int(1000, 9999); |
|
341 | + ) . '.' . $this->getConfig()->getCacheFileExtension() . \random_int(1000, 9999); |
|
342 | 342 | |
343 | 343 | $handle = \fopen($tmpFilename, 'w+b'); |
344 | 344 | if (\is_resource($handle)) { |
@@ -359,6 +359,6 @@ discard block |
||
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | - return (bool)($octetWritten ?? false); |
|
362 | + return (bool) ($octetWritten ?? false); |
|
363 | 363 | } |
364 | 364 | } |