Passed
Push — v7 ( a3bb3c...a1649b )
by Georges
01:44
created
lib/Phpfastcache/CacheManager.php 3 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
               'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
118 118
               E_USER_DEPRECATED
119 119
             );
120
-        }elseif ($config === null){
120
+        } elseif ($config === null){
121 121
             $config = self::getDefaultConfig();
122
-        }else if(!($config instanceof ConfigurationOption)){
122
+        } else if(!($config instanceof ConfigurationOption)){
123 123
             throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config)));
124 124
         }
125 125
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     {
405 405
         if(!empty(self::$driverCustoms[$driverName])){
406 406
             $driverClass = self::$driverCustoms[$driverName];
407
-        }else if(!empty(self::$driverOverrides[$driverName])){
407
+        } else if(!empty(self::$driverOverrides[$driverName])){
408 408
             $driverClass = self::$driverOverrides[$driverName];
409 409
         } else{
410 410
             $driverClass = self::getNamespacePath() . $driverName . '\Driver';
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 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, PhpfastcacheDriverException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException
21
+    PhpfastcacheDeprecatedException, PhpfastcacheDriverCheckException, PhpfastcacheDriverException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException
22 22
 };
23 23
 use Phpfastcache\Util\ClassNamespaceResolverTrait;
24 24
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
         if (\is_array($config)) {
116 116
             $config = new ConfigurationOption($config);
117 117
             \trigger_error(
118
-              'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
119
-              E_USER_DEPRECATED
118
+                'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
119
+                E_USER_DEPRECATED
120 120
             );
121 121
         }elseif ($config === null){
122 122
             $config = self::getDefaultConfig();
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 
139 139
             if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){
140 140
                 throw new PhpfastcacheDriverException(sprintf(
141
-                  'Class "%s" does not implement "%s"',
142
-                  $driverClass,
143
-                  ExtendedCacheItemPoolInterface::class
141
+                    'Class "%s" does not implement "%s"',
142
+                    $driverClass,
143
+                    ExtendedCacheItemPoolInterface::class
144 144
                 ));
145 145
             }
146 146
             try {
@@ -332,27 +332,27 @@  discard block
 block discarded – undo
332 332
     {
333 333
         \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);
334 334
         return [
335
-          'Apc',
336
-          'Apcu',
337
-          'Cassandra',
338
-          'Couchbase',
339
-          'Couchdb',
340
-          'Devnull',
341
-          'Files',
342
-          'Leveldb',
343
-          'Memcache',
344
-          'Memcached',
345
-          'Memstatic',
346
-          'Mongodb',
347
-          'Predis',
348
-          'Redis',
349
-          'Riak',
350
-          'Ssdb',
351
-          'Sqlite',
352
-          'Wincache',
353
-          'Xcache',
354
-          'Zenddisk',
355
-          'Zendshm',
335
+            'Apc',
336
+            'Apcu',
337
+            'Cassandra',
338
+            'Couchbase',
339
+            'Couchdb',
340
+            'Devnull',
341
+            'Files',
342
+            'Leveldb',
343
+            'Memcache',
344
+            'Memcached',
345
+            'Memstatic',
346
+            'Mongodb',
347
+            'Predis',
348
+            'Redis',
349
+            'Riak',
350
+            'Ssdb',
351
+            'Sqlite',
352
+            'Wincache',
353
+            'Xcache',
354
+            'Zenddisk',
355
+            'Zendshm',
356 356
         ];
357 357
     }
358 358
 
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
     {
365 365
         \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);
366 366
         return \array_merge(self::getStaticSystemDrivers(), [
367
-          'Devtrue',
368
-          'Devfalse',
369
-          'Cookie',
367
+            'Devtrue',
368
+            'Devfalse',
369
+            'Cookie',
370 370
         ]);
371 371
     }
372 372
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
         if(!\class_exists($className)){
446 446
             throw new PhpfastcacheInvalidArgumentException(
447
-              sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
447
+                sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
448 448
             );
449 449
         }
450 450
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
         if(!\class_exists($className)){
499 499
             throw new PhpfastcacheInvalidArgumentException(
500
-              sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
500
+                sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
501 501
             );
502 502
         }
503 503
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 
512 512
         if(!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)){
513 513
             throw new PhpfastcacheLogicException(
514
-              sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver')
514
+                sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver')
515 515
             );
516 516
         }
517 517
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 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
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
               'The CacheManager will drops the support of primitive configuration arrays, use a "\Phpfastcache\Config\ConfigurationOption" object instead',
119 119
               E_USER_DEPRECATED
120 120
             );
121
-        }elseif ($config === null){
121
+        }elseif ($config === null) {
122 122
             $config = self::getDefaultConfig();
123
-        }else if(!($config instanceof ConfigurationOption)){
123
+        } else if (!($config instanceof ConfigurationOption)) {
124 124
             throw new PhpfastcacheInvalidArgumentException(\sprintf('Unsupported config type: %s', gettype($config)));
125 125
         }
126 126
 
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 
133 133
         $instance = $instanceId ?: md5($driver . \serialize($config->toArray()));
134 134
 
135
-        if (!isset(self::$instances[ $instance ])) {
136
-            self::$badPracticeOmeter[ $driver ] = 1;
135
+        if (!isset(self::$instances[$instance])) {
136
+            self::$badPracticeOmeter[$driver] = 1;
137 137
             $driverClass = self::getDriverClass($driver);
138 138
 
139
-            if(!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)){
139
+            if (!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) {
140 140
                 throw new PhpfastcacheDriverException(sprintf(
141 141
                   'Class "%s" does not implement "%s"',
142 142
                   $driverClass,
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
             try {
147 147
                 if (\class_exists($driverClass)) {
148 148
                     $configClass = $driverClass::getConfigClass();
149
-                    self::$instances[ $instance ] = new $driverClass(new $configClass($config->toArray()), $instance);
150
-                    self::$instances[ $instance ]->setEventManager(EventManager::getInstance());
149
+                    self::$instances[$instance] = new $driverClass(new $configClass($config->toArray()), $instance);
150
+                    self::$instances[$instance]->setEventManager(EventManager::getInstance());
151 151
                 } else {
152 152
                     throw new PhpfastcacheDriverNotFoundException(\sprintf('The driver "%s" does not exists', $driver));
153 153
                 }
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
                     throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
166 166
                 }
167 167
             }
168
-        } else if (self::$badPracticeOmeter[ $driver ] >= 2) {
168
+        } else if (self::$badPracticeOmeter[$driver] >= 2) {
169 169
             \trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
170 170
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
171 171
         }
172 172
 
173
-        self::$badPracticeOmeter[ $driver ]++;
173
+        self::$badPracticeOmeter[$driver]++;
174 174
 
175
-        return self::$instances[ $instance ];
175
+        return self::$instances[$instance];
176 176
     }
177 177
 
178 178
     /**
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
             throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string');
190 190
         }
191 191
 
192
-        if (isset(self::$instances[ $instanceId ])) {
193
-            return self::$instances[ $instanceId ];
192
+        if (isset(self::$instances[$instanceId])) {
193
+            return self::$instances[$instanceId];
194 194
         }
195 195
 
196 196
         throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId));
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         if ($autoDriver === null) {
239 239
             foreach (self::getDriverList() as $driver) {
240 240
                 /** @var ExtendedCacheItemPoolInterface $driver */
241
-                if((self::CORE_DRIVER_NAMESPACE . $driver . '\Driver')::isUsableInAutoContext()){
241
+                if ((self::CORE_DRIVER_NAMESPACE . $driver . '\Driver')::isUsableInAutoContext()) {
242 242
                     try {
243 243
                         self::getInstance($driver, $config);
244 244
                         $autoDriver = $driver;
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
             }
251 251
         }
252 252
 
253
-        if(!$autoDriver || !\is_string($autoDriver)){
253
+        if (!$autoDriver || !\is_string($autoDriver)) {
254 254
             throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically');
255 255
         }
256 256
 
257
-        self::$badPracticeOmeter[ $autoDriver ]--;
257
+        self::$badPracticeOmeter[$autoDriver]--;
258 258
 
259 259
         return $autoDriver;
260 260
     }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface
268 268
     {
269
-        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []);
269
+        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []);
270 270
 
271 271
         return self::getInstance($name, $options);
272 272
     }
@@ -378,14 +378,14 @@  discard block
 block discarded – undo
378 378
     {
379 379
         static $driverList;
380 380
 
381
-        if(self::getDefaultNamespacePath() === self::getNamespacePath()){
382
-            if($driverList === null){
381
+        if (self::getDefaultNamespacePath() === self::getNamespacePath()) {
382
+            if ($driverList === null) {
383 383
                 $prefix = self::CORE_DRIVER_NAMESPACE;
384 384
                 $classMap = self::createClassMap(__DIR__ . '/Drivers');
385 385
                 $driverList = [];
386 386
 
387 387
                 foreach ($classMap as $class => $file) {
388
-                    $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\') ));
388
+                    $driverList[] = str_replace($prefix, '', substr($class, 0, strrpos($class, '\\')));
389 389
                 }
390 390
 
391 391
                 $driverList = array_values(array_unique($driverList));
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
      */
417 417
     public static function getDriverClass(string $driverName): string
418 418
     {
419
-        if(!empty(self::$driverCustoms[$driverName])){
419
+        if (!empty(self::$driverCustoms[$driverName])) {
420 420
             $driverClass = self::$driverCustoms[$driverName];
421
-        }else if(!empty(self::$driverOverrides[$driverName])){
421
+        } else if (!empty(self::$driverOverrides[$driverName])) {
422 422
             $driverClass = self::$driverOverrides[$driverName];
423
-        } else{
423
+        } else {
424 424
             $driverClass = self::getNamespacePath() . $driverName . '\Driver';
425 425
         }
426 426
 
@@ -435,24 +435,24 @@  discard block
 block discarded – undo
435 435
      * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException
436 436
      * @return void
437 437
      */
438
-    public static function addCustomDriver(string $driverName, string $className){
438
+    public static function addCustomDriver(string $driverName, string $className) {
439 439
         $driverName = self::standardizeDriverName($driverName);
440 440
 
441
-        if(empty($driverName)){
441
+        if (empty($driverName)) {
442 442
             throw new PhpfastcacheInvalidArgumentException("Can't add a custom driver because its name is empty");
443 443
         }
444 444
 
445
-        if(!\class_exists($className)){
445
+        if (!\class_exists($className)) {
446 446
             throw new PhpfastcacheInvalidArgumentException(
447 447
               sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
448 448
             );
449 449
         }
450 450
 
451
-        if(!empty(self::$driverCustoms[$driverName])){
451
+        if (!empty(self::$driverCustoms[$driverName])) {
452 452
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already added", $driverName));
453 453
         }
454 454
 
455
-        if(\in_array($driverName, self::getDriverList(), true)){
455
+        if (\in_array($driverName, self::getDriverList(), true)) {
456 456
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName));
457 457
         }
458 458
 
@@ -469,11 +469,11 @@  discard block
 block discarded – undo
469 469
     {
470 470
         $driverName = self::standardizeDriverName($driverName);
471 471
 
472
-        if(empty($driverName)){
472
+        if (empty($driverName)) {
473 473
             throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty");
474 474
         }
475 475
 
476
-        if(!isset(self::$driverCustoms[$driverName])){
476
+        if (!isset(self::$driverCustoms[$driverName])) {
477 477
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' does not exists", $driverName));
478 478
         }
479 479
 
@@ -488,28 +488,28 @@  discard block
 block discarded – undo
488 488
      * @throws \Phpfastcache\Exceptions\PhpfastcacheUnsupportedOperationException
489 489
      * @return void
490 490
      */
491
-    public static function addCoreDriverOverride(string $driverName, string $className){
491
+    public static function addCoreDriverOverride(string $driverName, string $className) {
492 492
         $driverName = self::standardizeDriverName($driverName);
493 493
 
494
-        if(empty($driverName)){
494
+        if (empty($driverName)) {
495 495
             throw new PhpfastcacheInvalidArgumentException("Can't add a core driver override because its name is empty");
496 496
         }
497 497
 
498
-        if(!\class_exists($className)){
498
+        if (!\class_exists($className)) {
499 499
             throw new PhpfastcacheInvalidArgumentException(
500 500
               sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
501 501
             );
502 502
         }
503 503
 
504
-        if(!empty(self::$driverOverrides[$driverName])){
504
+        if (!empty(self::$driverOverrides[$driverName])) {
505 505
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' has been already overridden", $driverName));
506 506
         }
507 507
 
508
-        if(!\in_array($driverName, self::getDriverList(), true)){
508
+        if (!\in_array($driverName, self::getDriverList(), true)) {
509 509
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' can't be overridden since its not a part of the PhpFastCache core", $driverName));
510 510
         }
511 511
 
512
-        if(!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)){
512
+        if (!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)) {
513 513
             throw new PhpfastcacheLogicException(
514 514
               sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver')
515 515
             );
@@ -528,11 +528,11 @@  discard block
 block discarded – undo
528 528
     {
529 529
         $driverName = self::standardizeDriverName($driverName);
530 530
 
531
-        if(empty($driverName)){
531
+        if (empty($driverName)) {
532 532
             throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty");
533 533
         }
534 534
 
535
-        if(!isset(self::$driverOverrides[$driverName])){
535
+        if (!isset(self::$driverOverrides[$driverName])) {
536 536
             throw new PhpfastcacheLogicException(sprintf("Driver '%s' were not overridden", $driverName));
537 537
         }
538 538
 
Please login to merge, or discard this patch.
lib/Phpfastcache/EventManager.php 1 patch
Spacing   +10 added lines, -10 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
 
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
          * due to performance issue on huge
77 77
          * loop dispatching operations
78 78
          */
79
-        if (isset($this->events[ $eventName ])) {
80
-            foreach ($this->events[ $eventName ] as $event) {
79
+        if (isset($this->events[$eventName])) {
80
+            foreach ($this->events[$eventName] as $event) {
81 81
                 call_user_func_array($event, $args);
82 82
             }
83 83
         }
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
     {
94 94
         if (\strpos($name, 'on') === 0) {
95 95
             $name = \substr($name, 2);
96
-            if (\is_callable($arguments[ 0 ])) {
97
-                if (isset($arguments[ 1 ]) && \is_string($arguments[ 0 ])) {
98
-                    $this->events[ $name ][ $arguments[ 1 ] ] = $arguments[ 0 ];
96
+            if (\is_callable($arguments[0])) {
97
+                if (isset($arguments[1]) && \is_string($arguments[0])) {
98
+                    $this->events[$name][$arguments[1]] = $arguments[0];
99 99
                 } else {
100
-                    $this->events[ $name ][] = $arguments[ 0 ];
100
+                    $this->events[$name][] = $arguments[0];
101 101
                 }
102 102
             } else {
103
-                throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[ 0 ])));
103
+                throw new PhpfastcacheInvalidArgumentException(\sprintf('Expected Callable, got "%s"', \gettype($arguments[0])));
104 104
             }
105 105
         } else {
106 106
             throw new \BadMethodCallException('An event must start with "on" such as "onCacheGetItem"');
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function unbindEventCallback(string $eventName, string $callbackName): bool
116 116
     {
117
-        $return = isset($this->events[ $eventName ][ $callbackName ]);
118
-        unset($this->events[ $eventName ][ $callbackName ]);
117
+        $return = isset($this->events[$eventName][$callbackName]);
118
+        unset($this->events[$eventName][$callbackName]);
119 119
 
120 120
         return $return;
121 121
     }
Please login to merge, or discard this patch.