@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | - ['127.0.0.1', 11211], |
|
134 | + ['127.0.0.1', 11211], |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
162 | 162 | |
163 | 163 | return (new driverStatistic()) |
164 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | - ->setRawData($stats) |
|
167 | - ->setSize($stats[ 'bytes' ]); |
|
164 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | + ->setRawData($stats) |
|
167 | + ->setSize($stats[ 'bytes' ]); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | \ No newline at end of file |
@@ -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 |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | { |
140 | 140 | try { |
141 | 141 | $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
142 | - 'host' => "127.0.0.1", |
|
143 | - 'port' => 8888, |
|
144 | - 'password' => '', |
|
145 | - 'timeout' => 2000, |
|
142 | + 'host' => "127.0.0.1", |
|
143 | + 'port' => 8888, |
|
144 | + 'password' => '', |
|
145 | + 'timeout' => 2000, |
|
146 | 146 | ]; |
147 | 147 | |
148 | 148 | $host = $server[ 'host' ]; |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * using hardcoded offset of pair key-value :-( |
184 | 184 | */ |
185 | 185 | $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
186 | - ->setRawData($info) |
|
187 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
188 | - ->setSize($this->instance->dbsize()); |
|
186 | + ->setRawData($info) |
|
187 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
188 | + ->setSize($this->instance->dbsize()); |
|
189 | 189 | |
190 | 190 | return $stat; |
191 | 191 | } |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | protected function driverConnect() |
139 | 139 | { |
140 | 140 | try { |
141 | - $server = isset($this->config[ 'ssdb' ]) ? $this->config[ 'ssdb' ] : [ |
|
141 | + $server = isset($this->config['ssdb']) ? $this->config['ssdb'] : [ |
|
142 | 142 | 'host' => "127.0.0.1", |
143 | 143 | 'port' => 8888, |
144 | 144 | 'password' => '', |
145 | 145 | 'timeout' => 2000, |
146 | 146 | ]; |
147 | 147 | |
148 | - $host = $server[ 'host' ]; |
|
149 | - $port = isset($server[ 'port' ]) ? (int) $server[ 'port' ] : 8888; |
|
150 | - $password = isset($server[ 'password' ]) ? $server[ 'password' ] : ''; |
|
151 | - $timeout = !empty($server[ 'timeout' ]) ? (int) $server[ 'timeout' ] : 2000; |
|
148 | + $host = $server['host']; |
|
149 | + $port = isset($server['port']) ? (int) $server['port'] : 8888; |
|
150 | + $password = isset($server['password']) ? $server['password'] : ''; |
|
151 | + $timeout = !empty($server['timeout']) ? (int) $server['timeout'] : 2000; |
|
152 | 152 | $this->instance = new SimpleSSDB($host, $port, $timeout); |
153 | 153 | if (!empty($password)) { |
154 | 154 | $this->instance->auth($password); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * Data returned by Ssdb are very poorly formatted |
183 | 183 | * using hardcoded offset of pair key-value :-( |
184 | 184 | */ |
185 | - $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[ 2 ], $info[ 6 ])) |
|
185 | + $stat->setInfo(sprintf("Ssdb-server v%s with a total of %s call(s).\n For more information see RawData.", $info[2], $info[6])) |
|
186 | 186 | ->setRawData($info) |
187 | 187 | ->setData(implode(', ', array_keys($this->itemInstances))) |
188 | 188 | ->setSize($this->instance->dbsize()); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
132 | 132 | if (count($servers) < 1) { |
133 | 133 | $servers = [ |
134 | - ['127.0.0.1', 11211], |
|
134 | + ['127.0.0.1', 11211], |
|
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
162 | 162 | |
163 | 163 | return (new driverStatistic()) |
164 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | - ->setRawData($stats) |
|
167 | - ->setSize($stats[ 'bytes' ]); |
|
164 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
165 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
166 | + ->setRawData($stats) |
|
167 | + ->setSize($stats[ 'bytes' ]); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | \ No newline at end of file |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function driverConnect() |
129 | 129 | { |
130 | - $servers = (!empty($this->config[ 'memcache' ]) && is_array($this->config[ 'memcache' ]) ? $this->config[ 'memcache' ] : []); |
|
130 | + $servers = (!empty($this->config['memcache']) && is_array($this->config['memcache']) ? $this->config['memcache'] : []); |
|
131 | 131 | if (count($servers) < 1) { |
132 | 132 | $servers = [ |
133 | 133 | ['127.0.0.1', 11211], |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | |
137 | 137 | foreach ($servers as $server) { |
138 | 138 | try { |
139 | - if (!$this->instance->addServer($server[ 0 ], $server[ 1 ])) { |
|
139 | + if (!$this->instance->addServer($server[0], $server[1])) { |
|
140 | 140 | $this->fallback = true; |
141 | 141 | } |
142 | - if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){ |
|
143 | - $this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']); |
|
142 | + if (!empty($server['sasl_user']) && !empty($server['sasl_password'])) { |
|
143 | + $this->instance->setSaslAuthData($server['sasl_user'], $server['sasl_password']); |
|
144 | 144 | } |
145 | 145 | } catch (\Exception $e) { |
146 | 146 | $this->fallback = true; |
@@ -160,16 +160,16 @@ discard block |
||
160 | 160 | public function getStats() |
161 | 161 | { |
162 | 162 | $stats = (array) $this->instance->getStats(); |
163 | - $stats[ 'uptime' ] = (isset($stats[ 'uptime' ]) ? $stats[ 'uptime' ] : 0); |
|
164 | - $stats[ 'version' ] = (isset($stats[ 'version' ]) ? $stats[ 'version' ] : 'UnknownVersion'); |
|
165 | - $stats[ 'bytes' ] = (isset($stats[ 'bytes' ]) ? $stats[ 'version' ] : 0); |
|
163 | + $stats['uptime'] = (isset($stats['uptime']) ? $stats['uptime'] : 0); |
|
164 | + $stats['version'] = (isset($stats['version']) ? $stats['version'] : 'UnknownVersion'); |
|
165 | + $stats['bytes'] = (isset($stats['bytes']) ? $stats['version'] : 0); |
|
166 | 166 | |
167 | - $date = (new \DateTime())->setTimestamp(time() - $stats[ 'uptime' ]); |
|
167 | + $date = (new \DateTime())->setTimestamp(time() - $stats['uptime']); |
|
168 | 168 | |
169 | 169 | return (new driverStatistic()) |
170 | 170 | ->setData(implode(', ', array_keys($this->itemInstances))) |
171 | - ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats[ 'version' ], $date->format(DATE_RFC2822))) |
|
171 | + ->setInfo(sprintf("The memcache daemon v%s is up since %s.\n For more information see RawData.", $stats['version'], $date->format(DATE_RFC2822))) |
|
172 | 172 | ->setRawData($stats) |
173 | - ->setSize($stats[ 'bytes' ]); |
|
173 | + ->setSize($stats['bytes']); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | \ No newline at end of file |
@@ -74,9 +74,9 @@ |
||
74 | 74 | */ |
75 | 75 | public function __call($name, $args) |
76 | 76 | { |
77 | - if(method_exists($this->instance, $name)){ |
|
77 | + if (method_exists($this->instance, $name)) { |
|
78 | 78 | return call_user_func_array([$this->instance, $name], $args); |
79 | - }else{ |
|
79 | + } else { |
|
80 | 80 | throw new \BadMethodCallException(sprintf('Method %s does not exists', $name)); |
81 | 81 | } |
82 | 82 | } |
@@ -273,7 +273,7 @@ |
||
273 | 273 | |
274 | 274 | if (!is_dir($path)) { |
275 | 275 | throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94); |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $size = Directory::dirSize($path); |
278 | 278 | } |
279 | 279 |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | $class = self::getNamespacePath() . $driver . '\Driver'; |
96 | 96 | try{ |
97 | 97 | self::$instances[ $instance ] = new $class($config); |
98 | - }catch(phpFastCacheDriverCheckException $e){ |
|
98 | + } catch(phpFastCacheDriverCheckException $e){ |
|
99 | 99 | $fallback = self::standardizeDriverName($config['fallback']); |
100 | 100 | if($fallback && $fallback !== $driver){ |
101 | 101 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
102 | 102 | self::$instances[ $instance ] = new $class($config); |
103 | 103 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
104 | - }else{ |
|
104 | + } else{ |
|
105 | 105 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
106 | 106 | } |
107 | 107 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | self::$config = array_merge(self::$config, $name); |
199 | 199 | } else if (is_string($name)){ |
200 | 200 | self::$config[ $name ] = $value; |
201 | - }else{ |
|
201 | + } else{ |
|
202 | 202 | throw new \InvalidArgumentException('Invalid variable type: $name'); |
203 | 203 | } |
204 | 204 | } |
@@ -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 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @param \Psr\Cache\CacheItemInterface $item |
160 | - * @return mixed |
|
160 | + * @return boolean |
|
161 | 161 | * @throws \InvalidArgumentException |
162 | 162 | */ |
163 | 163 | public function save(CacheItemInterface $item) |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * @return mixed|null |
|
178 | + * @return boolean |
|
179 | 179 | * @throws \InvalidArgumentException |
180 | 180 | */ |
181 | 181 | public function commit() |
@@ -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 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function getItem($key) |
62 | 62 | { |
63 | 63 | if (is_string($key)) { |
64 | - if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)){ |
|
64 | + if (preg_match('~([' . preg_quote(self::$unsupportedKeyChars, '~') . ']+)~', $key, $matches)) { |
|
65 | 65 | throw new phpFastCacheInvalidArgumentException('Unsupported key character detected: "' . $matches[1] . '". Please check: https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV6%5D-Unsupported-characters-in-key-identifiers'); |
66 | 66 | } |
67 | 67 | if (!array_key_exists($key, $this->itemInstances)) { |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | $driverArray = $this->driverRead($item); |
77 | 77 | |
78 | 78 | if ($driverArray) { |
79 | - if(!is_array($driverArray)){ |
|
79 | + if (!is_array($driverArray)) { |
|
80 | 80 | throw new phpFastCacheCoreException(sprintf('The driverRead method returned an unexpected variable type: %s', gettype($driverArray))); |
81 | 81 | } |
82 | 82 | $item->set($this->driverUnwrapData($driverArray)); |
83 | 83 | $item->expiresAt($this->driverUnwrapEdate($driverArray)); |
84 | 84 | |
85 | - if($this->config['itemDetailedDate']){ |
|
85 | + if ($this->config['itemDetailedDate']) { |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * If the itemDetailedDate has been |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | } else { |
107 | 107 | $item->setHit(true); |
108 | 108 | } |
109 | - }else{ |
|
110 | - $item->expiresAfter(abs((int) $this->getConfig()[ 'defaultTtl' ])); |
|
109 | + } else { |
|
110 | + $item->expiresAfter(abs((int) $this->getConfig()['defaultTtl'])); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * @param $this ExtendedCacheItemPoolInterface |
121 | 121 | * @param $this ExtendedCacheItemInterface |
122 | 122 | */ |
123 | - $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[ $key ]); |
|
123 | + $this->eventManager->dispatch('CacheGetItem', $this, $this->itemInstances[$key]); |
|
124 | 124 | |
125 | - return $this->itemInstances[ $key ]; |
|
125 | + return $this->itemInstances[$key]; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | public function setItem(CacheItemInterface $item) |
134 | 134 | { |
135 | 135 | if ($this->getClassNamespace() . '\\Item' === get_class($item)) { |
136 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
136 | + $this->itemInstances[$item->getKey()] = $item; |
|
137 | 137 | |
138 | 138 | return $this; |
139 | 139 | } else { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $collection = []; |
152 | 152 | foreach ($keys as $key) { |
153 | - $collection[ $key ] = $this->getItem($key); |
|
153 | + $collection[$key] = $this->getItem($key); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | return $collection; |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @var ExtendedCacheItemInterface $item |
248 | 248 | */ |
249 | 249 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
250 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
251 | - } else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
250 | + $this->itemInstances[$item->getKey()] = $item; |
|
251 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
252 | 252 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
253 | 253 | } |
254 | 254 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | public function saveDeferred(CacheItemInterface $item) |
279 | 279 | { |
280 | 280 | if (!array_key_exists($item->getKey(), $this->itemInstances)) { |
281 | - $this->itemInstances[ $item->getKey() ] = $item; |
|
282 | - }else if(spl_object_hash($item) !== spl_object_hash($this->itemInstances[ $item->getKey() ])){ |
|
281 | + $this->itemInstances[$item->getKey()] = $item; |
|
282 | + } else if (spl_object_hash($item) !== spl_object_hash($this->itemInstances[$item->getKey()])) { |
|
283 | 283 | throw new \RuntimeException('Spl object hash mismatches ! You probably tried to save a detached item which has been already retrieved from cache.'); |
284 | 284 | } |
285 | 285 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | $this->eventManager->dispatch('CacheSaveDeferredItem', $this, $item); |
292 | 292 | |
293 | - return $this->deferredList[ $item->getKey() ] = $item; |
|
293 | + return $this->deferredList[$item->getKey()] = $item; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | foreach ($this->deferredList as $key => $item) { |
311 | 311 | $result = $this->save($item); |
312 | 312 | if ($return !== false) { |
313 | - unset($this->deferredList[ $key ]); |
|
313 | + unset($this->deferredList[$key]); |
|
314 | 314 | $return = $result; |
315 | 315 | } |
316 | 316 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | /** |
59 | 59 | * @param \Psr\Cache\CacheItemInterface $item |
60 | - * @return mixed |
|
60 | + * @return boolean |
|
61 | 61 | * @throws \InvalidArgumentException |
62 | 62 | */ |
63 | 63 | public function driverWrite(CacheItemInterface $item) |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | protected function driverRead(CacheItemInterface $item) |
80 | 80 | { |
81 | 81 | return [ |
82 | - self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
83 | - self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
84 | - self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
82 | + self::DRIVER_DATA_WRAPPER_INDEX => false, |
|
83 | + self::DRIVER_TAGS_WRAPPER_INDEX => [], |
|
84 | + self::DRIVER_TIME_WRAPPER_INDEX => new \DateTime(), |
|
85 | 85 | ]; |
86 | 86 | } |
87 | 87 | /** |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | { |
131 | 131 | $stat = new driverStatistic(); |
132 | 132 | $stat->setInfo('[Devfalse] A void info string') |
133 | - ->setSize(0) |
|
134 | - ->setData(implode(', ', array_keys($this->itemInstances))) |
|
135 | - ->setRawData(false); |
|
133 | + ->setSize(0) |
|
134 | + ->setData(implode(', ', array_keys($this->itemInstances))) |
|
135 | + ->setRawData(false); |
|
136 | 136 | |
137 | 137 | return $stat; |
138 | 138 | } |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function getCreationDate() |
69 | 69 | { |
70 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
70 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
71 | 71 | return $this->creationDate; |
72 | - }else{ |
|
72 | + } else { |
|
73 | 73 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
74 | 74 | } |
75 | 75 | } |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function setCreationDate(\DateTimeInterface $date) |
83 | 83 | { |
84 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
84 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
85 | 85 | $this->creationDate = $date; |
86 | 86 | return $this; |
87 | - }else{ |
|
87 | + } else { |
|
88 | 88 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
89 | 89 | } |
90 | 90 | } |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function getModificationDate() |
97 | 97 | { |
98 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
98 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
99 | 99 | return $this->modificationDate; |
100 | - }else{ |
|
100 | + } else { |
|
101 | 101 | throw new \LogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
102 | 102 | } |
103 | 103 | } |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function setModificationDate(\DateTimeInterface $date) |
111 | 111 | { |
112 | - if($this->driver->getConfig()['itemDetailedDate']){ |
|
112 | + if ($this->driver->getConfig()['itemDetailedDate']) { |
|
113 | 113 | $this->modificationDate = $date; |
114 | 114 | return $this; |
115 | - }else{ |
|
115 | + } else { |
|
116 | 116 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
117 | 117 | } |
118 | 118 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | public function removeTag($tagName) |
280 | 280 | { |
281 | 281 | if (($key = array_search($tagName, $this->tags)) !== false) { |
282 | - unset($this->tags[ $key ]); |
|
282 | + unset($this->tags[$key]); |
|
283 | 283 | $this->removedTags[] = $tagName; |
284 | 284 | } |
285 | 285 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | final public function __debugInfo() |
346 | 346 | { |
347 | 347 | $info = get_object_vars($this); |
348 | - $info[ 'driver' ] = 'object(' . get_class($info[ 'driver' ]) . ')'; |
|
348 | + $info['driver'] = 'object(' . get_class($info['driver']) . ')'; |
|
349 | 349 | |
350 | 350 | return (array) $info; |
351 | 351 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | if($this->driver->getConfig()['itemDetailedDate']){ |
71 | 71 | return $this->creationDate; |
72 | - }else{ |
|
72 | + } else{ |
|
73 | 73 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
74 | 74 | } |
75 | 75 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | if($this->driver->getConfig()['itemDetailedDate']){ |
85 | 85 | $this->creationDate = $date; |
86 | 86 | return $this; |
87 | - }else{ |
|
87 | + } else{ |
|
88 | 88 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
89 | 89 | } |
90 | 90 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | { |
98 | 98 | if($this->driver->getConfig()['itemDetailedDate']){ |
99 | 99 | return $this->modificationDate; |
100 | - }else{ |
|
100 | + } else{ |
|
101 | 101 | throw new \LogicException('Cannot access to the modification date when the "itemDetailedDate" configuration is disabled.'); |
102 | 102 | } |
103 | 103 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if($this->driver->getConfig()['itemDetailedDate']){ |
113 | 113 | $this->modificationDate = $date; |
114 | 114 | return $this; |
115 | - }else{ |
|
115 | + } else{ |
|
116 | 116 | throw new \LogicException('Cannot access to the creation date when the "itemDetailedDate" configuration is disabled.'); |
117 | 117 | } |
118 | 118 | } |
@@ -159,9 +159,9 @@ |
||
159 | 159 | public function driverPreWrap(ExtendedCacheItemInterface $item) |
160 | 160 | { |
161 | 161 | $wrap = [ |
162 | - self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | - self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | - self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
162 | + self::DRIVER_DATA_WRAPPER_INDEX => $item->get(), |
|
163 | + self::DRIVER_TAGS_WRAPPER_INDEX => $item->getTags(), |
|
164 | + self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
|
165 | 165 | ]; |
166 | 166 | |
167 | 167 | if($this->config['itemDetailedDate']){ |
@@ -273,7 +273,7 @@ |
||
273 | 273 | |
274 | 274 | if (!is_dir($path)) { |
275 | 275 | throw new phpFastCacheDriverException("Can't read PATH:" . $path, 94); |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $size = Directory::dirSize($path); |
278 | 278 | } |
279 | 279 |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if (is_array($config_name)) { |
53 | 53 | $this->config = array_merge($this->config, $config_name); |
54 | 54 | } else { |
55 | - $this->config[ $config_name ] = $value; |
|
55 | + $this->config[$config_name] = $value; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | self::DRIVER_EDATE_WRAPPER_INDEX => $item->getExpirationDate(), |
165 | 165 | ]; |
166 | 166 | |
167 | - if($this->config['itemDetailedDate']){ |
|
168 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = new \DateTime(); |
|
167 | + if ($this->config['itemDetailedDate']) { |
|
168 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = new \DateTime(); |
|
169 | 169 | /** |
170 | 170 | * If the creation date exists |
171 | 171 | * reuse it else set a new Date |
172 | 172 | */ |
173 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = $item->getCreationDate() ?: new \DateTime(); |
|
174 | - }else{ |
|
175 | - $wrap[ self::DRIVER_MDATE_WRAPPER_INDEX ] = null; |
|
176 | - $wrap[ self::DRIVER_CDATE_WRAPPER_INDEX ] = null; |
|
173 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = $item->getCreationDate() ?: new \DateTime(); |
|
174 | + } else { |
|
175 | + $wrap[self::DRIVER_MDATE_WRAPPER_INDEX] = null; |
|
176 | + $wrap[self::DRIVER_CDATE_WRAPPER_INDEX] = null; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $wrap; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function driverUnwrapData(array $wrapper) |
187 | 187 | { |
188 | - return $wrapper[ self::DRIVER_DATA_WRAPPER_INDEX ]; |
|
188 | + return $wrapper[self::DRIVER_DATA_WRAPPER_INDEX]; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function driverUnwrapTags(array $wrapper) |
196 | 196 | { |
197 | - return $wrapper[ self::DRIVER_TAGS_WRAPPER_INDEX ]; |
|
197 | + return $wrapper[self::DRIVER_TAGS_WRAPPER_INDEX]; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function driverUnwrapEdate(array $wrapper) |
206 | 206 | { |
207 | - return $wrapper[ self::DRIVER_EDATE_WRAPPER_INDEX ]; |
|
207 | + return $wrapper[self::DRIVER_EDATE_WRAPPER_INDEX]; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function driverUnwrapCdate(array $wrapper) |
215 | 215 | { |
216 | - return $wrapper[ self::DRIVER_CDATE_WRAPPER_INDEX ]; |
|
216 | + return $wrapper[self::DRIVER_CDATE_WRAPPER_INDEX]; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function driverUnwrapMdate(array $wrapper) |
225 | 225 | { |
226 | - return $wrapper[ self::DRIVER_MDATE_WRAPPER_INDEX ]; |
|
226 | + return $wrapper[self::DRIVER_MDATE_WRAPPER_INDEX]; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * on tags item, it can leads |
249 | 249 | * to an infinite recursive calls |
250 | 250 | */ |
251 | - if(strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX ) === 0){ |
|
251 | + if (strpos($item->getKey(), self::DRIVER_TAGS_KEY_PREFIX) === 0) { |
|
252 | 252 | throw new \LogicException('Trying to set tag(s) to an Tag item index: ' . $item->getKey()); |
253 | 253 | } |
254 | 254 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | foreach ($tagsItems as $tagsItem) { |
292 | 292 | $data = (array) $tagsItem->get(); |
293 | 293 | |
294 | - unset($data[ $item->getKey() ]); |
|
294 | + unset($data[$item->getKey()]); |
|
295 | 295 | $tagsItem->set($data); |
296 | 296 | |
297 | 297 | /** |