Completed
Push — v7 ( 33961e...3db5c2 )
by Georges
02:15
created
lib/Phpfastcache/CacheManager.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Phpfastcache\Config\ConfigurationOption;
19 19
 use Phpfastcache\Core\Pool\ExtendedCacheItemPoolInterface;
20 20
 use Phpfastcache\Exceptions\{
21
-  PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException
21
+    PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException
22 22
 };
23 23
 use Phpfastcache\Util\ClassNamespaceResolverTrait;
24 24
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
         if (is_array($config)) {
103 103
             $config = new ConfigurationOption($config);
104 104
             trigger_error(
105
-              'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
106
-              E_USER_DEPRECATED
105
+                'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
106
+                E_USER_DEPRECATED
107 107
             );
108 108
         }elseif ($config === null){
109 109
             $config = self::getDefaultConfig();
@@ -304,27 +304,27 @@  discard block
 block discarded – undo
304 304
     {
305 305
         trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED);
306 306
         return [
307
-          'Apc',
308
-          'Apcu',
309
-          'Cassandra',
310
-          'Couchbase',
311
-          'Couchdb',
312
-          'Devnull',
313
-          'Files',
314
-          'Leveldb',
315
-          'Memcache',
316
-          'Memcached',
317
-          'Memstatic',
318
-          'Mongodb',
319
-          'Predis',
320
-          'Redis',
321
-          'Riak',
322
-          'Ssdb',
323
-          'Sqlite',
324
-          'Wincache',
325
-          'Xcache',
326
-          'Zenddisk',
327
-          'Zendshm',
307
+            'Apc',
308
+            'Apcu',
309
+            'Cassandra',
310
+            'Couchbase',
311
+            'Couchdb',
312
+            'Devnull',
313
+            'Files',
314
+            'Leveldb',
315
+            'Memcache',
316
+            'Memcached',
317
+            'Memstatic',
318
+            'Mongodb',
319
+            'Predis',
320
+            'Redis',
321
+            'Riak',
322
+            'Ssdb',
323
+            'Sqlite',
324
+            'Wincache',
325
+            'Xcache',
326
+            'Zenddisk',
327
+            'Zendshm',
328 328
         ];
329 329
     }
330 330
 
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
     {
337 337
         trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.', __METHOD__), E_USER_DEPRECATED);
338 338
         return \array_merge(self::getStaticSystemDrivers(), [
339
-          'Devtrue',
340
-          'Devfalse',
341
-          'Cookie',
339
+            'Devtrue',
340
+            'Devfalse',
341
+            'Cookie',
342 342
         ]);
343 343
     }
344 344
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @author Georges.L (Geolim4)  <[email protected]>
12 12
  *
13 13
  */
14
-declare(strict_types=1);
14
+declare(strict_types = 1);
15 15
 
16 16
 namespace Phpfastcache;
17 17
 
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
               'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
106 106
               E_USER_DEPRECATED
107 107
             );
108
-        }elseif ($config === null){
108
+        }elseif ($config === null) {
109 109
             $config = self::getDefaultConfig();
110
-        }else if(!($config instanceof ConfigurationOption)){
110
+        } else if (!($config instanceof ConfigurationOption)) {
111 111
             throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config)));
112 112
         }
113 113
 
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 
120 120
         $instance = $instanceId ?: md5($driver . \serialize($config->toArray()));
121 121
 
122
-        if (!isset(self::$instances[ $instance ])) {
123
-            $badPracticeOmeter[ $driver ] = 1;
122
+        if (!isset(self::$instances[$instance])) {
123
+            $badPracticeOmeter[$driver] = 1;
124 124
             $driverClass = self::getNamespacePath() . $driver . '\Driver';
125 125
             try {
126 126
                 if (\class_exists($driverClass)) {
127 127
                     $configClass = $driverClass::getConfigClass();
128
-                    self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance);
129
-                    self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
128
+                    self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance);
129
+                    self::$instances[$instance]->setEventManager(EventManager::getInstance());
130 130
                 } else {
131 131
                     throw new PhpfastcacheDriverNotFoundException(\sprintf('The driver "%s" does not exists', $driver));
132 132
                 }
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
                     throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
145 145
                 }
146 146
             }
147
-        } else if ($badPracticeOmeter[ $driver ] >= 2) {
147
+        } else if ($badPracticeOmeter[$driver] >= 2) {
148 148
             trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
149 149
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
150 150
         }
151 151
 
152
-        $badPracticeOmeter[ $driver ]++;
152
+        $badPracticeOmeter[$driver]++;
153 153
 
154
-        return self::$instances[ $instance ];
154
+        return self::$instances[$instance];
155 155
     }
156 156
 
157 157
     /**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
             throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string');
169 169
         }
170 170
 
171
-        if (isset(self::$instances[ $instanceId ])) {
172
-            return self::$instances[ $instanceId ];
171
+        if (isset(self::$instances[$instanceId])) {
172
+            return self::$instances[$instanceId];
173 173
         }
174 174
 
175 175
         throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId));
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
             }
227 227
         }
228 228
 
229
-        if(!$autoDriver || !\is_string($autoDriver)){
229
+        if (!$autoDriver || !\is_string($autoDriver)) {
230 230
             throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically');
231 231
         }
232 232
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface
242 242
     {
243
-        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []);
243
+        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []);
244 244
 
245 245
         return self::getInstance($name, $options);
246 246
     }
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
     {
351 351
         static $driverList;
352 352
 
353
-        if(self::getDefaultNamespacePath() === self::getNamespacePath()){
354
-            if($driverList === null){
353
+        if (self::getDefaultNamespacePath() === self::getNamespacePath()) {
354
+            if ($driverList === null) {
355 355
                 $prefix = 'Phpfastcache\Drivers\\';
356 356
                 $classMap = self::createClassMap(__DIR__ . '/Drivers');
357 357
                 $driverList = [];
358 358
 
359 359
                 foreach ($classMap as $class => $file) {
360
-                    $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') ));
360
+                    $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\')));
361 361
                 }
362 362
 
363 363
                 $driverList = array_values(array_unique($driverList));
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,9 +105,9 @@
 block discarded – undo
105 105
               'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
106 106
               E_USER_DEPRECATED
107 107
             );
108
-        }elseif ($config === null){
108
+        } elseif ($config === null){
109 109
             $config = self::getDefaultConfig();
110
-        }else if(!($config instanceof ConfigurationOption)){
110
+        } else if(!($config instanceof ConfigurationOption)){
111 111
             throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config)));
112 112
         }
113 113
 
Please login to merge, or discard this patch.