@@ -334,7 +334,7 @@ |
||
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @internal This method de-register an item from $this->itemInstances |
| 337 | - * @param CacheItemInterface|string $item |
|
| 337 | + * @param CacheItemInterface $item |
|
| 338 | 338 | * @throws \InvalidArgumentException |
| 339 | 339 | */ |
| 340 | 340 | protected function deregisterItem($item) |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512) |
| 49 | 49 | { |
| 50 | - $callback = function(CacheItemInterface $item){ |
|
| 50 | + $callback = function(CacheItemInterface $item) { |
|
| 51 | 51 | return $item->get(); |
| 52 | 52 | }; |
| 53 | 53 | return json_encode(array_map($callback, array_values($this->getItems($keys))), $option, $depth); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * #headache |
| 77 | 77 | */ |
| 78 | - return array_filter($this->getItems(array_unique(array_keys($items))), function(ExtendedCacheItemInterface $item){ |
|
| 78 | + return array_filter($this->getItems(array_unique(array_keys($items))), function(ExtendedCacheItemInterface $item) { |
|
| 79 | 79 | return $item->isHit(); |
| 80 | 80 | }); |
| 81 | 81 | } else { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function getItemsByTagsAsJsonString(array $tagNames, $option = 0, $depth = 512) |
| 119 | 119 | { |
| 120 | - $callback = function(CacheItemInterface $item){ |
|
| 120 | + $callback = function(CacheItemInterface $item) { |
|
| 121 | 121 | return $item->get(); |
| 122 | 122 | }; |
| 123 | 123 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | public function detachItem(CacheItemInterface $item) |
| 304 | 304 | { |
| 305 | - if(isset($this->itemInstances[$item->getKey()])){ |
|
| 305 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
| 306 | 306 | $this->deregisterItem($item); |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -324,9 +324,9 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | public function attachItem(CacheItemInterface $item) |
| 326 | 326 | { |
| 327 | - if(isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 327 | + if (isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
| 328 | 328 | throw new \LogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.'); |
| 329 | - }else{ |
|
| 329 | + } else { |
|
| 330 | 330 | $this->itemInstances[$item->getKey()] = $item; |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | protected function deregisterItem($item) |
| 341 | 341 | { |
| 342 | - if($item instanceof CacheItemInterface){ |
|
| 343 | - unset($this->itemInstances[ $item->getKey() ]); |
|
| 342 | + if ($item instanceof CacheItemInterface) { |
|
| 343 | + unset($this->itemInstances[$item->getKey()]); |
|
| 344 | 344 | |
| 345 | - }else if(is_string($item)){ |
|
| 346 | - unset($this->itemInstances[ $item ]); |
|
| 347 | - }else{ |
|
| 345 | + } else if (is_string($item)) { |
|
| 346 | + unset($this->itemInstances[$item]); |
|
| 347 | + } else { |
|
| 348 | 348 | throw new \InvalidArgumentException('Invalid type for $item variable'); |
| 349 | 349 | } |
| 350 | - if(gc_enabled()){ |
|
| 350 | + if (gc_enabled()) { |
|
| 351 | 351 | gc_collect_cycles(); |
| 352 | 352 | } |
| 353 | 353 | } |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function isAttached(CacheItemInterface $item) |
| 365 | 365 | { |
| 366 | - if(isset($this->itemInstances[$item->getKey()])){ |
|
| 367 | - return spl_object_hash($item) === spl_object_hash($this->itemInstances[ $item->getKey() ]); |
|
| 366 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
| 367 | + return spl_object_hash($item) === spl_object_hash($this->itemInstances[$item->getKey()]); |
|
| 368 | 368 | } |
| 369 | 369 | return null; |
| 370 | 370 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | { |
| 327 | 327 | if(isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
| 328 | 328 | throw new \LogicException('The item already exists and cannot be overwritten because the Spl object hash mismatches ! You probably tried to re-attach a detached item which has been already retrieved from cache.'); |
| 329 | - }else{ |
|
| 329 | + } else{ |
|
| 330 | 330 | $this->itemInstances[$item->getKey()] = $item; |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -342,9 +342,9 @@ discard block |
||
| 342 | 342 | if($item instanceof CacheItemInterface){ |
| 343 | 343 | unset($this->itemInstances[ $item->getKey() ]); |
| 344 | 344 | |
| 345 | - }else if(is_string($item)){ |
|
| 345 | + } else if(is_string($item)){ |
|
| 346 | 346 | unset($this->itemInstances[ $item ]); |
| 347 | - }else{ |
|
| 347 | + } else{ |
|
| 348 | 348 | throw new \InvalidArgumentException('Invalid type for $item variable'); |
| 349 | 349 | } |
| 350 | 350 | if(gc_enabled()){ |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | if (!is_object($driverInstance)) { |
| 25 | 25 | echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n"; |
| 26 | 26 | $status = 1; |
| 27 | -}else if(!($driverInstance instanceof CacheItemPoolInterface)){ |
|
| 27 | +} else if (!($driverInstance instanceof CacheItemPoolInterface)) { |
|
| 28 | 28 | echo '[FAIL] CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance) . "\n"; |
| 29 | 29 | $status = 1; |
| 30 | -}else{ |
|
| 30 | +} else { |
|
| 31 | 31 | $key = 'test_attaching_detaching'; |
| 32 | 32 | |
| 33 | 33 | $itemDetached = $driverInstance->getItem($key); |
| 34 | 34 | $driverInstance->detachItem($itemDetached); |
| 35 | 35 | $itemAttached = $driverInstance->getItem($key); |
| 36 | 36 | |
| 37 | - if(!$driverInstance->isAttached($itemDetached)) |
|
| 37 | + if (!$driverInstance->isAttached($itemDetached)) |
|
| 38 | 38 | { |
| 39 | 39 | echo '[PASS] ExtendedCacheItemPoolInterface::isAttached() identified $itemDetached as being detached.' . "\n"; |
| 40 | 40 | } |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | $status = 1; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - try{ |
|
| 47 | + try { |
|
| 48 | 48 | $driverInstance->attachItem($itemDetached); |
| 49 | 49 | echo '[FAIL] ExtendedCacheItemPoolInterface::attachItem() attached $itemDetached without trowing an error.' . "\n"; |
| 50 | 50 | $status = 1; |
| 51 | - }catch(\LogicException $e){ |
|
| 51 | + } catch (\LogicException $e) { |
|
| 52 | 52 | echo '[PASS] ExtendedCacheItemPoolInterface::attachItem() failed to attach $itemDetached by trowing a LogicException exception.' . "\n"; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | if (!is_object($driverInstance)) { |
| 25 | 25 | echo '[FAIL] CacheManager::getInstance() returned an invalid variable type:' . gettype($driverInstance) . "\n"; |
| 26 | 26 | $status = 1; |
| 27 | -}else if(!($driverInstance instanceof CacheItemPoolInterface)){ |
|
| 27 | +} else if(!($driverInstance instanceof CacheItemPoolInterface)){ |
|
| 28 | 28 | echo '[FAIL] CacheManager::getInstance() returned an invalid class:' . get_class($driverInstance) . "\n"; |
| 29 | 29 | $status = 1; |
| 30 | -}else{ |
|
| 30 | +} else{ |
|
| 31 | 31 | $key = 'test_attaching_detaching'; |
| 32 | 32 | |
| 33 | 33 | $itemDetached = $driverInstance->getItem($key); |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | if(!$driverInstance->isAttached($itemDetached)) |
| 38 | 38 | { |
| 39 | 39 | echo '[PASS] ExtendedCacheItemPoolInterface::isAttached() identified $itemDetached as being detached.' . "\n"; |
| 40 | - } |
|
| 41 | - else |
|
| 40 | + } else |
|
| 42 | 41 | { |
| 43 | 42 | echo '[FAIL] ExtendedCacheItemPoolInterface::isAttached() failed to identify $itemDetached as to be detached.' . "\n"; |
| 44 | 43 | $status = 1; |
@@ -48,7 +47,7 @@ discard block |
||
| 48 | 47 | $driverInstance->attachItem($itemDetached); |
| 49 | 48 | echo '[FAIL] ExtendedCacheItemPoolInterface::attachItem() attached $itemDetached without trowing an error.' . "\n"; |
| 50 | 49 | $status = 1; |
| 51 | - }catch(\LogicException $e){ |
|
| 50 | + } catch(\LogicException $e){ |
|
| 52 | 51 | echo '[PASS] ExtendedCacheItemPoolInterface::attachItem() failed to attach $itemDetached by trowing a LogicException exception.' . "\n"; |
| 53 | 52 | } |
| 54 | 53 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $item->set($this->driverUnwrapData($driverArray)); |
| 62 | 62 | $item->expiresAt($this->driverUnwrapEdate($driverArray)); |
| 63 | 63 | |
| 64 | - if($this->config['itemDetailedDate']){ |
|
| 64 | + if ($this->config['itemDetailedDate']) { |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * If the itemDetailedDate has been |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | } else { |
| 86 | 86 | $item->setHit(true); |
| 87 | 87 | } |
| 88 | - }else{ |
|
| 89 | - $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
|
| 88 | + } else { |
|
| 89 | + $item->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | throw new \InvalidArgumentException(sprintf('$key must be a string, got type "%s" instead.', gettype($key))); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - return $this->itemInstances[ $key ]; |
|
| 97 | + return $this->itemInstances[$key]; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | public function setItem(CacheItemInterface $item) |
| 106 | 106 | { |
| 107 | 107 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
| 108 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 108 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 109 | 109 | |
| 110 | 110 | return $this; |
| 111 | 111 | } else { |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | $collection = []; |
| 124 | 124 | foreach ($keys as $key) { |
| 125 | - $collection[ $key ] = $this->getItem($key); |
|
| 125 | + $collection[$key] = $this->getItem($key); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | return $collection; |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | * @var ExtendedCacheItemInterface $item |
| 205 | 205 | */ |
| 206 | 206 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
| 207 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 208 | - } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 207 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 208 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
| 209 | 209 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -228,12 +228,12 @@ discard block |
||
| 228 | 228 | public function saveDeferred(CacheItemInterface $item) |
| 229 | 229 | { |
| 230 | 230 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
| 231 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
| 232 | - }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 231 | + $this->itemInstances[$item->getKey()] = $item; |
|
| 232 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
| 233 | 233 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
| 236 | + return $this->deferredList[$item->getKey()] = $item; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | foreach ($this->deferredList as $key => $item) { |
| 247 | 247 | $result = $this->save($item); |
| 248 | 248 | if ($return !== false) { |
| 249 | - unset($this->deferredList[ $key ]); |
|
| 249 | + unset($this->deferredList[$key]); |
|
| 250 | 250 | $return = $result; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } else { |
| 86 | 86 | $item->setHit(true); |
| 87 | 87 | } |
| 88 | - }else{ |
|
| 88 | + } else{ |
|
| 89 | 89 | $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
| 231 | 231 | $this->itemInstances[ $item->getKey() ] = $item; |
| 232 | - }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 232 | + } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
| 233 | 233 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
| 234 | 234 | } |
| 235 | 235 | |