@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $this->instance = new MemcacheSoftware(); |
53 | 53 | $this->driverConnect(); |
54 | 54 | |
55 | - if (array_key_exists('compress_data', $config) && $config[ 'compress_data' ] === true) { |
|
55 | + if (array_key_exists('compress_data', $config) && $config['compress_data'] === true) { |
|
56 | 56 | $this->memcacheFlags = MEMCACHE_COMPRESSED; |
57 | 57 | } |
58 | 58 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function driverConnect() |
130 | 130 | { |
131 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
131 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | 134 | ['127.0.0.1', 11211], |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | |
138 | 138 | foreach ($servers as $server) { |
139 | 139 | try { |
140 | - if (!$this->instance->addserver($server[ 0 ], $server[ 1 ])) { |
|
140 | + if (!$this->instance->addserver($server[0], $server[1])) { |
|
141 | 141 | $this->fallback = true; |
142 | 142 | } |
143 | - if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){ |
|
144 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']); |
|
143 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
144 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
145 | 145 | } |
146 | 146 | } catch (\Exception $e) { |
147 | 147 | $this->fallback = true; |
@@ -161,16 +161,16 @@ discard block |
||
161 | 161 | public function getStats() |
162 | 162 | { |
163 | 163 | $stats = (array) $this->instance->getstats(); |
164 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
165 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
166 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
164 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
165 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
166 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
167 | 167 | |
168 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
168 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
169 | 169 | |
170 | 170 | return (new driverStatistic()) |
171 | 171 | ->setData(implode(', ', array_keys($this->itemInstances))) |
172 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
172 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
173 | 173 | ->setRawData($stats) |
174 | - ->setSize($stats[ 'bytes' ]); |
|
174 | + ->setSize($stats['bytes']); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | \ No newline at end of file |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
131 | 131 | if (count($servers) < 1) { |
132 | 132 | $servers = [ |
133 | - ['127.0.0.1', 11211], |
|
133 | + ['127.0.0.1', 11211], |
|
134 | 134 | ]; |
135 | 135 | } |
136 | 136 | |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
161 | 161 | |
162 | 162 | return (new driverStatistic()) |
163 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
164 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
165 | - ->setRawData($stats) |
|
166 | - ->setSize($stats[ 'bytes' ]); |
|
163 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
164 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
165 | + ->setRawData($stats) |
|
166 | + ->setSize($stats[ 'bytes' ]); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | \ No newline at end of file |
@@ -46,6 +46,6 @@ |
||
46 | 46 | }); |
47 | 47 | |
48 | 48 | if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) { |
49 | - trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
|
49 | + trigger_error('Your project already makes use of Composer. You SHOULD use the composer dependency "phpfastcache/phpfastcache" instead of hard-autoloading.', |
|
50 | 50 | E_USER_WARNING); |
51 | 51 | } |
52 | 52 | \ No newline at end of file |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Register Autoload |
20 | 20 | */ |
21 | -spl_autoload_register(function ($entity) { |
|
21 | +spl_autoload_register(function($entity) { |
|
22 | 22 | $module = explode('\\', $entity, 2); |
23 | - if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
|
23 | + if (!in_array($module[0], ['phpFastCache', 'Psr'])) { |
|
24 | 24 | /** |
25 | 25 | * Not a part of phpFastCache file |
26 | 26 | * then we return here. |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | if (is_readable($path)) { |
33 | 33 | require_once $path; |
34 | - }else{ |
|
34 | + } else { |
|
35 | 35 | trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR); |
36 | 36 | } |
37 | 37 | return; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | if (is_readable($path)) { |
42 | 42 | require_once $path; |
43 | - }else{ |
|
43 | + } else { |
|
44 | 44 | trigger_error('Cannot locate the Psr/SimpleCache files', E_USER_ERROR); |
45 | 45 | } |
46 | 46 | return; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | if (is_readable($path)) { |
33 | 33 | require_once $path; |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR); |
36 | 36 | } |
37 | 37 | return; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | if (is_readable($path)) { |
42 | 42 | require_once $path; |
43 | - }else{ |
|
43 | + } else{ |
|
44 | 44 | trigger_error('Cannot locate the Psr/SimpleCache files', E_USER_ERROR); |
45 | 45 | } |
46 | 46 | return; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | protected function driverRead(CacheItemInterface $item) |
85 | 85 | { |
86 | 86 | $key = md5($item->getKey()); |
87 | - if(isset($this->staticStack[$key])){ |
|
87 | + if (isset($this->staticStack[$key])) { |
|
88 | 88 | return $this->staticStack[$key]; |
89 | 89 | } |
90 | 90 | return null; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | if ($item instanceof Item) { |
104 | 104 | $key = md5($item->getKey()); |
105 | - if(isset($this->staticStack[$key])){ |
|
105 | + if (isset($this->staticStack[$key])) { |
|
106 | 106 | unset($this->staticStack[$key]); |
107 | 107 | return true; |
108 | 108 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | { |
31 | 31 | use DriverBaseTrait; |
32 | 32 | |
33 | - /** |
|
34 | - * @var array |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var array |
|
35 | + */ |
|
36 | 36 | protected $staticStack = []; |
37 | 37 | |
38 | 38 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | $key = md5($item->getKey()); |
88 | 88 | if(isset($this->staticStack[$key])){ |
89 | - return $this->staticStack[$key]; |
|
89 | + return $this->staticStack[$key]; |
|
90 | 90 | } |
91 | 91 | return null; |
92 | 92 | } |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | * Check for Cross-Driver type confusion |
103 | 103 | */ |
104 | 104 | if ($item instanceof Item) { |
105 | - $key = md5($item->getKey()); |
|
106 | - if(isset($this->staticStack[$key])){ |
|
107 | - unset($this->staticStack[$key]); |
|
108 | - return true; |
|
109 | - } |
|
110 | - return false; |
|
105 | + $key = md5($item->getKey()); |
|
106 | + if(isset($this->staticStack[$key])){ |
|
107 | + unset($this->staticStack[$key]); |
|
108 | + return true; |
|
109 | + } |
|
110 | + return false; |
|
111 | 111 | } else { |
112 | 112 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
113 | 113 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function driverClear() |
120 | 120 | { |
121 | - unset($this->staticStack); |
|
122 | - $this->staticStack = []; |
|
123 | - return true; |
|
121 | + unset($this->staticStack); |
|
122 | + $this->staticStack = []; |
|
123 | + return true; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | { |
145 | 145 | $stat = new driverStatistic(); |
146 | 146 | $stat->setInfo('[Memstatic] A memory static driver') |
147 | - ->setSize(mb_strlen(serialize($this->staticStack))) |
|
148 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
149 | - ->setRawData($this->staticStack); |
|
147 | + ->setSize(mb_strlen(serialize($this->staticStack))) |
|
148 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
149 | + ->setRawData($this->staticStack); |
|
150 | 150 | |
151 | 151 | return $stat; |
152 | 152 | } |
@@ -84,7 +84,7 @@ |
||
84 | 84 | foreach (array_unique($tagNames) as $tagName) { |
85 | 85 | if(is_string($tagName)){ |
86 | 86 | $items = array_merge($items, $this->getItemsByTag($tagName)); |
87 | - }else{ |
|
87 | + } else{ |
|
88 | 88 | throw new InvalidArgumentException('$tagName must be a a string'); |
89 | 89 | } |
90 | 90 | } |
@@ -38,6 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @inheritdoc |
41 | + * @param string $tagName |
|
41 | 42 | */ |
42 | 43 | public function getItemsByTag($tagName) |
43 | 44 | { |
@@ -408,7 +409,7 @@ discard block |
||
408 | 409 | |
409 | 410 | /** |
410 | 411 | * @internal This method de-register an item from $this->itemInstances |
411 | - * @param CacheItemInterface|string $item |
|
412 | + * @param CacheItemInterface $item |
|
412 | 413 | * @throws phpFastCacheInvalidArgumentException |
413 | 414 | */ |
414 | 415 | protected function deregisterItem($item) |
@@ -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 { |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | { |
75 | 75 | $items = []; |
76 | 76 | foreach (array_unique($tagNames) as $tagName) { |
77 | - if(is_string($tagName)){ |
|
77 | + if (is_string($tagName)) { |
|
78 | 78 | $items = array_merge($items, $this->getItemsByTag($tagName)); |
79 | - }else{ |
|
79 | + } else { |
|
80 | 80 | throw new InvalidArgumentException('$tagName must be a a string'); |
81 | 81 | } |
82 | 82 | } |
@@ -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 \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.'); |
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 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | */ |
438 | 438 | public function isAttached(CacheItemInterface $item) |
439 | 439 | { |
440 | - if (isset($this->itemInstances[ $item->getKey() ])) { |
|
441 | - return spl_object_hash($item) === spl_object_hash($this->itemInstances[ $item->getKey() ]); |
|
440 | + if (isset($this->itemInstances[$item->getKey()])) { |
|
441 | + return spl_object_hash($item) === spl_object_hash($this->itemInstances[$item->getKey()]); |
|
442 | 442 | } |
443 | 443 | return null; |
444 | 444 | } |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | */ |
459 | 459 | public function saveMultiple(...$items) |
460 | 460 | { |
461 | - if (isset($items[ 0 ]) && is_array($items[ 0 ])) { |
|
462 | - foreach ($items[ 0 ] as $item) { |
|
461 | + if (isset($items[0]) && is_array($items[0])) { |
|
462 | + foreach ($items[0] as $item) { |
|
463 | 463 | $this->save($item); |
464 | 464 | } |
465 | 465 | return true; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $keyword = self::PREFIX . $item->getKey(); |
81 | 81 | $v = json_encode($this->driverPreWrap($item)); |
82 | 82 | |
83 | - if (isset($this->config[ 'limited_memory_each_object' ]) && strlen($v) > $this->config[ 'limited_memory_each_object' ]) { |
|
83 | + if (isset($this->config['limited_memory_each_object']) && strlen($v) > $this->config['limited_memory_each_object']) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // return null if no caching |
102 | 102 | // return value if in caching |
103 | 103 | $keyword = self::PREFIX . $item->getKey(); |
104 | - $x = isset($_COOKIE[ $keyword ]) ? json_decode($_COOKIE[ $keyword ], true) : false; |
|
104 | + $x = isset($_COOKIE[$keyword]) ? json_decode($_COOKIE[$keyword], true) : false; |
|
105 | 105 | |
106 | 106 | if ($x == false) { |
107 | 107 | return null; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | { |
123 | 123 | $this->driverConnect(); |
124 | 124 | $keyword = self::PREFIX . $key; |
125 | - $x = isset($_COOKIE[ $keyword ]) ? $this->decode(json_decode($_COOKIE[ $keyword ])->t) : false; |
|
125 | + $x = isset($_COOKIE[$keyword]) ? $this->decode(json_decode($_COOKIE[$keyword])->t) : false; |
|
126 | 126 | |
127 | 127 | return $x ? $x - time() : $x; |
128 | 128 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | if ($item instanceof Item) { |
141 | 141 | $this->driverConnect(); |
142 | 142 | $keyword = self::PREFIX . $item->getKey(); |
143 | - $_COOKIE[ $keyword ] = null; |
|
143 | + $_COOKIE[$keyword] = null; |
|
144 | 144 | |
145 | 145 | return @setcookie($keyword, null, -10); |
146 | 146 | } else { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $this->driverConnect(); |
158 | 158 | foreach ($_COOKIE as $keyword => $value) { |
159 | 159 | if (strpos($keyword, self::PREFIX) !== false) { |
160 | - $_COOKIE[ $keyword ] = null; |
|
160 | + $_COOKIE[$keyword] = null; |
|
161 | 161 | $result = @setcookie($keyword, null, -10); |
162 | 162 | if ($return !== false) { |
163 | 163 | $return = $result; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | |
132 | 132 | /** |
133 | - * @param $keyword |
|
133 | + * @param false|string $keyword |
|
134 | 134 | * @param bool $skip |
135 | 135 | * @return string |
136 | 136 | * @throws phpFastCacheIOException |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | /** |
199 | 199 | * @param $filename |
200 | - * @return mixed |
|
200 | + * @return string |
|
201 | 201 | */ |
202 | 202 | protected static function cleanFileName($filename) |
203 | 203 | { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | - * @param $path |
|
215 | + * @param string $path |
|
216 | 216 | * @param bool $create |
217 | 217 | * @throws phpFastCacheIOException |
218 | 218 | */ |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | |
251 | 251 | /** |
252 | - * @param $file |
|
252 | + * @param string $file |
|
253 | 253 | * @return string |
254 | 254 | * @throws phpFastCacheIOException |
255 | 255 | */ |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | protected static function cleanFileName($filename) |
203 | 203 | { |
204 | 204 | $regex = [ |
205 | - '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
206 | - '/\.$/', |
|
207 | - '/^\./', |
|
205 | + '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/', |
|
206 | + '/\.$/', |
|
207 | + '/^\./', |
|
208 | 208 | ]; |
209 | 209 | $replace = ['-', '', '']; |
210 | 210 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
297 | 297 | str_shuffle(uniqid($this->getDriverName(), false)) |
298 | 298 | . str_shuffle(uniqid($this->getDriverName(), false)) |
299 | - )); |
|
299 | + )); |
|
300 | 300 | |
301 | 301 | $f = fopen($tmpFilename, 'w+'); |
302 | 302 | flock($f, LOCK_EX); |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | $stat->setData(implode(', ', array_keys($this->itemInstances))) |
341 | - ->setRawData([ |
|
341 | + ->setRawData([ |
|
342 | 342 | 'tmp' => $this->tmp |
343 | - ]) |
|
344 | - ->setSize(Directory::dirSize($path)) |
|
345 | - ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
343 | + ]) |
|
344 | + ->setSize(Directory::dirSize($path)) |
|
345 | + ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path)); |
|
346 | 346 | |
347 | 347 | return $stat; |
348 | 348 | } |
@@ -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 | - }else{ |
|
99 | - if (!isset($this->tmp[ $full_path_hash ]) || (!@file_exists($full_path) || !@is_writable($full_path))) { |
|
98 | + } else { |
|
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 | - }else if (!@is_writable($full_path)) { |
|
103 | - if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config[ 'autoTmpFallback' ]) |
|
102 | + } else if (!@is_writable($full_path)) { |
|
103 | + if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config['autoTmpFallback']) |
|
104 | 104 | { |
105 | 105 | /** |
106 | 106 | * Switch back to tmp dir |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | throw new phpFastCacheIOException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!'); |
123 | 123 | } |
124 | 124 | |
125 | - $this->tmp[ $full_path_hash ] = $full_path; |
|
126 | - $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
|
125 | + $this->tmp[$full_path_hash] = $full_path; |
|
126 | + $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config['htaccess'] : false); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | */ |
181 | 181 | protected function getDefaultChmod() |
182 | 182 | { |
183 | - if (!isset($this->config[ 'default_chmod' ]) || $this->config[ 'default_chmod' ] == '' || is_null($this->config[ 'default_chmod' ])) { |
|
183 | + if (!isset($this->config['default_chmod']) || $this->config['default_chmod'] == '' || is_null($this->config['default_chmod'])) { |
|
184 | 184 | return 0777; |
185 | 185 | } else { |
186 | - return $this->config[ 'default_chmod' ]; |
|
186 | + return $this->config['default_chmod']; |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | if ($create === true) { |
214 | 214 | if (!is_writable($path)) { |
215 | 215 | try { |
216 | - if(!chmod($path, 0777)){ |
|
216 | + if (!chmod($path, 0777)) { |
|
217 | 217 | throw new phpFastCacheIOException('Chmod failed on : ' . $path); |
218 | 218 | } |
219 | 219 | } catch (phpFastCacheIOException $e) { |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | $this->eventManager->dispatch('CacheWriteFileOnDisk', $this, $file, $secureFileManipulation); |
286 | 286 | |
287 | - if($secureFileManipulation){ |
|
287 | + if ($secureFileManipulation) { |
|
288 | 288 | $tmpFilename = Directory::getAbsolutePath(dirname($file) . '/tmp_' . md5( |
289 | 289 | str_shuffle(uniqid($this->getDriverName(), false)) |
290 | 290 | . str_shuffle(uniqid($this->getDriverName(), false)) |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | flock($f, LOCK_UN); |
297 | 297 | fclose($f); |
298 | 298 | |
299 | - if(!rename($tmpFilename, $file)){ |
|
299 | + if (!rename($tmpFilename, $file)) { |
|
300 | 300 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
301 | 301 | } |
302 | - }else{ |
|
302 | + } else { |
|
303 | 303 | $f = fopen($file, 'w+'); |
304 | 304 | $octetWritten = fwrite($f, $data); |
305 | 305 | fclose($f); |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | return $full_path_tmp; |
96 | 96 | } |
97 | 97 | return $full_path; |
98 | - }else{ |
|
98 | + } else{ |
|
99 | 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 | - }else if (!@is_writable($full_path)) { |
|
102 | + } else if (!@is_writable($full_path)) { |
|
103 | 103 | if (!@chmod($full_path, $this->getDefaultChmod()) && $this->config[ 'autoTmpFallback' ]) |
104 | 104 | { |
105 | 105 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | if(!rename($tmpFilename, $file)){ |
300 | 300 | throw new phpFastCacheIOException(sprintf('Failed to rename %s to %s', $tmpFilename, $file)); |
301 | 301 | } |
302 | - }else{ |
|
302 | + } else{ |
|
303 | 303 | $f = fopen($file, 'w+'); |
304 | 304 | $octetWritten = fwrite($f, $data); |
305 | 305 | fclose($f); |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | |
139 | 139 | |
140 | - $host = isset($this->config[ 'host' ]) ? $this->config[ 'host' ] : '127.0.0.1'; |
|
141 | - $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
|
142 | - $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
|
143 | - $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
|
140 | + $host = isset($this->config['host']) ? $this->config['host'] : '127.0.0.1'; |
|
141 | + $password = isset($this->config['password']) ? $this->config['password'] : ''; |
|
142 | + $username = isset($this->config['username']) ? $this->config['username'] : ''; |
|
143 | + $buckets = isset($this->config['buckets']) ? $this->config['buckets'] : [ |
|
144 | 144 | [ |
145 | 145 | 'bucket' => 'default', |
146 | 146 | 'password' => '', |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | $this->instance = new CouchbaseClient("couchbase://{$host}", $username, $password); |
151 | 151 | |
152 | 152 | foreach ($buckets as $bucket) { |
153 | - $this->bucketCurrent = $this->bucketCurrent ?: $bucket[ 'bucket' ]; |
|
154 | - $this->setBucket($bucket[ 'bucket' ], $this->instance->openBucket($bucket[ 'bucket' ], $bucket[ 'password' ])); |
|
153 | + $this->bucketCurrent = $this->bucketCurrent ?: $bucket['bucket']; |
|
154 | + $this->setBucket($bucket['bucket'], $this->instance->openBucket($bucket['bucket'], $bucket['password'])); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | protected function getBucket() |
165 | 165 | { |
166 | - return $this->bucketInstances[ $this->bucketCurrent ]; |
|
166 | + return $this->bucketInstances[$this->bucketCurrent]; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | protected function setBucket($bucketName, \CouchbaseBucket $CouchbaseBucket) |
175 | 175 | { |
176 | 176 | if (!array_key_exists($bucketName, $this->bucketInstances)) { |
177 | - $this->bucketInstances[ $bucketName ] = $CouchbaseBucket; |
|
177 | + $this->bucketInstances[$bucketName] = $CouchbaseBucket; |
|
178 | 178 | } else { |
179 | 179 | throw new \LogicException('A bucket instance with this name already exists.'); |
180 | 180 | } |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | $info = $this->getBucket()->manager()->info(); |
195 | 195 | |
196 | 196 | return (new driverStatistic()) |
197 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
197 | + ->setSize($info['basicStats']['diskUsed']) |
|
198 | 198 | ->setRawData($info) |
199 | 199 | ->setData(implode(', ', array_keys($this->itemInstances))) |
200 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
200 | + ->setInfo('CouchBase version ' . $info['nodes'][0]['version'] . ', Uptime (in days): ' . round($info['nodes'][0]['uptime'] / 86400, 1) . "\n For more information see RawData."); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | \ No newline at end of file |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | $password = isset($this->config[ 'password' ]) ? $this->config[ 'password' ] : ''; |
143 | 143 | $username = isset($this->config[ 'username' ]) ? $this->config[ 'username' ] : ''; |
144 | 144 | $buckets = isset($this->config[ 'buckets' ]) ? $this->config[ 'buckets' ] : [ |
145 | - [ |
|
145 | + [ |
|
146 | 146 | 'bucket' => 'default', |
147 | 147 | 'password' => '', |
148 | - ], |
|
148 | + ], |
|
149 | 149 | ]; |
150 | 150 | |
151 | 151 | $this->instance = new CouchbaseClient("couchbase://{$host}", $username, $password); |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | $info = $this->getBucket()->manager()->info(); |
196 | 196 | |
197 | 197 | return (new driverStatistic()) |
198 | - ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
199 | - ->setRawData($info) |
|
200 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
201 | - ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
198 | + ->setSize($info[ 'basicStats' ][ 'diskUsed' ]) |
|
199 | + ->setRawData($info) |
|
200 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
201 | + ->setInfo('CouchBase version ' . $info[ 'nodes' ][ 0 ][ 'version' ] . ', Uptime (in days): ' . round($info[ 'nodes' ][ 0 ][ 'uptime' ] / 86400, 1) . "\n For more information see RawData."); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | \ No newline at end of file |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function printNewLine($count = 1) |
81 | 81 | { |
82 | - for($i = 0; $i < $count; $i++){ |
|
82 | + for ($i = 0; $i < $count; $i++) { |
|
83 | 83 | print PHP_EOL; |
84 | 84 | } |
85 | 85 | |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function printText($string, $strtoupper = false) |
95 | 95 | { |
96 | - if(!$strtoupper){ |
|
96 | + if (!$strtoupper) { |
|
97 | 97 | print trim($string) . PHP_EOL; |
98 | - }else{ |
|
98 | + } else { |
|
99 | 99 | print strtoupper(trim($string) . PHP_EOL); |
100 | 100 | } |
101 | 101 |
@@ -111,7 +111,7 @@ |
||
111 | 111 | { |
112 | 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 |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | - * @return array |
|
238 | + * @return ExtendedCacheItemPoolInterface[] |
|
239 | 239 | */ |
240 | 240 | public static function getDefaultConfig() |
241 | 241 | { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | - * @return array |
|
246 | + * @return string[] |
|
247 | 247 | */ |
248 | 248 | public static function getStaticSystemDrivers() |
249 | 249 | { |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
271 | - * @return array |
|
271 | + * @return string[] |
|
272 | 272 | */ |
273 | 273 | public static function getStaticAllDrivers() |
274 | 274 | { |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | * @var ExtendedCacheItemPoolInterface[] |
57 | 57 | */ |
58 | 58 | protected static $config = [ |
59 | - 'itemDetailedDate' => false, // Specify if the item must provide detailed creation/modification dates |
|
60 | - 'autoTmpFallback' => false, // Automatically attempt to fallback to the temporary directory if the cache fails to write to the specified directory |
|
61 | - 'secureFileManipulation' => false, // Provide a secure file manipulation mechanism; on intensive usage the performance can be negatively affected. |
|
62 | - 'ignoreSymfonyNotice' => false, // Ignore Symfony notices for Symfony projects that do not makes use of PhpFastCache's Symfony Bundle |
|
63 | - 'defaultTtl' => 900, // Default time-to-live in seconds |
|
64 | - 'securityKey' => 'auto', // The securityKey that will be used to create the sub-directory |
|
65 | - 'htaccess' => true, // Auto-generate .htaccess if it is missing |
|
66 | - 'default_chmod' => 0777, // 0777 is recommended |
|
67 | - 'path' => '', // If not set will be the value of sys_get_temp_dir() |
|
68 | - 'fallback' => false, // Fall back when old driver is not supported |
|
69 | - 'limited_memory_each_object' => 4096, // Maximum size (bytes) of object store in memory |
|
70 | - 'compress_data' => false, // Compress stored data if the backend supports it |
|
59 | + 'itemDetailedDate' => false, // Specify if the item must provide detailed creation/modification dates |
|
60 | + 'autoTmpFallback' => false, // Automatically attempt to fallback to the temporary directory if the cache fails to write to the specified directory |
|
61 | + 'secureFileManipulation' => false, // Provide a secure file manipulation mechanism; on intensive usage the performance can be negatively affected. |
|
62 | + 'ignoreSymfonyNotice' => false, // Ignore Symfony notices for Symfony projects that do not makes use of PhpFastCache's Symfony Bundle |
|
63 | + 'defaultTtl' => 900, // Default time-to-live in seconds |
|
64 | + 'securityKey' => 'auto', // The securityKey that will be used to create the sub-directory |
|
65 | + 'htaccess' => true, // Auto-generate .htaccess if it is missing |
|
66 | + 'default_chmod' => 0777, // 0777 is recommended |
|
67 | + 'path' => '', // If not set will be the value of sys_get_temp_dir() |
|
68 | + 'fallback' => false, // Fall back when old driver is not supported |
|
69 | + 'limited_memory_each_object' => 4096, // Maximum size (bytes) of object store in memory |
|
70 | + 'compress_data' => false, // Compress stored data if the backend supports it |
|
71 | 71 | ]; |
72 | 72 | |
73 | 73 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | } else if(++$badPracticeOmeter[$driver] >= 5){ |
124 | - trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
124 | + trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
|
125 | 125 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
126 | 126 | } |
127 | 127 | |
@@ -248,23 +248,23 @@ discard block |
||
248 | 248 | public static function getStaticSystemDrivers() |
249 | 249 | { |
250 | 250 | return [ |
251 | - 'Apc', |
|
252 | - 'Apcu', |
|
253 | - 'Cassandra', |
|
254 | - 'Couchbase', |
|
255 | - 'Devnull', |
|
256 | - 'Files', |
|
257 | - 'Leveldb', |
|
258 | - 'Memcache', |
|
259 | - 'Memcached', |
|
260 | - 'Memstatic', |
|
261 | - 'Mongodb', |
|
262 | - 'Predis', |
|
263 | - 'Redis', |
|
264 | - 'Ssdb', |
|
265 | - 'Sqlite', |
|
266 | - 'Wincache', |
|
267 | - 'Xcache', |
|
251 | + 'Apc', |
|
252 | + 'Apcu', |
|
253 | + 'Cassandra', |
|
254 | + 'Couchbase', |
|
255 | + 'Devnull', |
|
256 | + 'Files', |
|
257 | + 'Leveldb', |
|
258 | + 'Memcache', |
|
259 | + 'Memcached', |
|
260 | + 'Memstatic', |
|
261 | + 'Mongodb', |
|
262 | + 'Predis', |
|
263 | + 'Redis', |
|
264 | + 'Ssdb', |
|
265 | + 'Sqlite', |
|
266 | + 'Wincache', |
|
267 | + 'Xcache', |
|
268 | 268 | ]; |
269 | 269 | } |
270 | 270 |
@@ -100,32 +100,32 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | $instance = crc32($driver . serialize($config)); |
103 | - if (!isset(self::$instances[ $instance ])) { |
|
103 | + if (!isset(self::$instances[$instance])) { |
|
104 | 104 | $badPracticeOmeter[$driver] = 1; |
105 | - if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){ |
|
105 | + if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
106 | 106 | trigger_error('A Symfony Bundle to make the PhpFastCache integration more easier is now available here: https://github.com/PHPSocialNetwork/phpfastcache-bundle', E_USER_NOTICE); |
107 | 107 | } |
108 | 108 | $class = self::getNamespacePath() . $driver . '\Driver'; |
109 | - try{ |
|
110 | - self::$instances[ $instance ] = new $class($config); |
|
111 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
112 | - }catch(phpFastCacheDriverCheckException $e){ |
|
109 | + try { |
|
110 | + self::$instances[$instance] = new $class($config); |
|
111 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
112 | + } catch (phpFastCacheDriverCheckException $e) { |
|
113 | 113 | $fallback = self::standardizeDriverName($config['fallback']); |
114 | - if($fallback && $fallback !== $driver){ |
|
114 | + if ($fallback && $fallback !== $driver) { |
|
115 | 115 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
116 | - self::$instances[ $instance ] = new $class($config); |
|
117 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
116 | + self::$instances[$instance] = new $class($config); |
|
117 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
118 | 118 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
119 | - }else{ |
|
119 | + } else { |
|
120 | 120 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
121 | 121 | } |
122 | 122 | } |
123 | - } else if(++$badPracticeOmeter[$driver] >= 5){ |
|
123 | + } else if (++$badPracticeOmeter[$driver] >= 5) { |
|
124 | 124 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
125 | 125 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
126 | 126 | } |
127 | 127 | |
128 | - return self::$instances[ $instance ]; |
|
128 | + return self::$instances[$instance]; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public static function __callStatic($name, $arguments) |
188 | 188 | { |
189 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
189 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
190 | 190 | |
191 | 191 | return self::getInstance($name, $options); |
192 | 192 | } |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | { |
228 | 228 | if (is_array($name)) { |
229 | 229 | self::$config = array_merge(self::$config, $name); |
230 | - } else if (is_string($name)){ |
|
231 | - self::$config[ $name ] = $value; |
|
232 | - }else{ |
|
230 | + } else if (is_string($name)) { |
|
231 | + self::$config[$name] = $value; |
|
232 | + } else { |
|
233 | 233 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
234 | 234 | } |
235 | 235 | } |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | try{ |
110 | 110 | self::$instances[ $instance ] = new $class($config); |
111 | 111 | self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
112 | - }catch(phpFastCacheDriverCheckException $e){ |
|
112 | + } catch(phpFastCacheDriverCheckException $e){ |
|
113 | 113 | $fallback = self::standardizeDriverName($config['fallback']); |
114 | 114 | if($fallback && $fallback !== $driver){ |
115 | 115 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
116 | 116 | self::$instances[ $instance ] = new $class($config); |
117 | 117 | self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
118 | 118 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
119 | - }else{ |
|
119 | + } else{ |
|
120 | 120 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
121 | 121 | } |
122 | 122 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | self::$config = array_merge(self::$config, $name); |
230 | 230 | } else if (is_string($name)){ |
231 | 231 | self::$config[ $name ] = $value; |
232 | - }else{ |
|
232 | + } else{ |
|
233 | 233 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
234 | 234 | } |
235 | 235 | } |