@@ -97,7 +97,7 @@ |
||
| 97 | 97 | public function __construct(...$args) |
| 98 | 98 | { |
| 99 | 99 | parent::__construct(...$args); |
| 100 | - $array =& $this->getArray(); |
|
| 100 | + $array = & $this->getArray(); |
|
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * Detect unwanted keys and throw an exception. |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | if (!isset($this->tmp[$full_path_hash]) || (!@\file_exists($full_path) || !@\is_writable($full_path))) { |
| 106 | 106 | if (!@\file_exists($full_path)) { |
| 107 | - if (@mkdir($full_path, $this->getDefaultChmod(), true) === false && !\is_dir($full_path) ) { |
|
| 108 | - throw new PhpfastcacheIOException('The directory '.$full_path.' could not be created.'); |
|
| 107 | + if (@mkdir($full_path, $this->getDefaultChmod(), true) === false && !\is_dir($full_path)) { |
|
| 108 | + throw new PhpfastcacheIOException('The directory ' . $full_path . ' could not be created.'); |
|
| 109 | 109 | } |
| 110 | 110 | } else { |
| 111 | 111 | if (!@\is_writable($full_path)) { |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | $full_path = $full_path_tmp; |
| 118 | 118 | if (!@\file_exists($full_path)) { |
| 119 | - if(@mkdir($full_path, $this->getDefaultChmod(), true) && !\is_dir($full_path)){ |
|
| 120 | - throw new PhpfastcacheIOException('The directory '.$full_path.' could not be created.'); |
|
| 119 | + if (@mkdir($full_path, $this->getDefaultChmod(), true) && !\is_dir($full_path)) { |
|
| 120 | + throw new PhpfastcacheIOException('The directory ' . $full_path . ' could not be created.'); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | )); |
| 300 | 300 | |
| 301 | 301 | $f = \fopen($tmpFilename, 'w+b'); |
| 302 | - if(\is_resource($f)){ |
|
| 302 | + if (\is_resource($f)) { |
|
| 303 | 303 | \flock($f, \LOCK_EX); |
| 304 | 304 | $octetWritten = fwrite($f, $data); |
| 305 | 305 | \flock($f, \LOCK_UN); |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | } else { |
| 313 | 313 | $f = \fopen($file, 'w+b'); |
| 314 | - if(\is_resource($f)){ |
|
| 314 | + if (\is_resource($f)) { |
|
| 315 | 315 | $octetWritten = \fwrite($f, $data); |
| 316 | 316 | \fclose($f); |
| 317 | 317 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | */ |
| 197 | 197 | public function getStats(): DriverStatistic |
| 198 | 198 | { |
| 199 | - $stats = (array)$this->instance->getstats(); |
|
| 199 | + $stats = (array) $this->instance->getstats(); |
|
| 200 | 200 | $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
| 201 | 201 | $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
| 202 | 202 | $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
@@ -207,6 +207,6 @@ discard block |
||
| 207 | 207 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 208 | 208 | ->setInfo(\sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(\DATE_RFC2822))) |
| 209 | 209 | ->setRawData($stats) |
| 210 | - ->setSize((int)$stats['bytes']); |
|
| 210 | + ->setSize((int) $stats['bytes']); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | \ No newline at end of file |
@@ -204,6 +204,6 @@ |
||
| 204 | 204 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 205 | 205 | ->setInfo(\sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(\DATE_RFC2822))) |
| 206 | 206 | ->setRawData($stats) |
| 207 | - ->setSize((int)$stats['bytes']); |
|
| 207 | + ->setSize((int) $stats['bytes']); |
|
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | \ No newline at end of file |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | ->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
| 125 | 125 | ]; |
| 126 | 126 | } |
| 127 | - $result = (array)$this->getCollection()->updateOne( |
|
| 127 | + $result = (array) $this->getCollection()->updateOne( |
|
| 128 | 128 | ['_id' => $item->getEncodedKey()], |
| 129 | 129 | [ |
| 130 | 130 | '$set' => $set, |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | $username = $this->getConfig()->getUsername(); |
| 233 | 233 | $password = $this->getConfig()->getPassword(); |
| 234 | 234 | |
| 235 | - if( \count($servers) > 0 ){ |
|
| 236 | - $host = \array_reduce($servers, function($carry, $data){ |
|
| 237 | - $carry .= ($carry === '' ? '' : ',').$data['host'].':'.$data['port']; |
|
| 235 | + if (\count($servers) > 0) { |
|
| 236 | + $host = \array_reduce($servers, function($carry, $data) { |
|
| 237 | + $carry .= ($carry === '' ? '' : ',') . $data['host'] . ':' . $data['port']; |
|
| 238 | 238 | return $carry; |
| 239 | 239 | }, ''); |
| 240 | 240 | $port = false; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $host, |
| 249 | 249 | ($port !== 27017 && $port !== false ? ":{$port}" : ''), |
| 250 | 250 | ($databaseName ? "/{$databaseName}" : ''), |
| 251 | - (\count($options) > 0 ? '?'.\http_build_query($options) : ''), |
|
| 251 | + (\count($options) > 0 ? '?' . \http_build_query($options) : ''), |
|
| 252 | 252 | ]); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | 'verbose' => true, |
| 284 | 284 | ]))->toArray()[0]; |
| 285 | 285 | |
| 286 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
| 286 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
| 287 | 287 | $array = $callback($array); |
| 288 | 288 | |
| 289 | 289 | if (\is_object($array) || \is_array($array)) { |
@@ -295,12 +295,12 @@ discard block |
||
| 295 | 295 | return $array; |
| 296 | 296 | }; |
| 297 | 297 | |
| 298 | - $callback = function ($item) { |
|
| 298 | + $callback = function($item) { |
|
| 299 | 299 | /** |
| 300 | 300 | * Remove unserializable properties |
| 301 | 301 | */ |
| 302 | 302 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
| 303 | - return (string)$item; |
|
| 303 | + return (string) $item; |
|
| 304 | 304 | } |
| 305 | 305 | return $item; |
| 306 | 306 | }; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * Reset the Item |
| 157 | 157 | */ |
| 158 | 158 | $item->set(null) |
| 159 | - ->expiresAfter(\abs((int)$this->getConfig()['defaultTtl'])) |
|
| 159 | + ->expiresAfter(\abs((int) $this->getConfig()['defaultTtl'])) |
|
| 160 | 160 | ->setHit(false) |
| 161 | 161 | ->setTags([]); |
| 162 | 162 | if ($this->getConfig()->isItemDetailedDate()) { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $item->setHit(true); |
| 174 | 174 | } |
| 175 | 175 | } else { |
| 176 | - $item->expiresAfter(\abs((int)$this->getConfig()['defaultTtl'])); |
|
| 176 | + $item->expiresAfter(\abs((int) $this->getConfig()['defaultTtl'])); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - return (bool)$return; |
|
| 306 | + return (bool) $return; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -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 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function getItemsByTagsAsJsonString(array $tagNames, $option = 0, $depth = 512): string |
| 114 | 114 | { |
| 115 | - $callback = function (CacheItemInterface $item) { |
|
| 115 | + $callback = function(CacheItemInterface $item) { |
|
| 116 | 116 | return $item->get(); |
| 117 | 117 | }; |
| 118 | 118 | |
@@ -165,7 +165,7 @@ |
||
| 165 | 165 | $fallback = $config->getFallback(); |
| 166 | 166 | $config->setFallback(''); |
| 167 | 167 | \trigger_error(\sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, |
| 168 | - $fallback), \E_USER_WARNING); |
|
| 168 | + $fallback), \E_USER_WARNING); |
|
| 169 | 169 | return self::getInstance($fallback, $config->getFallbackConfig()); |
| 170 | 170 | } catch (PhpfastcacheInvalidArgumentException $e) { |
| 171 | 171 | throw new PhpfastcacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $options = []; |
| 77 | 77 | |
| 78 | - if($this->getConfig()->getOptPrefix()){ |
|
| 78 | + if ($this->getConfig()->getOptPrefix()) { |
|
| 79 | 79 | $options['prefix'] = $this->getConfig()->getOptPrefix(); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @see https://redis.io/commands/expire |
| 132 | 132 | */ |
| 133 | 133 | if ($ttl <= 0) { |
| 134 | - return (bool)$this->instance->expire($item->getKey(), 0); |
|
| 134 | + return (bool) $this->instance->expire($item->getKey(), 0); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload() === 'OK'; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * Check for Cross-Driver type confusion |
| 152 | 152 | */ |
| 153 | 153 | if ($item instanceof Item) { |
| 154 | - return (bool)$this->instance->del([$item->getKey()]); |
|
| 154 | + return (bool) $this->instance->del([$item->getKey()]); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | return (new DriverStatistic()) |
| 199 | 199 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 200 | 200 | ->setRawData($info) |
| 201 | - ->setSize((int)$size) |
|
| 201 | + ->setSize((int) $size) |
|
| 202 | 202 | ->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.", |
| 203 | 203 | $version, $date->format(\DATE_RFC2822))); |
| 204 | 204 | } |