@@ -60,82 +60,82 @@ discard block |
||
60 | 60 | /** |
61 | 61 | * Specify if the item must provide detailed creation/modification dates |
62 | 62 | */ |
63 | - 'itemDetailedDate' => false, |
|
63 | + 'itemDetailedDate' => false, |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Automatically attempt to fallback to temporary directory |
67 | 67 | * if the cache fails to write on the specified directory |
68 | 68 | */ |
69 | - 'autoTmpFallback' => false, |
|
69 | + 'autoTmpFallback' => false, |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Provide a secure file manipulation mechanism |
73 | 73 | * on intensive usage the performance can be affected. |
74 | 74 | */ |
75 | - 'secureFileManipulation' => false, |
|
75 | + 'secureFileManipulation' => false, |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Ignore Symfony notice for Symfony project which |
79 | 79 | * do not makes use of PhpFastCache's Symfony Bundle |
80 | 80 | */ |
81 | - 'ignoreSymfonyNotice' => false, |
|
81 | + 'ignoreSymfonyNotice' => false, |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Default time-to-live in second |
85 | 85 | */ |
86 | - 'defaultTtl' => 900, |
|
86 | + 'defaultTtl' => 900, |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Default key hash function |
90 | 90 | * (md5 by default) |
91 | 91 | */ |
92 | - 'defaultKeyHashFunction' => '', |
|
92 | + 'defaultKeyHashFunction' => '', |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * The securityKey that will be used |
96 | 96 | * to create sub-directory |
97 | 97 | * (Files-based drivers only) |
98 | 98 | */ |
99 | - 'securityKey' => 'auto', |
|
99 | + 'securityKey' => 'auto', |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Auto-generate .htaccess if it's missing |
103 | 103 | * (Files-based drivers only) |
104 | 104 | */ |
105 | - 'htaccess' => true, |
|
105 | + 'htaccess' => true, |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Default files chmod |
109 | 109 | * 0777 recommended |
110 | 110 | * (Files-based drivers only) |
111 | 111 | */ |
112 | - 'default_chmod' => 0777, |
|
112 | + 'default_chmod' => 0777, |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * The path where we will writecache files |
116 | 116 | * default value if empty: sys_get_temp_dir() |
117 | 117 | * (Files-based drivers only) |
118 | 118 | */ |
119 | - 'path' => '', |
|
119 | + 'path' => '', |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Driver fallback in case of failure. |
123 | 123 | * Caution, in case of failure an E_WARNING |
124 | 124 | * error will always be raised |
125 | 125 | */ |
126 | - 'fallback' => false, |
|
126 | + 'fallback' => false, |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Maximum size (bytes) of object store in memory |
130 | 130 | * (Memcache(d) drivers only) |
131 | 131 | */ |
132 | - 'limited_memory_each_object' => 4096, |
|
132 | + 'limited_memory_each_object' => 4096, |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Compress stored data, if the backend supports it |
136 | 136 | * (Memcache(d) drivers only) |
137 | 137 | */ |
138 | - 'compress_data' => false, |
|
138 | + 'compress_data' => false, |
|
139 | 139 | ]; |
140 | 140 | |
141 | 141 | /** |
@@ -317,23 +317,23 @@ discard block |
||
317 | 317 | public static function getStaticSystemDrivers() |
318 | 318 | { |
319 | 319 | return [ |
320 | - 'Apc', |
|
321 | - 'Apcu', |
|
322 | - 'Cassandra', |
|
323 | - 'Couchbase', |
|
324 | - 'Devnull', |
|
325 | - 'Files', |
|
326 | - 'Leveldb', |
|
327 | - 'Memcache', |
|
328 | - 'Memcached', |
|
329 | - 'Memstatic', |
|
330 | - 'Mongodb', |
|
331 | - 'Predis', |
|
332 | - 'Redis', |
|
333 | - 'Ssdb', |
|
334 | - 'Sqlite', |
|
335 | - 'Wincache', |
|
336 | - 'Xcache', |
|
320 | + 'Apc', |
|
321 | + 'Apcu', |
|
322 | + 'Cassandra', |
|
323 | + 'Couchbase', |
|
324 | + 'Devnull', |
|
325 | + 'Files', |
|
326 | + 'Leveldb', |
|
327 | + 'Memcache', |
|
328 | + 'Memcached', |
|
329 | + 'Memstatic', |
|
330 | + 'Mongodb', |
|
331 | + 'Predis', |
|
332 | + 'Redis', |
|
333 | + 'Ssdb', |
|
334 | + 'Sqlite', |
|
335 | + 'Wincache', |
|
336 | + 'Xcache', |
|
337 | 337 | ]; |
338 | 338 | } |
339 | 339 | |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | public static function getStaticAllDrivers() |
344 | 344 | { |
345 | 345 | return array_merge(self::getStaticSystemDrivers(), [ |
346 | - 'Devtrue', |
|
347 | - 'Devfalse', |
|
348 | - 'Cookie', |
|
346 | + 'Devtrue', |
|
347 | + 'Devfalse', |
|
348 | + 'Cookie', |
|
349 | 349 | ]); |
350 | 350 | } |
351 | 351 |
@@ -169,32 +169,32 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | $instance = crc32($driver . serialize($config)); |
172 | - if (!isset(self::$instances[ $instance ])) { |
|
172 | + if (!isset(self::$instances[$instance])) { |
|
173 | 173 | $badPracticeOmeter[$driver] = 1; |
174 | - if(!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')){ |
|
174 | + if (!$config['ignoreSymfonyNotice'] && interface_exists('Symfony\Component\HttpKernel\KernelInterface') && !class_exists('phpFastCache\Bundle\phpFastCacheBundle')) { |
|
175 | 175 | 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); |
176 | 176 | } |
177 | 177 | $class = self::getNamespacePath() . $driver . '\Driver'; |
178 | - try{ |
|
179 | - self::$instances[ $instance ] = new $class($config); |
|
180 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
181 | - }catch(phpFastCacheDriverCheckException $e){ |
|
178 | + try { |
|
179 | + self::$instances[$instance] = new $class($config); |
|
180 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
181 | + } catch (phpFastCacheDriverCheckException $e) { |
|
182 | 182 | $fallback = self::standardizeDriverName($config['fallback']); |
183 | - if($fallback && $fallback !== $driver){ |
|
183 | + if ($fallback && $fallback !== $driver) { |
|
184 | 184 | $class = self::getNamespacePath() . $fallback . '\Driver'; |
185 | - self::$instances[ $instance ] = new $class($config); |
|
186 | - self::$instances[ $instance ]->setEventManager(EventManager::getInstance()); |
|
185 | + self::$instances[$instance] = new $class($config); |
|
186 | + self::$instances[$instance]->setEventManager(EventManager::getInstance()); |
|
187 | 187 | trigger_error(sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver, $fallback), E_USER_WARNING); |
188 | - }else{ |
|
188 | + } else { |
|
189 | 189 | throw new phpFastCacheDriverCheckException($e->getMessage(), $e->getCode(), $e); |
190 | 190 | } |
191 | 191 | } |
192 | - } else if(++$badPracticeOmeter[$driver] >= 5){ |
|
192 | + } else if (++$badPracticeOmeter[$driver] >= 5) { |
|
193 | 193 | trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. |
194 | 194 | See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F'); |
195 | 195 | } |
196 | 196 | |
197 | - return self::$instances[ $instance ]; |
|
197 | + return self::$instances[$instance]; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public static function __callStatic($name, $arguments) |
257 | 257 | { |
258 | - $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[ 0 ] : []); |
|
258 | + $options = (array_key_exists(0, $arguments) && is_array($arguments) ? $arguments[0] : []); |
|
259 | 259 | |
260 | 260 | return self::getInstance($name, $options); |
261 | 261 | } |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | { |
297 | 297 | if (is_array($name)) { |
298 | 298 | self::$config = array_merge(self::$config, $name); |
299 | - } else if (is_string($name)){ |
|
300 | - self::$config[ $name ] = $value; |
|
301 | - }else{ |
|
299 | + } else if (is_string($name)) { |
|
300 | + self::$config[$name] = $value; |
|
301 | + } else { |
|
302 | 302 | throw new phpFastCacheInvalidArgumentException('Invalid variable type: $name'); |
303 | 303 | } |
304 | 304 | } |
@@ -367,70 +367,70 @@ discard block |
||
367 | 367 | protected static function validateConfig(array $config) |
368 | 368 | { |
369 | 369 | foreach ($config as $configName => $configValue) { |
370 | - switch($configName) |
|
370 | + switch ($configName) |
|
371 | 371 | { |
372 | 372 | case 'itemDetailedDate': |
373 | - if(!is_bool($configValue)){ |
|
373 | + if (!is_bool($configValue)) { |
|
374 | 374 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
375 | 375 | } |
376 | 376 | break; |
377 | 377 | case 'autoTmpFallback': |
378 | - if(!is_bool($configValue)){ |
|
378 | + if (!is_bool($configValue)) { |
|
379 | 379 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
380 | 380 | } |
381 | 381 | break; |
382 | 382 | case 'secureFileManipulation': |
383 | - if(!is_bool($configValue)){ |
|
383 | + if (!is_bool($configValue)) { |
|
384 | 384 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
385 | 385 | } |
386 | 386 | break; |
387 | 387 | case 'ignoreSymfonyNotice': |
388 | - if(!is_bool($configValue)){ |
|
388 | + if (!is_bool($configValue)) { |
|
389 | 389 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
390 | 390 | } |
391 | 391 | break; |
392 | 392 | case 'defaultTtl': |
393 | - if(!is_numeric($configValue)){ |
|
393 | + if (!is_numeric($configValue)) { |
|
394 | 394 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be numeric"); |
395 | 395 | } |
396 | 396 | break; |
397 | 397 | case 'defaultKeyHashFunction': |
398 | - if(!is_string($configValue) && !is_callable($configValue)){ |
|
398 | + if (!is_string($configValue) && !is_callable($configValue)) { |
|
399 | 399 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a valid function name/closure"); |
400 | 400 | } |
401 | 401 | break; |
402 | 402 | case 'securityKey': |
403 | - if(!is_string($configValue)){ |
|
403 | + if (!is_string($configValue)) { |
|
404 | 404 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string"); |
405 | 405 | } |
406 | 406 | break; |
407 | 407 | case 'htaccess': |
408 | - if(!is_bool($configValue)){ |
|
408 | + if (!is_bool($configValue)) { |
|
409 | 409 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
410 | 410 | } |
411 | 411 | break; |
412 | 412 | case 'default_chmod': |
413 | - if(!is_int($configValue)){ |
|
413 | + if (!is_int($configValue)) { |
|
414 | 414 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer"); |
415 | 415 | } |
416 | 416 | break; |
417 | 417 | case 'path': |
418 | - if(!is_string($configValue)){ |
|
418 | + if (!is_string($configValue)) { |
|
419 | 419 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a string"); |
420 | 420 | } |
421 | 421 | break; |
422 | 422 | case 'fallback': |
423 | - if(!is_bool($configValue)){ |
|
423 | + if (!is_bool($configValue)) { |
|
424 | 424 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
425 | 425 | } |
426 | 426 | break; |
427 | 427 | case 'limited_memory_each_object': |
428 | - if(!is_int($configValue)){ |
|
428 | + if (!is_int($configValue)) { |
|
429 | 429 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be an integer"); |
430 | 430 | } |
431 | 431 | break; |
432 | 432 | case 'compress_data': |
433 | - if(!is_bool($configValue)){ |
|
433 | + if (!is_bool($configValue)) { |
|
434 | 434 | throw new phpFastCacheInvalidConfigurationException("{$configName} must be a boolean"); |
435 | 435 | } |
436 | 436 | break; |