@@ -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\Item; |
| 17 | 17 | |
@@ -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,8 +459,8 @@ 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 | - return (array)$info; |
|
| 464 | + return (array) $info; |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | \ 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\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; |
@@ -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 |
@@ -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 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @author Georges.L (Geolim4) <[email protected]> |
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | -declare(strict_types=1); |
|
| 15 | +declare(strict_types = 1); |
|
| 16 | 16 | |
| 17 | 17 | namespace Phpfastcache\Drivers\Predis; |
| 18 | 18 | |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | protected function driverConnect(): bool |
| 57 | 57 | { |
| 58 | - if(!empty($this->getConfig()->getPath())){ |
|
| 58 | + if (!empty($this->getConfig()->getPath())) { |
|
| 59 | 59 | $this->instance = new PredisClient([ |
| 60 | 60 | 'scheme' => 'unix', |
| 61 | 61 | 'path' => $this->getConfig()->getPath() |
| 62 | 62 | ]); |
| 63 | - }else{ |
|
| 63 | + } else { |
|
| 64 | 64 | $this->instance = new PredisClient($this->getConfig()->getPredisConfigArray()); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @see https://redis.io/commands/expire |
| 107 | 107 | */ |
| 108 | 108 | if ($ttl <= 0) { |
| 109 | - return (bool)$this->instance->expire($item->getKey(), 0); |
|
| 109 | + return (bool) $this->instance->expire($item->getKey(), 0); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item)))->getPayload() === 'OK'; |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | public function getStats(): DriverStatistic |
| 167 | 167 | { |
| 168 | 168 | $info = $this->instance->info(); |
| 169 | - $size = (isset($info[ 'Memory' ][ 'used_memory' ]) ? $info[ 'Memory' ][ 'used_memory' ] : 0); |
|
| 170 | - $version = (isset($info[ 'Server' ][ 'redis_version' ]) ? $info[ 'Server' ][ 'redis_version' ] : 0); |
|
| 171 | - $date = (isset($info[ 'Server' ][ 'uptime_in_seconds' ]) ? (new \DateTime())->setTimestamp(\time() - $info[ 'Server' ][ 'uptime_in_seconds' ]) : 'unknown date'); |
|
| 169 | + $size = (isset($info['Memory']['used_memory']) ? $info['Memory']['used_memory'] : 0); |
|
| 170 | + $version = (isset($info['Server']['redis_version']) ? $info['Server']['redis_version'] : 0); |
|
| 171 | + $date = (isset($info['Server']['uptime_in_seconds']) ? (new \DateTime())->setTimestamp(\time() - $info['Server']['uptime_in_seconds']) : 'unknown date'); |
|
| 172 | 172 | |
| 173 | 173 | return (new DriverStatistic()) |
| 174 | 174 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
@@ -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\Memcache; |
| 17 | 17 | |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | /** |
| 90 | 90 | * If path is provided we consider it as an UNIX Socket |
| 91 | 91 | */ |
| 92 | - if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
|
| 92 | + if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) { |
|
| 93 | 93 | $this->fallback = true; |
| 94 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
| 94 | + } else if (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) { |
|
| 95 | 95 | $this->fallback = true; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if (!empty($server[ 'saslUser' ]) && !empty($server[ 'saslPassword' ])) { |
|
| 98 | + if (!empty($server['saslUser']) && !empty($server['saslPassword'])) { |
|
| 99 | 99 | throw new PhpfastcacheDriverException('Unlike Memcached, Memcache does not support SASL authentication'); |
| 100 | 100 | } |
| 101 | 101 | } catch (\Exception $e) { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * Since Memcached does not throw |
| 107 | 107 | * any error if not connected ... |
| 108 | 108 | */ |
| 109 | - if(!$this->instance->getServerStatus(!empty($server[ 'path' ]) ? $server[ 'path' ] : $server[ 'host' ], !empty($server[ 'port' ]) ? $server[ 'port' ] : 0)){ |
|
| 109 | + if (!$this->instance->getServerStatus(!empty($server['path']) ? $server['path'] : $server['host'], !empty($server['port']) ? $server['port'] : 0)) { |
|
| 110 | 110 | throw new PhpfastcacheDriverException('Memcache seems to not be connected'); |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -189,17 +189,17 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | public function getStats(): DriverStatistic |
| 191 | 191 | { |
| 192 | - $stats = (array)$this->instance->getstats(); |
|
| 193 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
| 194 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
| 195 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
| 192 | + $stats = (array) $this->instance->getstats(); |
|
| 193 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
| 194 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
| 195 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
| 196 | 196 | |
| 197 | - $date = (new \DateTime())->setTimestamp(\time() - $stats[ 'uptime' ]); |
|
| 197 | + $date = (new \DateTime())->setTimestamp(\time() - $stats['uptime']); |
|
| 198 | 198 | |
| 199 | 199 | return (new DriverStatistic()) |
| 200 | 200 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 201 | - ->setInfo(\sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 201 | + ->setInfo(\sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
| 202 | 202 | ->setRawData($stats) |
| 203 | - ->setSize((int)$stats[ 'bytes' ]); |
|
| 203 | + ->setSize((int) $stats['bytes']); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | \ 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\Memcached; |
| 17 | 17 | |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * If path is provided we consider it as an UNIX Socket |
| 87 | 87 | */ |
| 88 | - if(!empty($server[ 'path' ]) && !$this->instance->addServer($server[ 'path' ], 0)){ |
|
| 88 | + if (!empty($server['path']) && !$this->instance->addServer($server['path'], 0)) { |
|
| 89 | 89 | $this->fallback = true; |
| 90 | - }else if (!empty($server[ 'host' ]) && !$this->instance->addServer($server[ 'host' ], $server[ 'port' ])) { |
|
| 90 | + } else if (!empty($server['host']) && !$this->instance->addServer($server['host'], $server['port'])) { |
|
| 91 | 91 | $this->fallback = true; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if (!empty($server[ 'saslUser' ]) && !empty($server[ 'saslPassword' ])) { |
|
| 95 | - $this->instance->setSaslAuthData($server[ 'saslUser' ], $server[ 'saslPassword' ]); |
|
| 94 | + if (!empty($server['saslUser']) && !empty($server['saslPassword'])) { |
|
| 95 | + $this->instance->setSaslAuthData($server['saslUser'], $server['saslPassword']); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | } catch (\Exception $e) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * any error if not connected ... |
| 106 | 106 | */ |
| 107 | 107 | $version = $this->instance->getVersion(); |
| 108 | - if(!$version || $this->instance->getResultCode() !== MemcachedSoftware::RES_SUCCESS){ |
|
| 108 | + if (!$version || $this->instance->getResultCode() !== MemcachedSoftware::RES_SUCCESS) { |
|
| 109 | 109 | throw new PhpfastcacheDriverException('Memcached seems to not be connected'); |
| 110 | 110 | } |
| 111 | 111 | return true; |
@@ -188,16 +188,16 @@ discard block |
||
| 188 | 188 | public function getStats(): DriverStatistic |
| 189 | 189 | { |
| 190 | 190 | $stats = current($this->instance->getStats()); |
| 191 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
| 192 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : $this->instance->getVersion()); |
|
| 193 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
| 191 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
| 192 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : $this->instance->getVersion()); |
|
| 193 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
| 194 | 194 | |
| 195 | - $date = (new \DateTime())->setTimestamp(\time() - $stats[ 'uptime' ]); |
|
| 195 | + $date = (new \DateTime())->setTimestamp(\time() - $stats['uptime']); |
|
| 196 | 196 | |
| 197 | 197 | return (new DriverStatistic()) |
| 198 | 198 | ->setData(\implode(', ', \array_keys($this->itemInstances))) |
| 199 | - ->setInfo(\sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
| 199 | + ->setInfo(\sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
| 200 | 200 | ->setRawData($stats) |
| 201 | - ->setSize((int)$stats[ 'bytes' ]); |
|
| 201 | + ->setSize((int) $stats['bytes']); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @author Fabio Covolo Mazzo (fabiocmazzo) <[email protected]> |
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | -declare(strict_types=1); |
|
| 15 | +declare(strict_types = 1); |
|
| 16 | 16 | |
| 17 | 17 | namespace Phpfastcache\Drivers\Mongodb; |
| 18 | 18 | |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | if ($document) { |
| 80 | 80 | $return = [ |
| 81 | - self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_DATA_WRAPPER_INDEX ]->getData()), |
|
| 82 | - self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[ self::DRIVER_TAGS_WRAPPER_INDEX ]->getData()), |
|
| 83 | - self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_EDATE_WRAPPER_INDEX ]->toDateTime()->getTimestamp()), |
|
| 81 | + self::DRIVER_DATA_WRAPPER_INDEX => $this->decode($document[self::DRIVER_DATA_WRAPPER_INDEX]->getData()), |
|
| 82 | + self::DRIVER_TAGS_WRAPPER_INDEX => $this->decode($document[self::DRIVER_TAGS_WRAPPER_INDEX]->getData()), |
|
| 83 | + self::DRIVER_EDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_EDATE_WRAPPER_INDEX]->toDateTime()->getTimestamp()), |
|
| 84 | 84 | ]; |
| 85 | 85 | |
| 86 | - if(!empty($this->getConfig()->isItemDetailedDate())){ |
|
| 86 | + if (!empty($this->getConfig()->isItemDetailedDate())) { |
|
| 87 | 87 | $return += [ |
| 88 | - self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_MDATE_WRAPPER_INDEX ]->toDateTime() |
|
| 88 | + self::DRIVER_MDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_MDATE_WRAPPER_INDEX]->toDateTime() |
|
| 89 | 89 | ->getTimestamp()), |
| 90 | - self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[ self::DRIVER_CDATE_WRAPPER_INDEX ]->toDateTime() |
|
| 90 | + self::DRIVER_CDATE_WRAPPER_INDEX => (new \DateTime())->setTimestamp($document[self::DRIVER_CDATE_WRAPPER_INDEX]->toDateTime() |
|
| 91 | 91 | ->getTimestamp()), |
| 92 | 92 | ]; |
| 93 | 93 | } |
@@ -117,13 +117,13 @@ discard block |
||
| 117 | 117 | self::DRIVER_EDATE_WRAPPER_INDEX => ($item->getTtl() > 0 ? new UTCDateTime((\time() + $item->getTtl()) * 1000) : new UTCDateTime(\time() * 1000)), |
| 118 | 118 | ]; |
| 119 | 119 | |
| 120 | - if(!empty($this->getConfig()->isItemDetailedDate())){ |
|
| 120 | + if (!empty($this->getConfig()->isItemDetailedDate())) { |
|
| 121 | 121 | $set += [ |
| 122 | 122 | self::DRIVER_MDATE_WRAPPER_INDEX => ($item->getModificationDate() ? new UTCDateTime(($item->getModificationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
| 123 | 123 | self::DRIVER_CDATE_WRAPPER_INDEX => ($item->getCreationDate() ? new UTCDateTime(($item->getCreationDate()->getTimestamp()) * 1000) : new UTCDateTime(\time() * 1000)), |
| 124 | 124 | ]; |
| 125 | 125 | } |
| 126 | - $result = (array)$this->getCollection()->updateOne( |
|
| 126 | + $result = (array) $this->getCollection()->updateOne( |
|
| 127 | 127 | ['_id' => $item->getEncodedKey()], |
| 128 | 128 | [ |
| 129 | 129 | '$set' => $set, |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | throw new PhpfastcacheDriverException('Got an exception while trying to write data to MongoDB server', null, $e); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - return isset($result[ 'ok' ]) ? $result[ 'ok' ] == 1 : true; |
|
| 137 | + return isset($result['ok']) ? $result['ok'] == 1 : true; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected'); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | $host = $this->getConfig()->getHost(); |
| 227 | 227 | $port = $this->getConfig()->getPort(); |
| 228 | 228 | $username = $this->getConfig()->getUsername(); |
| 229 | - $password = $this->getConfig()->getPassword(); |
|
| 229 | + $password = $this->getConfig()->getPassword(); |
|
| 230 | 230 | |
| 231 | 231 | return implode('', [ |
| 232 | 232 | 'mongodb://', |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | 'recordStats' => 0, |
| 264 | 264 | 'repl' => 0, |
| 265 | 265 | 'metrics' => 0, |
| 266 | - ]))->toArray()[ 0 ]; |
|
| 266 | + ]))->toArray()[0]; |
|
| 267 | 267 | |
| 268 | 268 | $collectionStats = $this->instance->getManager()->executeCommand('phpFastCache', new Command([ |
| 269 | - 'collStats' => (isset($this->getConfig()[ 'collectionName' ]) ? $this->getConfig()[ 'collectionName' ] : 'Cache'), |
|
| 269 | + 'collStats' => (isset($this->getConfig()['collectionName']) ? $this->getConfig()['collectionName'] : 'Cache'), |
|
| 270 | 270 | 'verbose' => true, |
| 271 | - ]))->toArray()[ 0 ]; |
|
| 271 | + ]))->toArray()[0]; |
|
| 272 | 272 | |
| 273 | - $array_filter_recursive = function ($array, callable $callback = null) use (&$array_filter_recursive) { |
|
| 273 | + $array_filter_recursive = function($array, callable $callback = null) use (&$array_filter_recursive) { |
|
| 274 | 274 | $array = $callback($array); |
| 275 | 275 | |
| 276 | 276 | if (\is_object($array) || \is_array($array)) { |
@@ -282,12 +282,12 @@ discard block |
||
| 282 | 282 | return $array; |
| 283 | 283 | }; |
| 284 | 284 | |
| 285 | - $callback = function ($item) { |
|
| 285 | + $callback = function($item) { |
|
| 286 | 286 | /** |
| 287 | 287 | * Remove unserializable properties |
| 288 | 288 | */ |
| 289 | 289 | if ($item instanceof \MongoDB\BSON\UTCDateTime) { |
| 290 | - return (string)$item; |
|
| 290 | + return (string) $item; |
|
| 291 | 291 | } |
| 292 | 292 | return $item; |
| 293 | 293 | }; |
@@ -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 |