@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * due to performance issue on huge |
76 | 76 | * loop dispatching operations |
77 | 77 | */ |
78 | - if (isset($this->events[ $eventName ])) { |
|
79 | - foreach ($this->events[ $eventName ] as $event) { |
|
78 | + if (isset($this->events[$eventName])) { |
|
79 | + foreach ($this->events[$eventName] as $event) { |
|
80 | 80 | call_user_func_array($event, $args); |
81 | 81 | } |
82 | 82 | } |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | { |
93 | 93 | if (strpos($name, 'on') === 0) { |
94 | 94 | $name = substr($name, 2); |
95 | - if (is_callable($arguments[ 0 ])) { |
|
96 | - if (isset($arguments[ 1 ]) && is_string($arguments[ 0 ])) { |
|
97 | - $this->events[ $name ][ $arguments[ 1 ] ] = $arguments[ 0 ]; |
|
95 | + if (is_callable($arguments[0])) { |
|
96 | + if (isset($arguments[1]) && is_string($arguments[0])) { |
|
97 | + $this->events[$name][$arguments[1]] = $arguments[0]; |
|
98 | 98 | } else { |
99 | - $this->events[ $name ][] = $arguments[ 0 ]; |
|
99 | + $this->events[$name][] = $arguments[0]; |
|
100 | 100 | } |
101 | 101 | } else { |
102 | - throw new phpFastCacheInvalidArgumentException(sprintf('Expected Callable, got "%s"', gettype($arguments[ 0 ]))); |
|
102 | + throw new phpFastCacheInvalidArgumentException(sprintf('Expected Callable, got "%s"', gettype($arguments[0]))); |
|
103 | 103 | } |
104 | 104 | } else { |
105 | 105 | throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"'); |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function unbindEventCallback($eventName, $callbackName) |
115 | 115 | { |
116 | - if (isset($this->events[ $eventName ][ $callbackName ])) { |
|
117 | - unset($this->events[ $eventName ][ $callbackName ]); |
|
116 | + if (isset($this->events[$eventName][$callbackName])) { |
|
117 | + unset($this->events[$eventName][$callbackName]); |
|
118 | 118 | return true; |
119 | 119 | } |
120 | 120 | return false; |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | protected static function cleanFileName($filename) |
192 | 192 | { |
193 | 193 | $regex = [ |
194 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
195 | - '/\.$/', |
|
196 | - '/^\./', |
|
194 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
195 | + '/\.$/', |
|
196 | + '/^\./', |
|
197 | 197 | ]; |
198 | 198 | $replace = ['-', '', '']; |
199 | 199 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
290 | 290 | str_shuffle(uniqid($this->getDriverName(), false)) |
291 | 291 | . str_shuffle(uniqid($this->getDriverName(), false)) |
292 | - )); |
|
292 | + )); |
|
293 | 293 | |
294 | 294 | $f = fopen($tmpFilename, 'w+'); |
295 | 295 | flock($f, LOCK_EX); |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | } |
332 | 332 | |
333 | 333 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
334 | - ->setRawData([ |
|
334 | + ->setRawData([ |
|
335 | 335 | 'tmp' => $this->tmp, |
336 | - ]) |
|
337 | - ->setSize(Directory::dirSize($path)) |
|
338 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
336 | + ]) |
|
337 | + ->setSize(Directory::dirSize($path)) |
|
338 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
339 | 339 | |
340 | 340 | return $stat; |
341 | 341 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | * Calculate the security key |
52 | 52 | */ |
53 | 53 | { |
54 | - $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
|
54 | + $securityKey = array_key_exists('securityKey', $this->config) ? $this->config['securityKey'] : ''; |
|
55 | 55 | if (!$securityKey || $securityKey === 'auto') { |
56 | - if (isset($_SERVER[ 'HTTP_HOST' ])) { |
|
57 | - $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
|
56 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
57 | + $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER['HTTP_HOST']))); |
|
58 | 58 | } else { |
59 | 59 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
60 | 60 | } |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | $tmp_dir = rtrim($tmp_dir, '/') . DIRECTORY_SEPARATOR; |
75 | 75 | |
76 | - if (empty($this->config[ 'path' ]) || !is_string($this->config[ 'path' ])) { |
|
76 | + if (empty($this->config['path']) || !is_string($this->config['path'])) { |
|
77 | 77 | $path = $tmp_dir; |
78 | 78 | } else { |
79 | - $path = rtrim($this->config[ 'path' ], '/') . DIRECTORY_SEPARATOR; |
|
79 | + $path = rtrim($this->config['path'], '/') . DIRECTORY_SEPARATOR; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $path_suffix = $securityKey . DIRECTORY_SEPARATOR . $this->getDriverName(); |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | * return the temp dir |
92 | 92 | */ |
93 | 93 | if ($readonly === true) { |
94 | - if ($this->config[ 'autoTmpFallback' ] && (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
94 | + if ($this->config['autoTmpFallback'] && (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
95 | 95 | return $full_path_tmp; |
96 | 96 | } |
97 | 97 | return $full_path; |
98 | 98 | } else { |
99 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
99 | + if (!isset($this->tmp[$full_path_hash]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
100 | 100 | if (!@file_exists($full_path)) { |
101 | 101 | @mkdir($full_path, $this->getDefaultChmod(), true); |
102 | 102 | } else if (!@is_writable($full_path)) { |
103 | - if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config[ 'autoTmpFallback' ]) { |
|
103 | + if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config['autoTmpFallback']) { |
|
104 | 104 | /** |
105 | 105 | * Switch back to tmp dir |
106 | 106 | * again if the path is not writable |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | 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 !'); |
122 | 122 | } |
123 | 123 | |
124 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
125 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
124 | + $this->tmp[$full_path_hash] = $full_path; |
|
125 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - return $path . '/' . $filename . '.' . $this->config[ 'cacheFileExtension' ]; |
|
162 | + return $path . '/' . $filename . '.' . $this->config['cacheFileExtension']; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | */ |
178 | 178 | protected function getDefaultChmod() |
179 | 179 | { |
180 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
180 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
181 | 181 | return 0777; |
182 | 182 | } else { |
183 | - return $this->config[ 'default_chmod' ]; |
|
183 | + return $this->config['default_chmod']; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function getItemsAsJsonString(array $keys = [], $option = 0, $depth = 512) |
32 | 32 | { |
33 | - $callback = function (CacheItemInterface $item) { |
|
33 | + $callback = function(CacheItemInterface $item) { |
|
34 | 34 | return $item->get(); |
35 | 35 | }; |
36 | 36 | return json_encode(array_map($callback, array_values($this->getItems($keys))), $option, $depth); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | if (is_string($tagName)) { |
45 | 45 | $driverResponse = $this->getItem($this->getTagKey($tagName)); |
46 | 46 | if ($driverResponse->isHit()) { |
47 | - $items = (array)$driverResponse->get(); |
|
47 | + $items = (array) $driverResponse->get(); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * getItems() may provides expired item(s) |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * #headache |
58 | 58 | */ |
59 | - return array_filter($this->getItems(array_unique(array_keys($items))), function (ExtendedCacheItemInterface $item) { |
|
59 | + return array_filter($this->getItems(array_unique(array_keys($items))), function(ExtendedCacheItemInterface $item) { |
|
60 | 60 | return $item->isHit(); |
61 | 61 | }); |
62 | 62 | } else { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | foreach ($items as $key => $item) { |
96 | 96 | if (array_diff($tagNames, $item->getTags())) { |
97 | - unset($items[ $key ]); |
|
97 | + unset($items[$key]); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function getItemsByTagsAsJsonString(array $tagNames, $option = 0, $depth = 512) |
109 | 109 | { |
110 | - $callback = function (CacheItemInterface $item) { |
|
110 | + $callback = function(CacheItemInterface $item) { |
|
111 | 111 | return $item->get(); |
112 | 112 | }; |
113 | 113 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function detachItem(CacheItemInterface $item) |
380 | 380 | { |
381 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
381 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
382 | 382 | $this->deregisterItem($item); |
383 | 383 | } |
384 | 384 | } |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | */ |
399 | 399 | public function attachItem(CacheItemInterface $item) |
400 | 400 | { |
401 | - if (isset($this->itemInstances[ $item->getKey() ]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
401 | + if (isset($this->itemInstances[$item->getKey()]) && spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
402 | 402 | throw new phpFastCacheLogicException('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.'); |
403 | 403 | } else { |
404 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
404 | + $this->itemInstances[$item->getKey()] = $item; |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | protected function deregisterItem($item) |
415 | 415 | { |
416 | 416 | if ($item instanceof CacheItemInterface) { |
417 | - unset($this->itemInstances[ $item->getKey() ]); |
|
417 | + unset($this->itemInstances[$item->getKey()]); |
|
418 | 418 | |
419 | 419 | } else if (is_string($item)) { |
420 | - unset($this->itemInstances[ $item ]); |
|
420 | + unset($this->itemInstances[$item]); |
|
421 | 421 | } else { |
422 | 422 | throw new phpFastCacheInvalidArgumentException('Invalid type for $item variable'); |
423 | 423 | } |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | */ |
437 | 437 | public function isAttached(CacheItemInterface $item) |
438 | 438 | { |
439 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
440 | - return spl_object_hash($item) === spl_object_hash($this->itemInstances[ $item->getKey() ]); |
|
439 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
440 | + return spl_object_hash($item) === spl_object_hash($this->itemInstances[$item->getKey()]); |
|
441 | 441 | } |
442 | 442 | return null; |
443 | 443 | } |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | */ |
458 | 458 | public function saveMultiple(...$items) |
459 | 459 | { |
460 | - if (isset($items[ 0 ]) && is_array($items[ 0 ])) { |
|
461 | - foreach ($items[ 0 ] as $item) { |
|
460 | + if (isset($items[0]) && is_array($items[0])) { |
|
461 | + foreach ($items[0] as $item) { |
|
462 | 462 | $this->save($item); |
463 | 463 | } |
464 | 464 | return true; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | if ($driverArray) { |
90 | 90 | if (!is_array($driverArray)) { |
91 | 91 | throw new phpFastCacheCoreException(sprintf('The driverRead method returned an unexpected variable type: %s', |
92 | - gettype($driverArray))); |
|
92 | + gettype($driverArray))); |
|
93 | 93 | } |
94 | 94 | $driverData = $this->driverUnwrapData($driverArray); |
95 | 95 | |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * Reset the Item |
156 | 156 | */ |
157 | 157 | $item->set(null) |
158 | - ->expiresAfter(abs((int)$this->getConfig()[ 'defaultTtl' ])) |
|
159 | - ->setHit(false) |
|
160 | - ->setTags([]); |
|
158 | + ->expiresAfter(abs((int)$this->getConfig()[ 'defaultTtl' ])) |
|
159 | + ->setHit(false) |
|
160 | + ->setTags([]); |
|
161 | 161 | if ($this->config[ 'itemDetailedDate' ]) { |
162 | 162 | |
163 | 163 | /** |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | $class = new \ReflectionClass((new \ReflectionObject($this))->getNamespaceName() . '\Item'); |
337 | 337 | $itemBatch = $class->newInstanceArgs([$this, $item->getKey()]); |
338 | 338 | $itemBatch->setEventManager($this->eventManager) |
339 | - ->set(new ItemBatch($item->getKey(), new \DateTime())) |
|
340 | - ->expiresAfter($this->getConfig()[ 'cacheSlamsTimeout' ]); |
|
339 | + ->set(new ItemBatch($item->getKey(), new \DateTime())) |
|
340 | + ->expiresAfter($this->getConfig()[ 'cacheSlamsTimeout' ]); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * To avoid SPL mismatches |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * due to performance issue on huge |
69 | 69 | * loop dispatching operations |
70 | 70 | */ |
71 | - if (!isset($this->itemInstances[ $key ])) { |
|
71 | + if (!isset($this->itemInstances[$key])) { |
|
72 | 72 | if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) { |
73 | - throw new phpFastCacheInvalidArgumentException('Unsupported key character detected: "' . $matches[ 1 ] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
|
73 | + throw new phpFastCacheInvalidArgumentException('Unsupported key character detected: "' . $matches[1] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | } |
94 | 94 | $driverData = $this->driverUnwrapData($driverArray); |
95 | 95 | |
96 | - if ($this->getConfig()[ 'preventCacheSlams' ]) { |
|
96 | + if ($this->getConfig()['preventCacheSlams']) { |
|
97 | 97 | while ($driverData instanceof ItemBatch) { |
98 | - if ($driverData->getItemDate()->getTimestamp() + $this->getConfig()[ 'cacheSlamsTimeout' ] < time()) { |
|
98 | + if ($driverData->getItemDate()->getTimestamp() + $this->getConfig()['cacheSlamsTimeout'] < time()) { |
|
99 | 99 | /** |
100 | 100 | * The timeout has been reached |
101 | 101 | * Consider that the batch has |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $item->set($driverData); |
128 | 128 | $item->expiresAt($this->driverUnwrapEdate($driverArray)); |
129 | 129 | |
130 | - if ($this->config[ 'itemDetailedDate' ]) { |
|
130 | + if ($this->config['itemDetailedDate']) { |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * If the itemDetailedDate has been |
@@ -155,10 +155,10 @@ 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 | - if ($this->config[ 'itemDetailedDate' ]) { |
|
161 | + if ($this->config['itemDetailedDate']) { |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * If the itemDetailedDate has been |
@@ -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 | } else { |
@@ -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; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - return (bool)$return; |
|
300 | + return (bool) $return; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -315,9 +315,9 @@ discard block |
||
315 | 315 | * due to performance issue on huge |
316 | 316 | * loop dispatching operations |
317 | 317 | */ |
318 | - if (!isset($this->itemInstances[ $item->getKey() ])) { |
|
319 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
320 | - } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
318 | + if (!isset($this->itemInstances[$item->getKey()])) { |
|
319 | + $this->itemInstances[$item->getKey()] = $item; |
|
320 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
321 | 321 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
322 | 322 | } |
323 | 323 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $this->eventManager->dispatch('CacheSaveItem', $this, $item); |
330 | 330 | |
331 | 331 | |
332 | - if ($this->getConfig()[ 'preventCacheSlams' ]) { |
|
332 | + if ($this->getConfig()['preventCacheSlams']) { |
|
333 | 333 | /** |
334 | 334 | * @var $itemBatch ExtendedCacheItemInterface |
335 | 335 | */ |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $itemBatch = $class->newInstanceArgs([$this, $item->getKey()]); |
338 | 338 | $itemBatch->setEventManager($this->eventManager) |
339 | 339 | ->set(new ItemBatch($item->getKey(), new \DateTime())) |
340 | - ->expiresAfter($this->getConfig()[ 'cacheSlamsTimeout' ]); |
|
340 | + ->expiresAfter($this->getConfig()['cacheSlamsTimeout']); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * To avoid SPL mismatches |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | public function saveDeferred(CacheItemInterface $item) |
370 | 370 | { |
371 | 371 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
372 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
373 | - } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])) { |
|
372 | + $this->itemInstances[$item->getKey()] = $item; |
|
373 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
374 | 374 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
375 | 375 | } |
376 | 376 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | $this->eventManager->dispatch('CacheSaveDeferredItem', $this, $item); |
383 | 383 | |
384 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
384 | + return $this->deferredList[$item->getKey()] = $item; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | foreach ($this->deferredList as $key => $item) { |
402 | 402 | $result = $this->save($item); |
403 | 403 | if ($return !== false) { |
404 | - unset($this->deferredList[ $key ]); |
|
404 | + unset($this->deferredList[$key]); |
|
405 | 405 | $return = $result; |
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | - return (bool)$return; |
|
409 | + return (bool) $return; |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | \ No newline at end of file |
@@ -139,9 +139,9 @@ |
||
139 | 139 | public function driverPreWrap(ExtendedCacheItemInterface $item) |
140 | 140 | { |
141 | 141 | $wrap = [ |
142 | - self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
143 | - self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
144 | - self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
142 | + self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
143 | + self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
144 | + self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
145 | 145 | ]; |
146 | 146 | |
147 | 147 | if ($this->config[ 'itemDetailedDate' ]) { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | if (is_array($config_name)) { |
55 | 55 | $this->config = array_merge($this->config, $config_name); |
56 | 56 | } else { |
57 | - $this->config[ $config_name ] = $value; |
|
57 | + $this->config[$config_name] = $value; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function getConfigOption($optionName) |
74 | 74 | { |
75 | - if (isset($this->config[ $optionName ])) { |
|
76 | - return $this->config[ $optionName ]; |
|
75 | + if (isset($this->config[$optionName])) { |
|
76 | + return $this->config[$optionName]; |
|
77 | 77 | } else { |
78 | 78 | return null; |
79 | 79 | } |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
145 | 145 | ]; |
146 | 146 | |
147 | - if ($this->config[ 'itemDetailedDate' ]) { |
|
148 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
147 | + if ($this->config['itemDetailedDate']) { |
|
148 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
149 | 149 | /** |
150 | 150 | * If the creation date exists |
151 | 151 | * reuse it else set a new Date |
152 | 152 | */ |
153 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
153 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
154 | 154 | } else { |
155 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
156 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
155 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
156 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $wrap; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function driverUnwrapData(array $wrapper) |
167 | 167 | { |
168 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
168 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function driverUnwrapTags(array $wrapper) |
176 | 176 | { |
177 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
177 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function driverUnwrapEdate(array $wrapper) |
186 | 186 | { |
187 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
187 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function driverUnwrapCdate(array $wrapper) |
195 | 195 | { |
196 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
196 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function driverUnwrapMdate(array $wrapper) |
205 | 205 | { |
206 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
206 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * that has slow performances |
248 | 248 | */ |
249 | 249 | |
250 | - $tagsItem->set(array_merge((array)$data, [$item->getKey() => $expTimestamp])); |
|
250 | + $tagsItem->set(array_merge((array) $data, [$item->getKey() => $expTimestamp])); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Set the expiration date |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | $tagsItems = $this->getItems($this->getTagKeys($item->getRemovedTags())); |
270 | 270 | |
271 | 271 | foreach ($tagsItems as $tagsItem) { |
272 | - $data = (array)$tagsItem->get(); |
|
272 | + $data = (array) $tagsItem->get(); |
|
273 | 273 | |
274 | - unset($data[ $item->getKey() ]); |
|
274 | + unset($data[$item->getKey()]); |
|
275 | 275 | $tagsItem->set($data); |
276 | 276 | |
277 | 277 | /** |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getCreationDate() |
113 | 113 | { |
114 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
114 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
115 | 115 | return $this->creationDate; |
116 | 116 | } else { |
117 | 117 | throw new phpFastCacheLogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function setCreationDate(\DateTimeInterface $date) |
127 | 127 | { |
128 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
128 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
129 | 129 | $this->creationDate = $date; |
130 | 130 | return $this; |
131 | 131 | } else { |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function getModificationDate() |
141 | 141 | { |
142 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
142 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
143 | 143 | return $this->modificationDate; |
144 | 144 | } else { |
145 | 145 | throw new phpFastCacheLogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function setModificationDate(\DateTimeInterface $date) |
155 | 155 | { |
156 | - if ($this->driver->getConfig()[ 'itemDetailedDate' ]) { |
|
156 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
157 | 157 | $this->modificationDate = $date; |
158 | 158 | return $this; |
159 | 159 | } else { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | if (is_array($this->data)) { |
227 | 227 | $this->data[] = $data; |
228 | 228 | } else if (is_string($data)) { |
229 | - $this->data .= (string)$data; |
|
229 | + $this->data .= (string) $data; |
|
230 | 230 | } else { |
231 | 231 | throw new phpFastCacheInvalidArgumentException('$data must be either array nor string.'); |
232 | 232 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | if (is_array($this->data)) { |
246 | 246 | array_unshift($this->data, $data); |
247 | 247 | } else if (is_string($data)) { |
248 | - $this->data = (string)$data . $this->data; |
|
248 | + $this->data = (string) $data . $this->data; |
|
249 | 249 | } else { |
250 | 250 | throw new phpFastCacheInvalidArgumentException('$data must be either array nor string.'); |
251 | 251 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | public function removeTag($tagName) |
325 | 325 | { |
326 | 326 | if (($key = array_search($tagName, $this->tags)) !== false) { |
327 | - unset($this->tags[ $key ]); |
|
327 | + unset($this->tags[$key]); |
|
328 | 328 | $this->removedTags[] = $tagName; |
329 | 329 | } |
330 | 330 | |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | final public function __debugInfo() |
404 | 404 | { |
405 | 405 | $info = get_object_vars($this); |
406 | - $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')'; |
|
406 | + $info['driver'] = 'object(' . get_class($info['driver']) . ')'; |
|
407 | 407 | |
408 | - return (array)$info; |
|
408 | + return (array) $info; |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct() |
38 | 38 | { |
39 | - $this->instances =& CacheManager::getInternalInstances(); |
|
39 | + $this->instances = & CacheManager::getInternalInstances(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function getGenericCallback() |
46 | 46 | { |
47 | - return function ($method, $args) { |
|
47 | + return function($method, $args) { |
|
48 | 48 | $getterMethod = (strpos($method, 'get') === 0); |
49 | 49 | $return = false; |
50 | 50 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | foreach ($this->instances as $instance) { |
56 | 56 | $reflectionMethod = new \ReflectionMethod(get_class($instance), $method); |
57 | 57 | if ($getterMethod) { |
58 | - $return[ $instance->getDriverName() ] = $reflectionMethod->invokeArgs($instance, $args); |
|
58 | + $return[$instance->getDriverName()] = $reflectionMethod->invokeArgs($instance, $args); |
|
59 | 59 | } else { |
60 | 60 | $result = $reflectionMethod->invokeArgs($instance, $args); |
61 | 61 | if ($result !== false) { |
@@ -86,8 +86,7 @@ discard block |
||
86 | 86 | return unlink($source); |
87 | 87 | } |
88 | 88 | |
89 | - $files = new RecursiveIteratorIterator |
|
90 | - ( |
|
89 | + $files = new RecursiveIteratorIterator( |
|
91 | 90 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), |
92 | 91 | RecursiveIteratorIterator::CHILD_FIRST |
93 | 92 | ); |
@@ -137,8 +136,8 @@ discard block |
||
137 | 136 | /** |
138 | 137 | * Allows to dereference char |
139 | 138 | */ |
140 | - $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc. |
|
141 | - $prefix = $__FILE__[ 0 ] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
|
139 | + $__FILE__ = preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__); // remove file protocols such as "phar://" etc. |
|
140 | + $prefix = $__FILE__[0] === DIRECTORY_SEPARATOR ? DIRECTORY_SEPARATOR : ''; |
|
142 | 141 | return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes); |
143 | 142 | } |
144 | 143 | } |
145 | 144 | \ No newline at end of file |