@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | use Phpfastcache\Core\Item\ExtendedCacheItemInterface; |
| 20 | 20 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 21 | 21 | use Phpfastcache\Exceptions\{ |
| 22 | - PhpfastcacheDriverCheckException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException, PhpfastcacheRootException, PhpfastcacheSimpleCacheException |
|
| 22 | + PhpfastcacheDriverCheckException, PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException, PhpfastcacheRootException, PhpfastcacheSimpleCacheException |
|
| 23 | 23 | }; |
| 24 | 24 | use Psr\SimpleCache\CacheInterface; |
| 25 | 25 | |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | try { |
| 86 | 86 | $cacheItem = $this->internalCacheInstance |
| 87 | - ->getItem($key) |
|
| 88 | - ->set($value); |
|
| 87 | + ->getItem($key) |
|
| 88 | + ->set($value); |
|
| 89 | 89 | if (\is_int($ttl) && $ttl <= 0) { |
| 90 | 90 | $cacheItem->expiresAt((new \DateTime('@0'))); |
| 91 | 91 | } elseif (\is_int($ttl) || $ttl instanceof \DateInterval) { |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | throw new PhpfastcacheLogicException("You can't pass a config parameter along with an non-string '\$driver' parameter."); |
| 49 | 49 | } |
| 50 | 50 | $this->internalCacheInstance = $driver; |
| 51 | - }else{ |
|
| 51 | + } else{ |
|
| 52 | 52 | $this->internalCacheInstance = CacheManager::getInstance($driver, $config); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct($driver, $config = null) |
| 45 | 45 | { |
| 46 | - if($driver instanceof ExtendedCacheItemPoolInterface){ |
|
| 47 | - if($config !== null){ |
|
| 46 | + if ($driver instanceof ExtendedCacheItemPoolInterface) { |
|
| 47 | + if ($config !== null) { |
|
| 48 | 48 | throw new PhpfastcacheLogicException("You can't pass a config parameter along with an non-string '\$driver' parameter."); |
| 49 | 49 | } |
| 50 | 50 | $this->internalCacheInstance = $driver; |
| 51 | - }else{ |
|
| 51 | + } else { |
|
| 52 | 52 | $this->internalCacheInstance = CacheManager::getInstance($driver, $config); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | public function getMultiple($keys, $default = null) |
| 134 | 134 | { |
| 135 | 135 | try { |
| 136 | - return array_map(function (ExtendedCacheItemInterface $item) { |
|
| 136 | + return array_map(function(ExtendedCacheItemInterface $item) { |
|
| 137 | 137 | return $item->get(); |
| 138 | 138 | }, $this->internalCacheInstance->getItems($keys)); |
| 139 | 139 | } catch (PhpfastcacheInvalidArgumentException $e) { |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * due to performance issue on huge |
| 79 | 79 | * loop dispatching operations |
| 80 | 80 | */ |
| 81 | - if (isset($this->events[ $eventName ])) { |
|
| 82 | - foreach ($this->events[ $eventName ] as $event) { |
|
| 81 | + if (isset($this->events[$eventName])) { |
|
| 82 | + foreach ($this->events[$eventName] as $event) { |
|
| 83 | 83 | \call_user_func_array($event, $args); |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | if (\strpos($name, 'on') === 0) { |
| 97 | 97 | $name = \substr($name, 2); |
| 98 | - if (\is_callable($arguments[ 0 ])) { |
|
| 99 | - if (isset($arguments[ 1 ]) && \is_string($arguments[ 0 ])) { |
|
| 100 | - $this->events[ $name ][ $arguments[ 1 ] ] = $arguments[ 0 ]; |
|
| 98 | + if (\is_callable($arguments[0])) { |
|
| 99 | + if (isset($arguments[1]) && \is_string($arguments[0])) { |
|
| 100 | + $this->events[$name][$arguments[1]] = $arguments[0]; |
|
| 101 | 101 | } else { |
| 102 | - $this->events[ $name ][] = $arguments[ 0 ]; |
|
| 102 | + $this->events[$name][] = $arguments[0]; |
|
| 103 | 103 | } |
| 104 | 104 | } else { |
| 105 | - throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[ 0 ]))); |
|
| 105 | + throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[0]))); |
|
| 106 | 106 | } |
| 107 | 107 | } else { |
| 108 | 108 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function unbindEventCallback(string $eventName, string $callbackName): bool |
| 118 | 118 | { |
| 119 | - $return = isset($this->events[ $eventName ][ $callbackName ]); |
|
| 120 | - unset($this->events[ $eventName ][ $callbackName ]); |
|
| 119 | + $return = isset($this->events[$eventName][$callbackName]); |
|
| 120 | + unset($this->events[$eventName][$callbackName]); |
|
| 121 | 121 | |
| 122 | 122 | return $return; |
| 123 | 123 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | public function __construct($message = "", $code = 0, $previous = null) |
| 28 | 28 | { |
| 29 | 29 | $lastError = error_get_last(); |
| 30 | - if($lastError){ |
|
| 30 | + if ($lastError) { |
|
| 31 | 31 | $message .= "\n"; |
| 32 | 32 | $message .= "Additional information provided by error_get_last():\n"; |
| 33 | 33 | $message .= "{$lastError['message']} in {$lastError['file']} line {$lastError['line']}"; |
@@ -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 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __construct(...$args) |
| 34 | 34 | { |
| 35 | - $this->array = (\count($args) === 1 && \is_array($args[ 0 ]) ? $args[ 0 ] : $args); |
|
| 35 | + $this->array = (\count($args) === 1 && \is_array($args[0]) ? $args[0] : $args); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function current() |
| 42 | 42 | { |
| 43 | - return $this->array[ $this->position ]; |
|
| 43 | + return $this->array[$this->position]; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function offsetGet($offset) |
| 100 | 100 | { |
| 101 | - return $this->array[ $offset ] ?? null; |
|
| 101 | + return $this->array[$offset] ?? null; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | if ($offset === null) { |
| 114 | 114 | $this->array[] = $value; |
| 115 | 115 | } else { |
| 116 | - $this->array[ $offset ] = $value; |
|
| 116 | + $this->array[$offset] = $value; |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function offsetUnset($offset) |
| 124 | 124 | { |
| 125 | - unset($this->array[ $offset ]); |
|
| 125 | + unset($this->array[$offset]); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 19 | 19 | use Phpfastcache\Event\EventInterface; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException, PhpfastcacheLogicException |
|
| 21 | + PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidArgumentTypeException, PhpfastcacheLogicException |
|
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $this->driver = $driver; |
| 71 | 71 | $this->driver->setItem($this); |
| 72 | 72 | $this->expirationDate = new \DateTime(); |
| 73 | - if($this->driver->getConfig()->isItemDetailedDate()){ |
|
| 73 | + if ($this->driver->getConfig()->isItemDetailedDate()) { |
|
| 74 | 74 | $this->creationDate = new \DateTime(); |
| 75 | 75 | $this->modificationDate = new \DateTime(); |
| 76 | 76 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | case 'array': |
| 226 | 226 | case 'object': |
| 227 | - if(\is_array($this->data) || $this->data instanceof \Countable){ |
|
| 227 | + if (\is_array($this->data) || $this->data instanceof \Countable) { |
|
| 228 | 228 | return \count($this->data); |
| 229 | 229 | } |
| 230 | 230 | break; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | if (\is_array($this->data)) { |
| 283 | 283 | $this->data[] = $data; |
| 284 | 284 | } else 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 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | if (\is_array($this->data)) { |
| 302 | 302 | \array_unshift($this->data, $data); |
| 303 | 303 | } else if (\is_string($data)) { |
| 304 | - $this->data = (string)$data . $this->data; |
|
| 304 | + $this->data = (string) $data . $this->data; |
|
| 305 | 305 | } else { |
| 306 | 306 | throw new PhpfastcacheInvalidArgumentException('$data must be either array nor string.'); |
| 307 | 307 | } |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | public function removeTag($tagName): ExtendedCacheItemInterface |
| 381 | 381 | { |
| 382 | 382 | if (($key = \array_search($tagName, $this->tags)) !== false) { |
| 383 | - unset($this->tags[ $key ]); |
|
| 383 | + unset($this->tags[$key]); |
|
| 384 | 384 | $this->removedTags[] = $tagName; |
| 385 | 385 | } |
| 386 | 386 | |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | final public function __debugInfo() |
| 460 | 460 | { |
| 461 | 461 | $info = \get_object_vars($this); |
| 462 | - $info[ 'driver' ] = 'object(' . \get_class($info[ 'driver' ]) . ')'; |
|
| 462 | + $info['driver'] = 'object(' . \get_class($info['driver']) . ')'; |
|
| 463 | 463 | |
| 464 | 464 | return $info; |
| 465 | 465 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 19 | 19 | use Phpfastcache\Event\EventInterface; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 21 | + PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 22 | 22 | }; |
| 23 | 23 | use Psr\Cache\CacheItemInterface; |
| 24 | 24 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | use Phpfastcache\Core\Item\ExtendedCacheItemInterface; |
| 19 | 19 | use Phpfastcache\Event\EventInterface; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 21 | + PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 22 | 22 | }; |
| 23 | 23 | use Psr\Cache\CacheItemInterface; |
| 24 | 24 | |
@@ -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; |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | use Phpfastcache\Entities\DriverStatistic; |
| 22 | 22 | use Phpfastcache\Event\EventInterface; |
| 23 | 23 | use Phpfastcache\Exceptions\{ |
| 24 | - PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 24 | + PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 25 | 25 | }; |
| 26 | 26 | use Psr\Cache\{CacheItemInterface, CacheItemPoolInterface}; |
| 27 | 27 | |