@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function printNewLine($count = 1) |
| 97 | 97 | { |
| 98 | - for($i = 0; $i < $count; $i++){ |
|
| 98 | + for ($i = 0; $i < $count; $i++) { |
|
| 99 | 99 | print PHP_EOL; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function printText($string, $strtoupper = false) |
| 111 | 111 | { |
| 112 | - if(!$strtoupper){ |
|
| 112 | + if (!$strtoupper) { |
|
| 113 | 113 | print trim($string) . PHP_EOL; |
| 114 | - }else{ |
|
| 114 | + } else { |
|
| 115 | 115 | print strtoupper(trim($string) . PHP_EOL); |
| 116 | 116 | } |
| 117 | 117 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function runAsyncProcess($cmd) |
| 125 | 125 | { |
| 126 | - if (substr(php_uname(), 0, 7) === 'Windows'){ |
|
| 127 | - pclose(popen('start /B '. $cmd, 'r')); |
|
| 126 | + if (substr(php_uname(), 0, 7) === 'Windows') { |
|
| 127 | + pclose(popen('start /B ' . $cmd, 'r')); |
|
| 128 | 128 | } |
| 129 | 129 | else { |
| 130 | 130 | exec($cmd . ' > /dev/null &'); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function getItem($key) |
| 63 | 63 | { |
| 64 | 64 | if (is_string($key)) { |
| 65 | - if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)){ |
|
| 65 | + if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) { |
|
| 66 | 66 | throw new phpFastCacheInvalidArgumentException('Unsupported key character detected: "' . $matches[1] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
| 67 | 67 | } |
| 68 | 68 | if (!array_key_exists($key, $this->itemInstances)) { |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | $driverArray = $this->driverRead($item); |
| 82 | 82 | |
| 83 | 83 | if ($driverArray) { |
| 84 | - if(!is_array($driverArray)){ |
|
| 84 | + if (!is_array($driverArray)) { |
|
| 85 | 85 | throw new phpFastCacheCoreException(sprintf('The driverRead method returned an unexpected variable type: %s', gettype($driverArray))); |
| 86 | 86 | } |
| 87 | 87 | $driverData = $this->driverUnwrapData($driverArray); |
| 88 | 88 | |
| 89 | - if($this->getConfig()[ 'preventCacheSlams' ]){ |
|
| 90 | - while($driverData instanceof ItemBatch) { |
|
| 91 | - if($driverData->getItemDate()->getTimestamp() + $this->getConfig()[ 'cacheSlamsTimeout' ] < time()){ |
|
| 89 | + if ($this->getConfig()['preventCacheSlams']) { |
|
| 90 | + while ($driverData instanceof ItemBatch) { |
|
| 91 | + if ($driverData->getItemDate()->getTimestamp() + $this->getConfig()['cacheSlamsTimeout'] < time()) { |
|
| 92 | 92 | /** |
| 93 | 93 | * The timeout has been reached |
| 94 | 94 | * Consider that the batch has |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $item->set($driverData); |
| 121 | 121 | $item->expiresAt($this->driverUnwrapEdate($driverArray)); |
| 122 | 122 | |
| 123 | - if($this->config['itemDetailedDate']){ |
|
| 123 | + if ($this->config['itemDetailedDate']) { |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * If the itemDetailedDate has been |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | * Reset the Item |
| 149 | 149 | */ |
| 150 | 150 | $item->set(null) |
| 151 | - ->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])) |
|
| 151 | + ->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])) |
|
| 152 | 152 | ->setHit(false) |
| 153 | 153 | ->setTags([]); |
| 154 | - if($this->config['itemDetailedDate']){ |
|
| 154 | + if ($this->config['itemDetailedDate']) { |
|
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * If the itemDetailedDate has been |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | } else { |
| 165 | 165 | $item->setHit(true); |
| 166 | 166 | } |
| 167 | - }else{ |
|
| 168 | - $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
|
| 167 | + } else { |
|
| 168 | + $item->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | * @param $this ExtendedCacheItemPoolInterface |
| 179 | 179 | * @param $this ExtendedCacheItemInterface |
| 180 | 180 | */ |
| 181 | - $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[ $key ]); |
|
| 181 | + $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[$key]); |
|
| 182 | 182 | |
| 183 | - return $this->itemInstances[ $key ]; |
|
| 183 | + return $this->itemInstances[$key]; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | public function setItem(CacheItemInterface $item) |
| 192 | 192 | { |
| 193 | 193 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
| 194 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 194 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 195 | 195 | |
| 196 | 196 | return $this; |
| 197 | 197 | } else { |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | $collection = []; |
| 210 | 210 | foreach ($keys as $key) { |
| 211 | - $collection[ $key ] = $this->getItem($key); |
|
| 211 | + $collection[$key] = $this->getItem($key); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return $collection; |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | * @var ExtendedCacheItemInterface $item |
| 306 | 306 | */ |
| 307 | 307 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
| 308 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 309 | - } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 308 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 309 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
| 310 | 310 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | $this->eventManager->dispatch('CacheSaveItem', $this, $item); |
| 319 | 319 | |
| 320 | 320 | |
| 321 | - if($this->getConfig()[ 'preventCacheSlams' ]){ |
|
| 321 | + if ($this->getConfig()['preventCacheSlams']) { |
|
| 322 | 322 | /** |
| 323 | 323 | * @var $itemBatch ExtendedCacheItemInterface |
| 324 | 324 | */ |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $itemBatch = $class->newInstanceArgs([$this, $item->getKey()]); |
| 327 | 327 | $itemBatch->setEventManager($this->eventManager) |
| 328 | 328 | ->set(new ItemBatch($item->getKey(), new \DateTime())) |
| 329 | - ->expiresAfter($this->getConfig()[ 'cacheSlamsTimeout' ]); |
|
| 329 | + ->expiresAfter($this->getConfig()['cacheSlamsTimeout']); |
|
| 330 | 330 | |
| 331 | 331 | /** |
| 332 | 332 | * To avoid SPL mismatches |
@@ -358,8 +358,8 @@ discard block |
||
| 358 | 358 | public function saveDeferred(CacheItemInterface $item) |
| 359 | 359 | { |
| 360 | 360 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
| 361 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 362 | - }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 361 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 362 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
| 363 | 363 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
| 364 | 364 | } |
| 365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | */ |
| 371 | 371 | $this->eventManager->dispatch('CacheSaveDeferredItem', $this, $item); |
| 372 | 372 | |
| 373 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
| 373 | + return $this->deferredList[$item->getKey()] = $item; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | foreach ($this->deferredList as $key => $item) { |
| 391 | 391 | $result = $this->save($item); |
| 392 | 392 | if ($return !== false) { |
| 393 | - unset($this->deferredList[ $key ]); |
|
| 393 | + unset($this->deferredList[$key]); |
|
| 394 | 394 | $return = $result; |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -39,10 +39,10 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function __construct($itemKey, \DateTime $itemDate) |
| 41 | 41 | { |
| 42 | - if(is_string($itemKey)){ |
|
| 42 | + if (is_string($itemKey)) { |
|
| 43 | 43 | $this->itemKey = $itemKey; |
| 44 | 44 | $this->itemDate = $itemDate; |
| 45 | - }else{ |
|
| 45 | + } else { |
|
| 46 | 46 | throw new phpFastCacheInvalidArgumentException(sprintf('$itemKey must be a string, got "%s" instead', gettype($itemKey))); |
| 47 | 47 | } |
| 48 | 48 | } |