Passed
Push — v7 ( 61f560...7e6987 )
by Georges
01:59
created
lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
     protected static function cleanFileName($filename): string
195 195
     {
196 196
         $regex = [
197
-          '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
198
-          '/\.$/',
199
-          '/^\./',
197
+            '/[\?\[\]\/\\\=\<\>\:\;\,\'\"\&\$\#\*\(\)\|\~\`\!\{\}]/',
198
+            '/\.$/',
199
+            '/^\./',
200 200
         ];
201 201
         $replace = ['-', '', ''];
202 202
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             $tmpFilename = Directory::getAbsolutePath(\dirname($file) . '/tmp_' . \md5(
293 293
                 \str_shuffle(\uniqid($this->getDriverName(), false))
294 294
                 . \str_shuffle(\uniqid($this->getDriverName(), false))
295
-              ));
295
+                ));
296 296
 
297 297
             $f = \fopen($tmpFilename, 'w+');
298 298
             \flock($f, \LOCK_EX);
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
         }
335 335
 
336 336
         $stat->setData(\implode(', ', \array_keys($this->itemInstances)))
337
-          ->setRawData([
337
+            ->setRawData([
338 338
             'tmp' => $this->tmp,
339
-          ])
340
-          ->setSize(Directory::dirSize($path))
341
-          ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
339
+            ])
340
+            ->setSize(Directory::dirSize($path))
341
+            ->setInfo('Number of files used to build the cache: ' . Directory::getFileCount($path));
342 342
 
343 343
         return $stat;
344 344
     }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 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\Core\Pool\IO;
17 17
 
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
         {
57 57
             $securityKey = $this->getConfig()->getSecurityKey();
58 58
             if (!$securityKey || \mb_strtolower($securityKey) === 'auto') {
59
-                if (isset($_SERVER[ 'HTTP_HOST' ])) {
60
-                    $securityKey = \preg_replace('/^www./', '', \strtolower(\str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ])));
59
+                if (isset($_SERVER['HTTP_HOST'])) {
60
+                    $securityKey = \preg_replace('/^www./', '', \strtolower(\str_replace(':', '_', $_SERVER['HTTP_HOST'])));
61 61
                 } else {
62 62
                     $securityKey = ($this->isPHPModule() ? 'web' : 'cli');
63 63
                 }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             return $full_path;
101 101
         }
102 102
 
103
-        if (!isset($this->tmp[ $full_path_hash ]) || (!@\file_exists($full_path) || !@\is_writable($full_path))) {
103
+        if (!isset($this->tmp[$full_path_hash]) || (!@\file_exists($full_path) || !@\is_writable($full_path))) {
104 104
             if (!@\file_exists($full_path)) {
105 105
                 @mkdir($full_path, $this->getDefaultChmod(), true);
106 106
             } else if (!@\is_writable($full_path)) {
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 throw new PhpfastcacheIOException('Path "' . $full_path . '" is not writable, please set a chmod 0777 or any writable permission and make sure to make use of an absolute path !');
126 126
             }
127 127
 
128
-            $this->tmp[ $full_path_hash ] = $full_path;
128
+            $this->tmp[$full_path_hash] = $full_path;
129 129
             $this->htaccessGen($full_path, \array_key_exists('htaccess', $this->getConfig()) ? $this->getConfig()->getHtaccess() : false);
130 130
         }
131 131
 
Please login to merge, or discard this patch.
lib/Phpfastcache/CacheManager.php 2 patches
Indentation   +36 added lines, -36 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
-  PhpfastcacheDriverCheckException, PhpfastcacheDriverException, PhpfastcacheDriverNotFoundException, PhpfastcacheInstanceNotFoundException, PhpfastcacheInvalidArgumentException, PhpfastcacheInvalidConfigurationException, PhpfastcacheLogicException, PhpfastcacheUnsupportedOperationException
21
+    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 {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                         $fallback = $config->getFallback();
158 158
                         $config->setFallback('');
159 159
                         \trigger_error(\sprintf('The "%s" driver is unavailable at the moment, the fallback driver "%s" has been used instead.', $driver,
160
-                          $fallback), E_USER_WARNING);
160
+                            $fallback), E_USER_WARNING);
161 161
                         return self::getInstance($fallback, $config->getFallbackConfig());
162 162
                     } catch (PhpfastcacheInvalidArgumentException $e) {
163 163
                         throw new PhpfastcacheInvalidConfigurationException('Invalid fallback driver configuration', 0, $e);
@@ -332,29 +332,29 @@  discard block
 block discarded – undo
332 332
     public static function getStaticSystemDrivers(): array
333 333
     {
334 334
         \trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.',
335
-          __METHOD__), E_USER_DEPRECATED);
335
+            __METHOD__), E_USER_DEPRECATED);
336 336
         return [
337
-          'Apc',
338
-          'Apcu',
339
-          'Cassandra',
340
-          'Couchbase',
341
-          'Couchdb',
342
-          'Devnull',
343
-          'Files',
344
-          'Leveldb',
345
-          'Memcache',
346
-          'Memcached',
347
-          'Memstatic',
348
-          'Mongodb',
349
-          'Predis',
350
-          'Redis',
351
-          'Riak',
352
-          'Ssdb',
353
-          'Sqlite',
354
-          'Wincache',
355
-          'Xcache',
356
-          'Zenddisk',
357
-          'Zendshm',
337
+            'Apc',
338
+            'Apcu',
339
+            'Cassandra',
340
+            'Couchbase',
341
+            'Couchdb',
342
+            'Devnull',
343
+            'Files',
344
+            'Leveldb',
345
+            'Memcache',
346
+            'Memcached',
347
+            'Memstatic',
348
+            'Mongodb',
349
+            'Predis',
350
+            'Redis',
351
+            'Riak',
352
+            'Ssdb',
353
+            'Sqlite',
354
+            'Wincache',
355
+            'Xcache',
356
+            'Zenddisk',
357
+            'Zendshm',
358 358
         ];
359 359
     }
360 360
 
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
     public static function getStaticAllDrivers(): array
366 366
     {
367 367
         \trigger_error(\sprintf('Method "%s" is deprecated as of the V7 and will be removed soon or later, use CacheManager::getDriverList() instead.',
368
-          __METHOD__), E_USER_DEPRECATED);
368
+            __METHOD__), E_USER_DEPRECATED);
369 369
         return \array_merge(self::getStaticSystemDrivers(), [
370
-          'Devtrue',
371
-          'Devfalse',
372
-          'Cookie',
370
+            'Devtrue',
371
+            'Devfalse',
372
+            'Cookie',
373 373
         ]);
374 374
     }
375 375
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 
449 449
         if (!\class_exists($className)) {
450 450
             throw new PhpfastcacheInvalidArgumentException(
451
-              \sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
451
+                \sprintf("Can't add '%s' because the class '%s' does not exists", $driverName, $className)
452 452
             );
453 453
         }
454 454
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 
503 503
         if (!\class_exists($className)) {
504 504
             throw new PhpfastcacheInvalidArgumentException(
505
-              \sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
505
+                \sprintf("Can't override '%s' because the class '%s' does not exists", $driverName, $className)
506 506
             );
507 507
         }
508 508
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 
517 517
         if (!\is_subclass_of($className, self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver', true)) {
518 518
             throw new PhpfastcacheLogicException(
519
-              \sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className,
519
+                \sprintf("Can't override '%s' because the class '%s' MUST extend '%s'", $driverName, $className,
520 520
                 self::CORE_DRIVER_NAMESPACE . $driverName . '\\Driver')
521 521
             );
522 522
         }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 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
 
@@ -132,8 +132,8 @@  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 139
             if (!is_a($driverClass, ExtendedCacheItemPoolInterface::class, true)) {
@@ -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
                 }
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
                     throw new PhpfastcacheDriverCheckException($e->getMessage(), $e->getCode(), $e);
167 167
                 }
168 168
             }
169
-        } else if (self::$badPracticeOmeter[ $driver ] >= 2) {
169
+        } else if (self::$badPracticeOmeter[$driver] >= 2) {
170 170
             \trigger_error('[' . $driver . '] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances.
171 171
            See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F');
172 172
         }
173 173
 
174
-        self::$badPracticeOmeter[ $driver ]++;
174
+        self::$badPracticeOmeter[$driver]++;
175 175
 
176
-        return self::$instances[ $instance ];
176
+        return self::$instances[$instance];
177 177
     }
178 178
 
179 179
     /**
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
             throw new PhpfastcacheInvalidArgumentException('The Instance ID must be a string');
191 191
         }
192 192
 
193
-        if (isset(self::$instances[ $instanceId ])) {
194
-            return self::$instances[ $instanceId ];
193
+        if (isset(self::$instances[$instanceId])) {
194
+            return self::$instances[$instanceId];
195 195
         }
196 196
 
197 197
         throw new PhpfastcacheInstanceNotFoundException(\sprintf('Instance ID %s not found', $instanceId));
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             throw new PhpfastcacheLogicException('Unable to find out a valid driver automatically');
256 256
         }
257 257
 
258
-        self::$badPracticeOmeter[ $autoDriver ]--;
258
+        self::$badPracticeOmeter[$autoDriver]--;
259 259
 
260 260
         return $autoDriver;
261 261
     }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      */
268 268
     public static function __callStatic(string $name, array $arguments): ExtendedCacheItemPoolInterface
269 269
     {
270
-        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[ 0 ] : []);
270
+        $options = (\array_key_exists(0, $arguments) && \is_array($arguments) ? $arguments[0] : []);
271 271
 
272 272
         return self::getInstance($name, $options);
273 273
     }
@@ -419,10 +419,10 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public static function getDriverClass(string $driverName): string
421 421
     {
422
-        if (!empty(self::$driverCustoms[ $driverName ])) {
423
-            $driverClass = self::$driverCustoms[ $driverName ];
424
-        } else if (!empty(self::$driverOverrides[ $driverName ])) {
425
-            $driverClass = self::$driverOverrides[ $driverName ];
422
+        if (!empty(self::$driverCustoms[$driverName])) {
423
+            $driverClass = self::$driverCustoms[$driverName];
424
+        } else if (!empty(self::$driverOverrides[$driverName])) {
425
+            $driverClass = self::$driverOverrides[$driverName];
426 426
         } else {
427 427
             $driverClass = self::getNamespacePath() . $driverName . '\Driver';
428 428
         }
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
             );
453 453
         }
454 454
 
455
-        if (!empty(self::$driverCustoms[ $driverName ])) {
455
+        if (!empty(self::$driverCustoms[$driverName])) {
456 456
             throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already added", $driverName));
457 457
         }
458 458
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
             throw new PhpfastcacheLogicException(\sprintf("Driver '%s' is already a part of the PhpFastCache core", $driverName));
461 461
         }
462 462
 
463
-        self::$driverCustoms[ $driverName ] = $className;
463
+        self::$driverCustoms[$driverName] = $className;
464 464
     }
465 465
 
466 466
     /**
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
             throw new PhpfastcacheInvalidArgumentException("Can't remove a custom driver because its name is empty");
478 478
         }
479 479
 
480
-        if (!isset(self::$driverCustoms[ $driverName ])) {
480
+        if (!isset(self::$driverCustoms[$driverName])) {
481 481
             throw new PhpfastcacheLogicException(\sprintf("Driver '%s' does not exists", $driverName));
482 482
         }
483 483
 
484
-        unset(self::$driverCustoms[ $driverName ]);
484
+        unset(self::$driverCustoms[$driverName]);
485 485
     }
486 486
 
487 487
     /**
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
             );
507 507
         }
508 508
 
509
-        if (!empty(self::$driverOverrides[ $driverName ])) {
509
+        if (!empty(self::$driverOverrides[$driverName])) {
510 510
             throw new PhpfastcacheLogicException(\sprintf("Driver '%s' has been already overridden", $driverName));
511 511
         }
512 512
 
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
             );
522 522
         }
523 523
 
524
-        self::$driverOverrides[ $driverName ] = $className;
524
+        self::$driverOverrides[$driverName] = $className;
525 525
     }
526 526
 
527 527
     /**
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
             throw new PhpfastcacheInvalidArgumentException("Can't remove a core driver override because its name is empty");
539 539
         }
540 540
 
541
-        if (!isset(self::$driverOverrides[ $driverName ])) {
541
+        if (!isset(self::$driverOverrides[$driverName])) {
542 542
             throw new PhpfastcacheLogicException(\sprintf("Driver '%s' were not overridden", $driverName));
543 543
         }
544 544
 
545
-        unset(self::$driverOverrides[ $driverName ]);
545
+        unset(self::$driverOverrides[$driverName]);
546 546
     }
547 547
 }
Please login to merge, or discard this patch.