@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | protected static function cleanFileName($filename): string |
| 193 | 193 | { |
| 194 | 194 | $regex = [ |
| 195 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 196 | - '/\.$/', |
|
| 197 | - '/^\./', |
|
| 195 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
| 196 | + '/\.$/', |
|
| 197 | + '/^\./', |
|
| 198 | 198 | ]; |
| 199 | 199 | $replace = ['-', '', '']; |
| 200 | 200 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $tmpFilename = Directory::getAbsolutePath(\dirname($file) . '/tmp_' . \md5( |
| 291 | 291 | \str_shuffle(\uniqid($this->getDriverName(), false)) |
| 292 | 292 | . \str_shuffle(\uniqid($this->getDriverName(), false)) |
| 293 | - )); |
|
| 293 | + )); |
|
| 294 | 294 | |
| 295 | 295 | $f = \fopen($tmpFilename, 'w+'); |
| 296 | 296 | \flock($f, LOCK_EX); |
@@ -332,11 +332,11 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $stat->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 335 | - ->setRawData([ |
|
| 335 | + ->setRawData([ |
|
| 336 | 336 | 'tmp' => $this->tmp, |
| 337 | - ]) |
|
| 338 | - ->setSize(Directory::dirSize($path)) |
|
| 339 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 337 | + ]) |
|
| 338 | + ->setSize(Directory::dirSize($path)) |
|
| 339 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
| 340 | 340 | |
| 341 | 341 | return $stat; |
| 342 | 342 | } |
@@ -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\IO; |
| 17 | 17 | |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | $securityKey = \array_key_exists('securityKey', $this->getConfig()) ? $this->getConfig()->getSecurityKey() : ''; |
| 58 | 58 | if (!$securityKey || mb_strtolower($securityKey) === 'auto') { |
| 59 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
| 60 | - $securityKey = preg_replace('/^www./', '', \strtolower(\str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
| 59 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
| 60 | + $securityKey = preg_replace('/^www./', '', \strtolower(\str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
| 61 | 61 | } else { |
| 62 | 62 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
| 63 | 63 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | return $full_path; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@\file_exists($full_path) || !@\is_writable($full_path))) { |
|
| 103 | + if (!isset($this->tmp[$full_path_hash]) || (!@\file_exists($full_path) || !@\is_writable($full_path))) { |
|
| 104 | 104 | if (!@\file_exists($full_path)) { |
| 105 | 105 | @mkdir($full_path, $this->getDefaultChmod(), true); |
| 106 | 106 | } else if (!@\is_writable($full_path)) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | throw new PhpfastcacheIOException('Path "' . $full_path . '" is not writable, please set a chmod 0777 or any writable permission and make sure to make use of an absolute path !'); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
| 128 | + $this->tmp[$full_path_hash] = $full_path; |
|
| 129 | 129 | $this->htaccessGen($full_path, \array_key_exists('htaccess', $this->getConfig()) ? $this->getConfig()->getHtaccess() : false); |
| 130 | 130 | } |
| 131 | 131 | |
@@ -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 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Phpfastcache\Core\Pool\{DriverBaseTrait, ExtendedCacheItemPoolInterface}; |
| 19 | 19 | use Phpfastcache\Entities\DriverStatistic; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheInvalidArgumentException |
|
| 21 | + PhpfastcacheInvalidArgumentException |
|
| 22 | 22 | }; |
| 23 | 23 | use Psr\Cache\CacheItemInterface; |
| 24 | 24 | |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | $date = (new \DateTime())->setTimestamp(\time() - $info[ 'total_cache_uptime' ]); |
| 122 | 122 | |
| 123 | 123 | return (new DriverStatistic()) |
| 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' ]) |
|
| 126 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 127 | - ->setRawData($memInfo); |
|
| 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' ]) |
|
| 126 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 127 | + ->setRawData($memInfo); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | \ 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\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 | } |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | use Phpfastcache\Config\ConfigurationOption; |
| 19 | 19 | use Phpfastcache\Core\Pool\{ |
| 20 | - DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 20 | + DriverBaseTrait, ExtendedCacheItemPoolInterface |
|
| 21 | 21 | }; |
| 22 | 22 | use Phpfastcache\Entities\DriverStatistic; |
| 23 | 23 | use Phpfastcache\Exceptions\{ |
| 24 | - PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 24 | + PhpfastcacheInvalidArgumentException, PhpfastcacheLogicException |
|
| 25 | 25 | }; |
| 26 | 26 | use Phpfastcache\Util\ArrayObject; |
| 27 | 27 | use Psr\Cache\CacheItemInterface; |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | $date = (new \DateTime())->setTimestamp(\time() - $info[ 'uptime_in_seconds' ]); |
| 163 | 163 | |
| 164 | 164 | return (new DriverStatistic()) |
| 165 | - ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 166 | - ->setRawData($info) |
|
| 167 | - ->setSize((int)$info[ 'used_memory' ]) |
|
| 168 | - ->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.", |
|
| 165 | + ->setData(\implode(', ', \array_keys($this->itemInstances))) |
|
| 166 | + ->setRawData($info) |
|
| 167 | + ->setSize((int)$info[ 'used_memory' ]) |
|
| 168 | + ->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.", |
|
| 169 | 169 | $info[ 'redis_version' ], $date->format(DATE_RFC2822))); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | \ 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\Drivers\Redis; |
| 17 | 17 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * Check for Cross-Driver type confusion |
| 135 | 135 | */ |
| 136 | 136 | if ($item instanceof Item) { |
| 137 | - return (bool)$this->instance->del($item->getKey()); |
|
| 137 | + return (bool) $this->instance->del($item->getKey()); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -161,13 +161,13 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | // used_memory |
| 163 | 163 | $info = $this->instance->info(); |
| 164 | - $date = (new \DateTime())->setTimestamp(\time() - $info[ 'uptime_in_seconds' ]); |
|
| 164 | + $date = (new \DateTime())->setTimestamp(\time() - $info['uptime_in_seconds']); |
|
| 165 | 165 | |
| 166 | 166 | return (new DriverStatistic()) |
| 167 | 167 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 168 | 168 | ->setRawData($info) |
| 169 | - ->setSize((int)$info[ 'used_memory' ]) |
|
| 169 | + ->setSize((int) $info['used_memory']) |
|
| 170 | 170 | ->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.", |
| 171 | - $info[ 'redis_version' ], $date->format(DATE_RFC2822))); |
|
| 171 | + $info['redis_version'], $date->format(DATE_RFC2822))); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | \ 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; |
| 17 | 17 | |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | * due to performance issue on huge |
| 77 | 77 | * loop dispatching operations |
| 78 | 78 | */ |
| 79 | - if (isset($this->events[ $eventName ])) { |
|
| 80 | - foreach ($this->events[ $eventName ] as $event) { |
|
| 79 | + if (isset($this->events[$eventName])) { |
|
| 80 | + foreach ($this->events[$eventName] as $event) { |
|
| 81 | 81 | call_user_func_array($event, $args); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | if (\strpos($name, 'on') === 0) { |
| 95 | 95 | $name = \substr($name, 2); |
| 96 | - if (\is_callable($arguments[ 0 ])) { |
|
| 97 | - if (isset($arguments[ 1 ]) && \is_string($arguments[ 0 ])) { |
|
| 98 | - $this->events[ $name ][ $arguments[ 1 ] ] = $arguments[ 0 ]; |
|
| 96 | + if (\is_callable($arguments[0])) { |
|
| 97 | + if (isset($arguments[1]) && \is_string($arguments[0])) { |
|
| 98 | + $this->events[$name][$arguments[1]] = $arguments[0]; |
|
| 99 | 99 | } else { |
| 100 | - $this->events[ $name ][] = $arguments[ 0 ]; |
|
| 100 | + $this->events[$name][] = $arguments[0]; |
|
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | - throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[ 0 ]))); |
|
| 103 | + throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[0]))); |
|
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | 106 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function unbindEventCallback($eventName, $callbackName): bool |
| 116 | 116 | { |
| 117 | - $return = isset($this->events[ $eventName ][ $callbackName ]); |
|
| 118 | - unset($this->events[ $eventName ][ $callbackName ]); |
|
| 117 | + $return = isset($this->events[$eventName][$callbackName]); |
|
| 118 | + unset($this->events[$eventName][$callbackName]); |
|
| 119 | 119 | |
| 120 | 120 | return $return; |
| 121 | 121 | } |
@@ -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; |
| 17 | 17 | |
@@ -64,29 +64,29 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | static $version; |
| 66 | 66 | |
| 67 | - if($version && $cacheable){ |
|
| 67 | + if ($version && $cacheable) { |
|
| 68 | 68 | return $version; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if(\function_exists('shell_exec')){ |
|
| 71 | + if (\function_exists('shell_exec')) { |
|
| 72 | 72 | $stdout = shell_exec('git describe --abbrev=0 --tags'); |
| 73 | - if(\is_string($stdout)){ |
|
| 73 | + if (\is_string($stdout)) { |
|
| 74 | 74 | $version = \trim($stdout); |
| 75 | 75 | return $version; |
| 76 | 76 | } |
| 77 | 77 | throw new PhpfastcacheLogicException('The git command used to retrieve the PhpFastCache version has failed.'); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if(!$fallbackOnChangelog){ |
|
| 80 | + if (!$fallbackOnChangelog) { |
|
| 81 | 81 | throw new PhpfastcacheLogicException('shell_exec is disabled therefore the PhpFastCache version cannot be retrieved.'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; |
| 85 | - if(\file_exists($changelogFilename)){ |
|
| 85 | + if (\file_exists($changelogFilename)) { |
|
| 86 | 86 | $versionPrefix = '## '; |
| 87 | 87 | $changelog = \explode("\n", self::getPhpFastCacheChangelog()); |
| 88 | - foreach ($changelog as $line){ |
|
| 89 | - if(\strpos($line, $versionPrefix) === 0){ |
|
| 88 | + foreach ($changelog as $line) { |
|
| 89 | + if (\strpos($line, $versionPrefix) === 0) { |
|
| 90 | 90 | $version = \trim(\str_replace($versionPrefix, '', $line)); |
| 91 | 91 | return $version; |
| 92 | 92 | } |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | static $hash; |
| 106 | 106 | |
| 107 | - if($hash && $cacheable){ |
|
| 107 | + if ($hash && $cacheable) { |
|
| 108 | 108 | return $hash; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if(\function_exists('shell_exec')){ |
|
| 111 | + if (\function_exists('shell_exec')) { |
|
| 112 | 112 | $stdout = \shell_exec('git rev-parse --short HEAD'); |
| 113 | - if(\is_string($stdout)){ |
|
| 113 | + if (\is_string($stdout)) { |
|
| 114 | 114 | $hash = \trim($stdout); |
| 115 | 115 | return "#{$hash}"; |
| 116 | 116 | } |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | public static function getChangelog(): string |
| 129 | 129 | { |
| 130 | 130 | $changelogFilename = __DIR__ . '/../../CHANGELOG_API.md'; |
| 131 | - if(\file_exists($changelogFilename)){ |
|
| 131 | + if (\file_exists($changelogFilename)) { |
|
| 132 | 132 | $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); |
| 133 | - if($string){ |
|
| 133 | + if ($string) { |
|
| 134 | 134 | return $string; |
| 135 | 135 | } |
| 136 | 136 | throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache API changelog as it seems to be empty.'); |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | public static function getPhpFastCacheChangelog(): string |
| 148 | 148 | { |
| 149 | 149 | $changelogFilename = __DIR__ . '/../../CHANGELOG.md'; |
| 150 | - if(\file_exists($changelogFilename)){ |
|
| 150 | + if (\file_exists($changelogFilename)) { |
|
| 151 | 151 | $string = \str_replace(["\r\n", "\r"], "\n", \trim(\file_get_contents($changelogFilename))); |
| 152 | - if($string){ |
|
| 152 | + if ($string) { |
|
| 153 | 153 | return $string; |
| 154 | 154 | } |
| 155 | 155 | throw new PhpfastcacheLogicException('Unable to retrieve the PhpFastCache changelog as it seems to be empty.'); |
@@ -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; |
| 17 | 17 | |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
| 106 | 106 | E_USER_DEPRECATED |
| 107 | 107 | ); |
| 108 | - }elseif ($config === null){ |
|
| 108 | + }elseif ($config === null) { |
|
| 109 | 109 | $config = self::getDefaultConfig(); |
| 110 | - }else if(!($config instanceof ConfigurationOption)){ |
|
| 110 | + } else if (!($config instanceof ConfigurationOption)) { |
|
| 111 | 111 | throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config))); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $instance = $instanceId ?: md5($driver . \serialize($config->toArray())); |
| 121 | 121 | |
| 122 | - if (!isset(self::$instances[ $instance ])) { |
|
| 123 | - $badPracticeOmeter[ $driver ] = 1; |
|
| 122 | + if (!isset(self::$instances[$instance])) { |
|
| 123 | + $badPracticeOmeter[$driver] = 1; |
|
| 124 | 124 | $driverClass = self::getNamespacePath() . $driver . '\Driver'; |
| 125 | 125 | try { |
| 126 | 126 | if (\class_exists($driverClass)) { |
| 127 | 127 | $configClass = $driverClass::getConfigClass(); |
| 128 | - self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
| 129 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
| 128 | + self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance); |
|
| 129 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
| 130 | 130 | } else { |
| 131 | 131 | throw new PhpfastcacheDriverNotFoundException(\sprintf('The driver "%s" does not exists', $driver)); |
| 132 | 132 | } |
@@ -144,14 +144,14 @@ discard block |
||
| 144 | 144 | throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | - } else if ($badPracticeOmeter[ $driver ] >= 2) { |
|
| 147 | + } else if ($badPracticeOmeter[$driver] >= 2) { |
|
| 148 | 148 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
| 149 | 149 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $badPracticeOmeter[ $driver ]++; |
|
| 152 | + $badPracticeOmeter[$driver]++; |
|
| 153 | 153 | |
| 154 | - return self::$instances[ $instance ]; |
|
| 154 | + return self::$instances[$instance]; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string'); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if (isset(self::$instances[ $instanceId ])) { |
|
| 172 | - return self::$instances[ $instanceId ]; |
|
| 171 | + if (isset(self::$instances[$instanceId])) { |
|
| 172 | + return self::$instances[$instanceId]; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId)); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if(!$autoDriver || !\is_string($autoDriver)){ |
|
| 229 | + if (!$autoDriver || !\is_string($autoDriver)) { |
|
| 230 | 230 | throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically'); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface |
| 242 | 242 | { |
| 243 | - $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []); |
|
| 243 | + $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []); |
|
| 244 | 244 | |
| 245 | 245 | return self::getInstance($name, $options); |
| 246 | 246 | } |
@@ -350,14 +350,14 @@ discard block |
||
| 350 | 350 | { |
| 351 | 351 | static $driverList; |
| 352 | 352 | |
| 353 | - if(self::getDefaultNamespacePath() === self::getNamespacePath()){ |
|
| 354 | - if($driverList === null){ |
|
| 353 | + if (self::getDefaultNamespacePath() === self::getNamespacePath()) { |
|
| 354 | + if ($driverList === null) { |
|
| 355 | 355 | $prefix = 'Phpfastcache\Drivers\\'; |
| 356 | 356 | $classMap = self::createClassMap(__DIR__ . '/Drivers'); |
| 357 | 357 | $driverList = []; |
| 358 | 358 | |
| 359 | 359 | foreach ($classMap as $class => $file) { |
| 360 | - $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') )); |
|
| 360 | + $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\'))); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $driverList = array_values(array_unique($driverList)); |
@@ -105,9 +105,9 @@ |
||
| 105 | 105 | 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
| 106 | 106 | E_USER_DEPRECATED |
| 107 | 107 | ); |
| 108 | - }elseif ($config === null){ |
|
| 108 | + } elseif ($config === null){ |
|
| 109 | 109 | $config = self::getDefaultConfig(); |
| 110 | - }else if(!($config instanceof ConfigurationOption)){ |
|
| 110 | + } else if(!($config instanceof ConfigurationOption)){ |
|
| 111 | 111 | throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config))); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | use Phpfastcache\Config\ConfigurationOption; |
| 19 | 19 | use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface; |
| 20 | 20 | use Phpfastcache\Exceptions\{ |
| 21 | - PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException |
|
| 21 | + PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException |
|
| 22 | 22 | }; |
| 23 | 23 | use Phpfastcache\Util\ClassNamespaceResolverTrait; |
| 24 | 24 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | if (\is_array($config)) { |
| 103 | 103 | $config = new ConfigurationOption($config); |
| 104 | 104 | trigger_error( |
| 105 | - 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
| 106 | - E_USER_DEPRECATED |
|
| 105 | + 'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead', |
|
| 106 | + E_USER_DEPRECATED |
|
| 107 | 107 | ); |
| 108 | 108 | }elseif ($config === null){ |
| 109 | 109 | $config = self::getDefaultConfig(); |
@@ -304,27 +304,27 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED); |
| 306 | 306 | return [ |
| 307 | - 'Apc', |
|
| 308 | - 'Apcu', |
|
| 309 | - 'Cassandra', |
|
| 310 | - 'Couchbase', |
|
| 311 | - 'Couchdb', |
|
| 312 | - 'Devnull', |
|
| 313 | - 'Files', |
|
| 314 | - 'Leveldb', |
|
| 315 | - 'Memcache', |
|
| 316 | - 'Memcached', |
|
| 317 | - 'Memstatic', |
|
| 318 | - 'Mongodb', |
|
| 319 | - 'Predis', |
|
| 320 | - 'Redis', |
|
| 321 | - 'Riak', |
|
| 322 | - 'Ssdb', |
|
| 323 | - 'Sqlite', |
|
| 324 | - 'Wincache', |
|
| 325 | - 'Xcache', |
|
| 326 | - 'Zenddisk', |
|
| 327 | - 'Zendshm', |
|
| 307 | + 'Apc', |
|
| 308 | + 'Apcu', |
|
| 309 | + 'Cassandra', |
|
| 310 | + 'Couchbase', |
|
| 311 | + 'Couchdb', |
|
| 312 | + 'Devnull', |
|
| 313 | + 'Files', |
|
| 314 | + 'Leveldb', |
|
| 315 | + 'Memcache', |
|
| 316 | + 'Memcached', |
|
| 317 | + 'Memstatic', |
|
| 318 | + 'Mongodb', |
|
| 319 | + 'Predis', |
|
| 320 | + 'Redis', |
|
| 321 | + 'Riak', |
|
| 322 | + 'Ssdb', |
|
| 323 | + 'Sqlite', |
|
| 324 | + 'Wincache', |
|
| 325 | + 'Xcache', |
|
| 326 | + 'Zenddisk', |
|
| 327 | + 'Zendshm', |
|
| 328 | 328 | ]; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | { |
| 337 | 337 | trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED); |
| 338 | 338 | return \array_merge(self::getStaticSystemDrivers(), [ |
| 339 | - 'Devtrue', |
|
| 340 | - 'Devfalse', |
|
| 341 | - 'Cookie', |
|
| 339 | + 'Devtrue', |
|
| 340 | + 'Devfalse', |
|
| 341 | + 'Cookie', |
|
| 342 | 342 | ]); |
| 343 | 343 | } |
| 344 | 344 | |
@@ -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()) { |
@@ -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 | |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | ]; |
| 170 | 170 | |
| 171 | 171 | if ($this->getConfig()->isItemDetailedDate()) { |
| 172 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
| 172 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
| 173 | 173 | /** |
| 174 | 174 | * If the creation date exists |
| 175 | 175 | * reuse it else set a new Date |
| 176 | 176 | */ |
| 177 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
| 177 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
| 178 | 178 | } else { |
| 179 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
| 180 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
| 179 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
| 180 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $wrap; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function driverUnwrapData(array $wrapper) |
| 191 | 191 | { |
| 192 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
| 192 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function driverUnwrapTags(array $wrapper) |
| 200 | 200 | { |
| 201 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
| 201 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function driverUnwrapEdate(array $wrapper) |
| 210 | 210 | { |
| 211 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
| 211 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function driverUnwrapCdate(array $wrapper) |
| 219 | 219 | { |
| 220 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
| 220 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public function driverUnwrapMdate(array $wrapper) |
| 229 | 229 | { |
| 230 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
| 230 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * that has slow performances |
| 285 | 285 | */ |
| 286 | 286 | |
| 287 | - $tagsItem->set(array_merge((array)$data, [$item->getKey() => $expTimestamp])); |
|
| 287 | + $tagsItem->set(array_merge((array) $data, [$item->getKey() => $expTimestamp])); |
|
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | 290 | * Set the expiration date |
@@ -306,9 +306,9 @@ discard block |
||
| 306 | 306 | $tagsItems = $this->getItems($this->getTagKeys($item->getRemovedTags())); |
| 307 | 307 | |
| 308 | 308 | foreach ($tagsItems as $tagsItem) { |
| 309 | - $data = (array)$tagsItem->get(); |
|
| 309 | + $data = (array) $tagsItem->get(); |
|
| 310 | 310 | |
| 311 | - unset($data[ $item->getKey() ]); |
|
| 311 | + unset($data[$item->getKey()]); |
|
| 312 | 312 | $tagsItem->set($data); |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | public static function getConfigClass(): string |
| 390 | 390 | { |
| 391 | 391 | $localConfigClass = substr(static::class, 0, strrpos(static::class, '\\')) . '\Config'; |
| 392 | - if(\class_exists($localConfigClass) && is_a($localConfigClass, ConfigurationOption::class, true)){ |
|
| 392 | + if (\class_exists($localConfigClass) && is_a($localConfigClass, ConfigurationOption::class, true)) { |
|
| 393 | 393 | return $localConfigClass; |
| 394 | 394 | } |
| 395 | 395 | 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 |
@@ -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->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 |