@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $config = self::validateConfig($config); |
| 177 | 177 | $driver = self::standardizeDriverName($driver); |
| 178 | 178 | |
| 179 | - $instanceId = $instanceId ?: md5($driver . \serialize(\array_filter($config->toArray(), static function ($val){ |
|
| 179 | + $instanceId = $instanceId ?: md5($driver . \serialize(\array_filter($config->toArray(), static function($val) { |
|
| 180 | 180 | return !\is_callable($val); |
| 181 | 181 | }))); |
| 182 | 182 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $found = false; |
| 320 | 320 | self::$instances = \array_filter( |
| 321 | 321 | \array_map( |
| 322 | - static function (ExtendedCacheItemPoolInterface $cachePool) use ($cachePoolInstance, &$found) { |
|
| 322 | + static function(ExtendedCacheItemPoolInterface $cachePool) use ($cachePoolInstance, &$found) { |
|
| 323 | 323 | if (\spl_object_hash($cachePool) === \spl_object_hash($cachePoolInstance)) { |
| 324 | 324 | $found = true; |
| 325 | 325 | return null; |
@@ -152,7 +152,7 @@ |
||
| 152 | 152 | } |
| 153 | 153 | try { |
| 154 | 154 | return \array_map( |
| 155 | - static function (ExtendedCacheItemInterface $item) use ($default) { |
|
| 155 | + static function(ExtendedCacheItemInterface $item) use ($default) { |
|
| 156 | 156 | return $item->isHit() ? $item->get() : $default; |
| 157 | 157 | }, |
| 158 | 158 | $this->internalCacheInstance->getItems($keys) |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * Register Autoload |
| 31 | 31 | */ |
| 32 | 32 | spl_autoload_register( |
| 33 | - static function ($entity): void { |
|
| 33 | + static function($entity): void { |
|
| 34 | 34 | $module = explode('\\', $entity, 2); |
| 35 | 35 | if (!\in_array($module[0], ['Phpfastcache', 'Psr'])) { |
| 36 | 36 | /** |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $entityPath = str_replace('\\', '/', $entity); |
| 66 | 66 | |
| 67 | - if(\strpos($entity, PFC_TESTS_NS) === 0){ |
|
| 67 | + if (\strpos($entity, PFC_TESTS_NS) === 0) { |
|
| 68 | 68 | $path = PFC_TESTS_DIR . \str_replace(str_replace('\\', '/', PFC_TESTS_NS), '', $entityPath) . '.' . PFC_PHP_EXT; |
| 69 | - }else{ |
|
| 69 | + } else { |
|
| 70 | 70 | $path = PFC_LIB_DIR . $entityPath . '.' . PFC_PHP_EXT; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -91,8 +91,7 @@ discard block |
||
| 91 | 91 | return unlink($source); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $files = new RecursiveIteratorIterator |
|
| 95 | - ( |
|
| 94 | + $files = new RecursiveIteratorIterator( |
|
| 96 | 95 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
| 97 | 96 | RecursiveIteratorIterator::CHILD_FIRST |
| 98 | 97 | ); |
@@ -102,7 +101,7 @@ discard block |
||
| 102 | 101 | * @var SplFileInfo $fileinfo |
| 103 | 102 | */ |
| 104 | 103 | $realpath = $fileinfo->getRealPath(); |
| 105 | - if($realpath){ |
|
| 104 | + if ($realpath) { |
|
| 106 | 105 | if ($fileinfo->isDir()) { |
| 107 | 106 | if (self::rrmdir($fileinfo->getRealPath()) === false) { |
| 108 | 107 | return false; |
@@ -111,7 +110,7 @@ discard block |
||
| 111 | 110 | return false; |
| 112 | 111 | } |
| 113 | 112 | } |
| 114 | - else{ |
|
| 113 | + else { |
|
| 115 | 114 | return false; |
| 116 | 115 | } |
| 117 | 116 | } |
@@ -148,7 +147,7 @@ discard block |
||
| 148 | 147 | /** |
| 149 | 148 | * Allows to dereference char |
| 150 | 149 | */ |
| 151 | - $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc. |
|
| 150 | + $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc. |
|
| 152 | 151 | $prefix = $__FILE__[0] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
| 153 | 152 | return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes); |
| 154 | 153 | } |
@@ -99,14 +99,14 @@ |
||
| 99 | 99 | case T_NAMESPACE: |
| 100 | 100 | $namespace = ''; |
| 101 | 101 | // If there is a namespace, extract it (PHP 8 test) |
| 102 | - if(\defined('T_NAME_QUALIFIED')){ |
|
| 102 | + if (\defined('T_NAME_QUALIFIED')) { |
|
| 103 | 103 | while (isset($tokens[++$i][1])) { |
| 104 | 104 | if ($tokens[$i][0] === T_NAME_QUALIFIED) { |
| 105 | 105 | $namespace = $tokens[$i][1]; |
| 106 | 106 | break; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | - }else{ |
|
| 109 | + } else { |
|
| 110 | 110 | while (isset($tokens[++$i][1])) { |
| 111 | 111 | if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR], true)) { |
| 112 | 112 | $namespace .= $tokens[$i][1]; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | if (\is_string($key)) { |
| 67 | 67 | $this->key = $key; |
| 68 | 68 | $this->driver = $driver; |
| 69 | - if($driver->getConfig()->isUseStaticItemCaching()){ |
|
| 69 | + if ($driver->getConfig()->isUseStaticItemCaching()) { |
|
| 70 | 70 | $this->driver->setItem($this); |
| 71 | 71 | } |
| 72 | 72 | $this->expirationDate = new DateTime(); |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $this->data[] = $data; |
| 283 | 283 | } else { |
| 284 | 284 | if (\is_string($data)) { |
| 285 | - $this->data .= (string)$data; |
|
| 285 | + $this->data .= (string) $data; |
|
| 286 | 286 | } else { |
| 287 | 287 | throw new PhpfastcacheInvalidArgumentException('$data must be either array nor string.'); |
| 288 | 288 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | \array_unshift($this->data, $data); |
| 304 | 304 | } else { |
| 305 | 305 | if (\is_string($data)) { |
| 306 | - $this->data = (string)$data . $this->data; |
|
| 306 | + $this->data = (string) $data . $this->data; |
|
| 307 | 307 | } else { |
| 308 | 308 | throw new PhpfastcacheInvalidArgumentException('$data must be either array nor string.'); |
| 309 | 309 | } |
@@ -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 | ); |
@@ -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 | ); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - return (bool)$return; |
|
| 138 | + return (bool) $return; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - return (bool)$return; |
|
| 155 | + return (bool) $return; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string'); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - return (bool)$return; |
|
| 190 | + return (bool) $return; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $this->saveDeferred($item); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - return (bool)$this->commit(); |
|
| 204 | + return (bool) $this->commit(); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string and $step an integer'); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - return (bool)$return; |
|
| 223 | + return (bool) $return; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $this->saveDeferred($item); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - return (bool)$this->commit(); |
|
| 237 | + return (bool) $this->commit(); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string and $step an integer'); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - return (bool)$return; |
|
| 256 | + return (bool) $return; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $this->saveDeferred($item); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - return (bool)$this->commit(); |
|
| 270 | + return (bool) $this->commit(); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string'); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - return (bool)$return; |
|
| 289 | + return (bool) $return; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $this->saveDeferred($item); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - return (bool)$this->commit(); |
|
| 303 | + return (bool) $this->commit(); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | throw new PhpfastcacheInvalidArgumentException('$tagName must be a string'); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * that has slow performances |
| 362 | 362 | */ |
| 363 | 363 | |
| 364 | - $tagsItem->set(\array_merge((array)$data, [$item->getKey() => $expTimestamp])) |
|
| 364 | + $tagsItem->set(\array_merge((array) $data, [$item->getKey() => $expTimestamp])) |
|
| 365 | 365 | ->expiresAt($item->getExpirationDate()); |
| 366 | 366 | |
| 367 | 367 | $this->driverWrite($tagsItem); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $tagsItems = $this->getItems($this->getTagKeys($item->getRemovedTags())); |
| 376 | 376 | |
| 377 | 377 | foreach ($tagsItems as $tagsItem) { |
| 378 | - $data = (array)$tagsItem->get(); |
|
| 378 | + $data = (array) $tagsItem->get(); |
|
| 379 | 379 | |
| 380 | 380 | unset($data[$item->getKey()]); |
| 381 | 381 | $tagsItem->set($data); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | protected function getTagKeys(array $keys): array |
| 407 | 407 | { |
| 408 | 408 | return \array_map( |
| 409 | - function (string $key) { |
|
| 409 | + function(string $key) { |
|
| 410 | 410 | return $this->getTagKey($key); |
| 411 | 411 | }, |
| 412 | 412 | $keys |
@@ -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 | } |