@@ -106,7 +106,7 @@ |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | - * @param $cacheFile |
|
| 109 | + * @param string $cacheFile |
|
| 110 | 110 | * |
| 111 | 111 | * @return bool |
| 112 | 112 | */ |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | $this->serializer = new SerializerIgbinary(); |
| 42 | 42 | |
| 43 | 43 | if (!$cacheDir) { |
| 44 | - $cacheDir = \realpath(\sys_get_temp_dir()) . '/simple_php_cache'; |
|
| 44 | + $cacheDir = \realpath(\sys_get_temp_dir()).'/simple_php_cache'; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $this->cacheDir = (string) $cacheDir; |
|
| 47 | + $this->cacheDir = (string)$cacheDir; |
|
| 48 | 48 | |
| 49 | 49 | if ($this->createCacheDirectory($cacheDir) === true) { |
| 50 | 50 | $this->installed = true; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | protected function getFileName(string $key): string |
| 193 | 193 | { |
| 194 | - return $this->cacheDir . \DIRECTORY_SEPARATOR . self::CACHE_FILE_PREFIX . $key . self::CACHE_FILE_SUBFIX; |
|
| 194 | + return $this->cacheDir.\DIRECTORY_SEPARATOR.self::CACHE_FILE_PREFIX.$key.self::CACHE_FILE_SUBFIX; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -638,7 +638,7 @@ |
||
| 638 | 638 | * |
| 639 | 639 | * @param string $key |
| 640 | 640 | * @param mixed $value |
| 641 | - * @param \DateInterval|int|null $ttl |
|
| 641 | + * @param integer $ttl |
|
| 642 | 642 | * |
| 643 | 643 | * @throws InvalidArgumentException |
| 644 | 644 | * |
@@ -302,10 +302,10 @@ |
||
| 302 | 302 | protected function getTheDefaultPrefix(): string |
| 303 | 303 | { |
| 304 | 304 | return ($_SERVER['SERVER_NAME'] ?? '') . '_' . |
| 305 | - ($_SERVER['THEME'] ?? '') . '_' . |
|
| 306 | - ($_SERVER['STAGE'] ?? '') . '_' . |
|
| 307 | - ($_SESSION['language'] ?? '') . '_' . |
|
| 308 | - ($_SESSION['language_extra'] ?? ''); |
|
| 305 | + ($_SERVER['THEME'] ?? '') . '_' . |
|
| 306 | + ($_SERVER['STAGE'] ?? '') . '_' . |
|
| 307 | + ($_SESSION['language'] ?? '') . '_' . |
|
| 308 | + ($_SESSION['language_extra'] ?? ''); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | // test the cache, with this GET-parameter |
| 194 | 194 | if ($this->disableCacheGetParameter) { |
| 195 | - $testCache = isset($_GET[$this->disableCacheGetParameter]) ? (int) $_GET[$this->disableCacheGetParameter] : 0; |
|
| 195 | + $testCache = isset($_GET[$this->disableCacheGetParameter]) ? (int)$_GET[$this->disableCacheGetParameter] : 0; |
|
| 196 | 196 | } else { |
| 197 | 197 | $testCache = 0; |
| 198 | 198 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | } else { |
| 276 | 276 | |
| 277 | 277 | // for testing with dev-address |
| 278 | - $noDev = isset($_GET['noDev']) ? (int) $_GET['noDev'] : 0; |
|
| 278 | + $noDev = isset($_GET['noDev']) ? (int)$_GET['noDev'] : 0; |
|
| 279 | 279 | $remoteAddr = $_SERVER['REMOTE_ADDR'] ?? 'NO_REMOTE_ADDR'; |
| 280 | 280 | |
| 281 | 281 | if ( |
@@ -301,10 +301,10 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | protected function getTheDefaultPrefix(): string |
| 303 | 303 | { |
| 304 | - return ($_SERVER['SERVER_NAME'] ?? '') . '_' . |
|
| 305 | - ($_SERVER['THEME'] ?? '') . '_' . |
|
| 306 | - ($_SERVER['STAGE'] ?? '') . '_' . |
|
| 307 | - ($_SESSION['language'] ?? '') . '_' . |
|
| 304 | + return ($_SERVER['SERVER_NAME'] ?? '').'_'. |
|
| 305 | + ($_SERVER['THEME'] ?? '').'_'. |
|
| 306 | + ($_SERVER['STAGE'] ?? '').'_'. |
|
| 307 | + ($_SESSION['language'] ?? '').'_'. |
|
| 308 | 308 | ($_SESSION['language_extra'] ?? ''); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | protected function calculateStoreKey(string $rawKey): string |
| 550 | 550 | { |
| 551 | - $str = $this->getPrefix() . $rawKey; |
|
| 551 | + $str = $this->getPrefix().$rawKey; |
|
| 552 | 552 | |
| 553 | 553 | if ($this->adapter instanceof AdapterFileAbstract) { |
| 554 | 554 | $str = $this->cleanStoreKey($str); |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | // always cache the TTL time, maybe we need this later ... |
| 673 | - self::$STATIC_CACHE_EXPIRE[$storeKey] = ($ttl ? (int) $ttl + \time() : 0); |
|
| 673 | + self::$STATIC_CACHE_EXPIRE[$storeKey] = ($ttl ? (int)$ttl + \time() : 0); |
|
| 674 | 674 | |
| 675 | 675 | return $this->adapter->setExpired($storeKey, $serialized, $ttl); |
| 676 | 676 | } |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | */ |
| 75 | 75 | public function setExpired(string $key, $value, int $ttl = 0): bool |
| 76 | 76 | { |
| 77 | - return (bool) \file_put_contents( |
|
| 77 | + return (bool)\file_put_contents( |
|
| 78 | 78 | $this->getFileName($key), |
| 79 | 79 | $this->serializer->serialize( |
| 80 | 80 | [ |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function delete($key): bool |
| 32 | 32 | { |
| 33 | 33 | if (!\is_string($key)) { |
| 34 | - throw new InvalidArgumentException('$key is not a string:' . \print_r($key, true)); |
|
| 34 | + throw new InvalidArgumentException('$key is not a string:'.\print_r($key, true)); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | return $this->removeItem($key); |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | public function deleteMultiple($keys): bool |
| 50 | 50 | { |
| 51 | 51 | if (!\is_array($keys) && !($keys instanceof \Traversable)) { |
| 52 | - throw new InvalidArgumentException('$keys is not iterable:' . \print_r($keys, true)); |
|
| 52 | + throw new InvalidArgumentException('$keys is not iterable:'.\print_r($keys, true)); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $results = []; |
| 56 | - foreach ((array) $keys as $key) { |
|
| 56 | + foreach ((array)$keys as $key) { |
|
| 57 | 57 | $results = $this->delete($key); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | public function getMultiple($keys, $default = null) |
| 94 | 94 | { |
| 95 | 95 | if (!\is_array($keys) && !($keys instanceof \Traversable)) { |
| 96 | - throw new InvalidArgumentException('$keys is not iterable:' . \print_r($keys, true)); |
|
| 96 | + throw new InvalidArgumentException('$keys is not iterable:'.\print_r($keys, true)); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $result = []; |
| 100 | - foreach ((array) $keys as $key) { |
|
| 100 | + foreach ((array)$keys as $key) { |
|
| 101 | 101 | $result[$key] = $this->has($key) ? $this->get($key) : $default; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | public function has($key): bool |
| 122 | 122 | { |
| 123 | 123 | if (!\is_string($key)) { |
| 124 | - throw new InvalidArgumentException('$key is not a string:' . \print_r($key, true)); |
|
| 124 | + throw new InvalidArgumentException('$key is not a string:'.\print_r($key, true)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $this->existsItem($key); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public function set($key, $value, $ttl = null): bool |
| 144 | 144 | { |
| 145 | 145 | if (!\is_string($key)) { |
| 146 | - throw new InvalidArgumentException('$key is not a string:' . \print_r($key, true)); |
|
| 146 | + throw new InvalidArgumentException('$key is not a string:'.\print_r($key, true)); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return $this->setItem($key, $value, $ttl); |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | public function setMultiple($values, $ttl = null): bool |
| 165 | 165 | { |
| 166 | 166 | if (!\is_array($values) && !($values instanceof \Traversable)) { |
| 167 | - throw new InvalidArgumentException('$values is not iterable:' . \print_r($values, true)); |
|
| 167 | + throw new InvalidArgumentException('$values is not iterable:'.\print_r($values, true)); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $results = []; |
| 171 | - foreach ((array) $values as $key => $value) { |
|
| 171 | + foreach ((array)$values as $key => $value) { |
|
| 172 | 172 | $results = $this->set($key, $value, $ttl); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function cacheClear(string $type): bool |
| 65 | 65 | { |
| 66 | - return (bool) \apcu_clear_cache(); |
|
| 66 | + return (bool)\apcu_clear_cache(); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function exists(string $key): bool |
| 86 | 86 | { |
| 87 | - return (bool) \apcu_exists($key); |
|
| 87 | + return (bool)\apcu_exists($key); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function remove(string $key): bool |
| 114 | 114 | { |
| 115 | - return (bool) \apcu_delete($key); |
|
| 115 | + return (bool)\apcu_delete($key); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function removeAll(): bool |
| 122 | 122 | { |
| 123 | - return (bool) ($this->cacheClear('system') && $this->cacheClear('user')); |
|
| 123 | + return (bool)($this->cacheClear('system') && $this->cacheClear('user')); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function set(string $key, $value): bool |
| 130 | 130 | { |
| 131 | - return (bool) \apcu_store($key, $value); |
|
| 131 | + return (bool)\apcu_store($key, $value); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -136,6 +136,6 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function setExpired(string $key, $data, int $ttl = 0): bool |
| 138 | 138 | { |
| 139 | - return (bool) \apcu_store($key, $data, $ttl); |
|
| 139 | + return (bool)\apcu_store($key, $data, $ttl); |
|
| 140 | 140 | } |
| 141 | 141 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | protected function getFileName(string $key): string |
| 71 | 71 | { |
| 72 | - return $this->cacheDir . \DIRECTORY_SEPARATOR . self::CACHE_FILE_PREFIX . $key . '.php'; |
|
| 72 | + return $this->cacheDir.\DIRECTORY_SEPARATOR.self::CACHE_FILE_PREFIX.$key.'.php'; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | $content = \var_export($item, true); |
| 85 | 85 | |
| 86 | 86 | $content = '<?php |
| 87 | - return ' . $content . '; |
|
| 87 | + return ' . $content.'; |
|
| 88 | 88 | '; |
| 89 | 89 | |
| 90 | 90 | $cacheFile = $this->getFileName($key); |
| 91 | 91 | |
| 92 | - $result = (bool) \file_put_contents( |
|
| 92 | + $result = (bool)\file_put_contents( |
|
| 93 | 93 | $cacheFile, |
| 94 | 94 | $content, |
| 95 | 95 | 0, |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | // Make sure we are under the proper limit |
| 96 | 96 | if (\strlen($key) > 250) { |
| 97 | - throw new InvalidArgumentException('The passed cache key is over 250 bytes:' . \print_r($key, true)); |
|
| 97 | + throw new InvalidArgumentException('The passed cache key is over 250 bytes:'.\print_r($key, true)); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | return $this->memcache->set($key, $value, $this->getCompressedFlag()); |
@@ -139,6 +139,6 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function setCompressed($value) |
| 141 | 141 | { |
| 142 | - $this->compressed = (bool) $value; |
|
| 142 | + $this->compressed = (bool)$value; |
|
| 143 | 143 | } |
| 144 | 144 | } |
@@ -90,8 +90,8 @@ |
||
| 90 | 90 | public function set(string $key, $value): bool |
| 91 | 91 | { |
| 92 | 92 | // Make sure we are under the proper limit |
| 93 | - if (\strlen($this->memcached->getOption(\Memcached::OPT_PREFIX_KEY) . $key) > 250) { |
|
| 94 | - throw new InvalidArgumentException('The passed cache key is over 250 bytes:' . \print_r($key, true)); |
|
| 93 | + if (\strlen($this->memcached->getOption(\Memcached::OPT_PREFIX_KEY).$key) > 250) { |
|
| 94 | + throw new InvalidArgumentException('The passed cache key is over 250 bytes:'.\print_r($key, true)); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | return $this->memcached->set($key, $value); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function apc_cache_exists($key): bool |
| 50 | 50 | { |
| 51 | - return (bool) \apc_fetch($key); |
|
| 51 | + return (bool)\apc_fetch($key); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function cacheClear(string $type): bool |
| 65 | 65 | { |
| 66 | - return (bool) \apc_clear_cache($type); |
|
| 66 | + return (bool)\apc_clear_cache($type); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | public function exists(string $key): bool |
| 87 | 87 | { |
| 88 | 88 | if (\function_exists('apc_exists')) { |
| 89 | - return (bool) \apc_exists($key); |
|
| 89 | + return (bool)\apc_exists($key); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $this->apc_cache_exists($key); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function remove(string $key): bool |
| 119 | 119 | { |
| 120 | - return (bool) \apc_delete($key); |
|
| 120 | + return (bool)\apc_delete($key); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function removeAll(): bool |
| 127 | 127 | { |
| 128 | - return (bool) ($this->cacheClear('system') && $this->cacheClear('user')); |
|
| 128 | + return (bool)($this->cacheClear('system') && $this->cacheClear('user')); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function set(string $key, $value): bool |
| 135 | 135 | { |
| 136 | - return (bool) \apc_store($key, $value); |
|
| 136 | + return (bool)\apc_store($key, $value); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -141,6 +141,6 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function setExpired(string $key, $data, int $ttl = 0): bool |
| 143 | 143 | { |
| 144 | - return (bool) \apc_store($key, $data, $ttl); |
|
| 144 | + return (bool)\apc_store($key, $data, $ttl); |
|
| 145 | 145 | } |
| 146 | 146 | } |