Passed
Push — main ( 47f44b...c607be )
by Dimitri
12:45
created
Handlers/File.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected array $_defaultConfig = [
50 50
         'duration'  => 3600,
51
-        'groups'    => [],
51
+        'groups'    => [ ],
52 52
         'lock'      => true,
53 53
         'mask'      => 0o664,
54 54
         'path'      => null,
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * {@inheritDoc}
66 66
      */
67
-    public function init(array $config = []): bool
67
+    public function init(array $config = [ ]): bool
68 68
     {
69 69
         parent::init($config);
70 70
 
71
-        if ($this->_config['path'] === null) {
72
-            $this->_config['path'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'blitz-php' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
71
+        if ($this->_config[ 'path' ] === null) {
72
+            $this->_config[ 'path' ] = sys_get_temp_dir().DIRECTORY_SEPARATOR.'blitz-php'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
73 73
         }
74
-        if (substr($this->_config['path'], -1) !== DIRECTORY_SEPARATOR) {
75
-            $this->_config['path'] .= DIRECTORY_SEPARATOR;
74
+        if (substr($this->_config[ 'path' ], -1) !== DIRECTORY_SEPARATOR) {
75
+            $this->_config[ 'path' ] .= DIRECTORY_SEPARATOR;
76 76
         }
77 77
         if ($this->_groupPrefix) {
78 78
             $this->_groupPrefix = str_replace('_', DIRECTORY_SEPARATOR, $this->_groupPrefix);
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * {@inheritDoc}
86 86
      */
87
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
87
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
88 88
     {
89
-        if ($value === '' || ! $this->_init) {
89
+        if ($value === '' || !$this->_init) {
90 90
             return false;
91 91
         }
92 92
 
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
             return false;
97 97
         }
98 98
 
99
-        if (! empty($this->_config['serialize'])) {
99
+        if (!empty($this->_config[ 'serialize' ])) {
100 100
             $value = serialize($value);
101 101
         }
102 102
 
103 103
         $expires  = time() + $this->duration($ttl);
104
-        $contents = implode('', [$expires, PHP_EOL, $value, PHP_EOL]);
104
+        $contents = implode('', [ $expires, PHP_EOL, $value, PHP_EOL ]);
105 105
 
106
-        if ($this->_config['lock']) {
106
+        if ($this->_config[ 'lock' ]) {
107 107
             /** @psalm-suppress PossiblyNullReference */
108 108
             $this->_File->flock(LOCK_EX);
109 109
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             && $this->_File->fwrite($contents)
115 115
             && $this->_File->fflush();
116 116
 
117
-        if ($this->_config['lock']) {
117
+        if ($this->_config[ 'lock' ]) {
118 118
             $this->_File->flock(LOCK_UN);
119 119
         }
120 120
         $this->_File = null;
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
     {
130 130
         $key = $this->_key($key);
131 131
 
132
-        if (! $this->_init || $this->_setKey($key) === false) {
132
+        if (!$this->_init || $this->_setKey($key) === false) {
133 133
             return $default;
134 134
         }
135 135
 
136
-        if ($this->_config['lock']) {
136
+        if ($this->_config[ 'lock' ]) {
137 137
             /** @psalm-suppress PossiblyNullReference */
138 138
             $this->_File->flock(LOCK_SH);
139 139
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         $cachetime = (int) $this->_File->current();
145 145
 
146 146
         if ($cachetime < $time) {
147
-            if ($this->_config['lock']) {
147
+            if ($this->_config[ 'lock' ]) {
148 148
                 $this->_File->flock(LOCK_UN);
149 149
             }
150 150
 
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
             $this->_File->next();
161 161
         }
162 162
 
163
-        if ($this->_config['lock']) {
163
+        if ($this->_config[ 'lock' ]) {
164 164
             $this->_File->flock(LOCK_UN);
165 165
         }
166 166
 
167 167
         $data = trim($data);
168 168
 
169
-        if ($data !== '' && ! empty($this->_config['serialize'])) {
169
+        if ($data !== '' && !empty($this->_config[ 'serialize' ])) {
170 170
             $data = unserialize($data);
171 171
         }
172 172
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     {
181 181
         $key = $this->_key($key);
182 182
 
183
-        if ($this->_setKey($key) === false || ! $this->_init) {
183
+        if ($this->_setKey($key) === false || !$this->_init) {
184 184
             return false;
185 185
         }
186 186
 
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
      */
203 203
     public function clear(): bool
204 204
     {
205
-        if (! $this->_init) {
205
+        if (!$this->_init) {
206 206
             return false;
207 207
         }
208 208
         $this->_File = null;
209 209
 
210
-        $this->_clearDirectory($this->_config['path']);
210
+        $this->_clearDirectory($this->_config[ 'path' ]);
211 211
 
212 212
         $directory = new RecursiveDirectoryIterator(
213
-            $this->_config['path'],
213
+            $this->_config[ 'path' ],
214 214
             FilesystemIterator::SKIP_DOTS
215 215
         );
216 216
         $contents = new RecursiveIteratorIterator(
217 217
             $directory,
218 218
             RecursiveIteratorIterator::SELF_FIRST
219 219
         );
220
-        $cleared = [];
220
+        $cleared = [ ];
221 221
 
222 222
         /** @var SplFileInfo $fileInfo */
223 223
         foreach ($contents as $fileInfo) {
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
             }
229 229
 
230 230
             $realPath = $fileInfo->getRealPath();
231
-            if (! $realPath) {
231
+            if (!$realPath) {
232 232
                 unset($fileInfo);
233 233
 
234 234
                 continue;
235 235
             }
236 236
 
237
-            $path = $realPath . DIRECTORY_SEPARATOR;
238
-            if (! in_array($path, $cleared, true)) {
237
+            $path = $realPath.DIRECTORY_SEPARATOR;
238
+            if (!in_array($path, $cleared, true)) {
239 239
                 $this->_clearDirectory($path);
240
-                $cleared[] = $path;
240
+                $cleared[ ] = $path;
241 241
             }
242 242
 
243 243
             // les itérateurs internes possibles doivent également être désactivés pour que les verrous sur les parents soient libérés
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
      */
257 257
     protected function _clearDirectory(string $path): void
258 258
     {
259
-        if (! is_dir($path)) {
259
+        if (!is_dir($path)) {
260 260
             return;
261 261
         }
262 262
 
263 263
         $dir = dir($path);
264
-        if (! $dir) {
264
+        if (!$dir) {
265 265
             return;
266 266
         }
267 267
 
268
-        $prefixLength = strlen($this->_config['prefix']);
268
+        $prefixLength = strlen($this->_config[ 'prefix' ]);
269 269
 
270 270
         while (($entry = $dir->read()) !== false) {
271
-            if (substr($entry, 0, $prefixLength) !== $this->_config['prefix']) {
271
+            if (substr($entry, 0, $prefixLength) !== $this->_config[ 'prefix' ]) {
272 272
                 continue;
273 273
             }
274 274
 
275 275
             try {
276
-                $file = new SplFileObject($path . $entry, 'r');
276
+                $file = new SplFileObject($path.$entry, 'r');
277 277
             } catch (Exception $e) {
278 278
                 continue;
279 279
             }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      */
317 317
     public function info()
318 318
     {
319
-        return $this->getDirFileInfo($this->_config['path']);
319
+        return $this->getDirFileInfo($this->_config[ 'path' ]);
320 320
     }
321 321
 
322 322
     /**
@@ -333,15 +333,15 @@  discard block
 block discarded – undo
333 333
         if ($this->_groupPrefix) {
334 334
             $groups = vsprintf($this->_groupPrefix, $this->groups());
335 335
         }
336
-        $dir = $this->_config['path'] . $groups;
336
+        $dir = $this->_config[ 'path' ].$groups;
337 337
 
338
-        if (! is_dir($dir)) {
338
+        if (!is_dir($dir)) {
339 339
             mkdir($dir, 0o775, true);
340 340
         }
341 341
 
342
-        $path = new SplFileInfo($dir . $key);
342
+        $path = new SplFileInfo($dir.$key);
343 343
 
344
-        if (! $createKey && ! $path->isFile()) {
344
+        if (!$createKey && !$path->isFile()) {
345 345
             return false;
346 346
         }
347 347
         if (
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
             }
361 361
             unset($path);
362 362
 
363
-            if (! $exists && ! chmod($this->_File->getPathname(), (int) $this->_config['mask'])) {
363
+            if (!$exists && !chmod($this->_File->getPathname(), (int) $this->_config[ 'mask' ])) {
364 364
                 trigger_error(sprintf(
365 365
                     'Impossible d\'appliquer le masque d\'autorisation "%s" sur le fichier cache "%s"',
366 366
                     $this->_File->getPathname(),
367
-                    $this->_config['mask']
367
+                    $this->_config[ 'mask' ]
368 368
                 ), E_USER_WARNING);
369 369
             }
370 370
         }
@@ -377,21 +377,21 @@  discard block
 block discarded – undo
377 377
      */
378 378
     protected function _active(): bool
379 379
     {
380
-        $dir     = new SplFileInfo($this->_config['path']);
380
+        $dir     = new SplFileInfo($this->_config[ 'path' ]);
381 381
         $path    = $dir->getPathname();
382 382
         $success = true;
383
-        if (! is_dir($path)) {
383
+        if (!is_dir($path)) {
384 384
             // phpcs:disable
385 385
             $success = @mkdir($path, 0o775, true);
386 386
             // phpcs:enable
387 387
         }
388 388
 
389 389
         $isWritableDir = ($dir->isDir() && $dir->isWritable());
390
-        if (! $success || ($this->_init && ! $isWritableDir)) {
390
+        if (!$success || ($this->_init && !$isWritableDir)) {
391 391
             $this->_init = false;
392 392
             trigger_error(sprintf(
393 393
                 '%s is not writable',
394
-                $this->_config['path']
394
+                $this->_config[ 'path' ]
395 395
             ), E_USER_WARNING);
396 396
         }
397 397
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
         if (preg_match('/[\/\\<>?:|*"]/', $key)) {
409 409
             throw new InvalidArgumentException(
410
-                "La clé de cache `{$key}` contient des caractères non valides. " .
410
+                "La clé de cache `{$key}` contient des caractères non valides. ".
411 411
                 'Vous ne pouvez pas utiliser /, \\, <, >, ?, :, |, * ou " dans les clés de cache.'
412 412
             );
413 413
         }
@@ -422,17 +422,17 @@  discard block
 block discarded – undo
422 422
     {
423 423
         $this->_File = null;
424 424
 
425
-        $prefix = (string) $this->_config['prefix'];
425
+        $prefix = (string) $this->_config[ 'prefix' ];
426 426
 
427
-        $directoryIterator = new RecursiveDirectoryIterator($this->_config['path']);
427
+        $directoryIterator = new RecursiveDirectoryIterator($this->_config[ 'path' ]);
428 428
         $contents          = new RecursiveIteratorIterator(
429 429
             $directoryIterator,
430 430
             RecursiveIteratorIterator::CHILD_FIRST
431 431
         );
432 432
         $filtered = new CallbackFilterIterator(
433 433
             $contents,
434
-            static function (SplFileInfo $current) use ($group, $prefix) {
435
-                if (! $current->isFile()) {
434
+            static function(SplFileInfo $current) use ($group, $prefix) {
435
+                if (!$current->isFile()) {
436 436
                     return false;
437 437
                 }
438 438
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
                 $pos = strpos(
446 446
                     $current->getPathname(),
447
-                    DIRECTORY_SEPARATOR . $group . DIRECTORY_SEPARATOR
447
+                    DIRECTORY_SEPARATOR.$group.DIRECTORY_SEPARATOR
448 448
                 );
449 449
 
450 450
                 return $pos !== false;
@@ -479,23 +479,23 @@  discard block
 block discarded – undo
479 479
      */
480 480
     protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true, bool $_recursion = false)
481 481
     {
482
-        static $_filedata = [];
482
+        static $_filedata = [ ];
483 483
         $relativePath     = $sourceDir;
484 484
 
485 485
         if ($fp = @opendir($sourceDir)) {
486 486
             // réinitialise le tableau et s'assure que $source_dir a une barre oblique à la fin de l'appel initial
487 487
             if ($_recursion === false) {
488
-                $_filedata = [];
489
-                $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
488
+                $_filedata = [ ];
489
+                $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
490 490
             }
491 491
 
492 492
             // Utilisé pour être foreach (scandir($source_dir, 1) comme $file), mais scandir() n'est tout simplement pas aussi rapide
493 493
             while (false !== ($file = readdir($fp))) {
494
-                if (is_dir($sourceDir . $file) && $file[0] !== '.' && $topLevelOnly === false) {
495
-                    $this->getDirFileInfo($sourceDir . $file . DIRECTORY_SEPARATOR, $topLevelOnly, true);
496
-                } elseif (! is_dir($sourceDir . $file) && $file[0] !== '.') {
497
-                    $_filedata[$file]                  = $this->getFileInfo($sourceDir . $file);
498
-                    $_filedata[$file]['relative_path'] = $relativePath;
494
+                if (is_dir($sourceDir.$file) && $file[ 0 ] !== '.' && $topLevelOnly === false) {
495
+                    $this->getDirFileInfo($sourceDir.$file.DIRECTORY_SEPARATOR, $topLevelOnly, true);
496
+                } elseif (!is_dir($sourceDir.$file) && $file[ 0 ] !== '.') {
497
+                    $_filedata[ $file ]                  = $this->getFileInfo($sourceDir.$file);
498
+                    $_filedata[ $file ][ 'relative_path' ] = $relativePath;
499 499
                 }
500 500
             }
501 501
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
      *
518 518
      * @return array|false
519 519
      */
520
-    protected function getFileInfo(string $file, $returnedValues = ['name', 'server_path', 'size', 'date'])
520
+    protected function getFileInfo(string $file, $returnedValues = [ 'name', 'server_path', 'size', 'date' ])
521 521
     {
522
-        if (! is_file($file)) {
522
+        if (!is_file($file)) {
523 523
             return false;
524 524
         }
525 525
 
@@ -527,40 +527,40 @@  discard block
 block discarded – undo
527 527
             $returnedValues = explode(',', $returnedValues);
528 528
         }
529 529
 
530
-        $fileInfo = [];
530
+        $fileInfo = [ ];
531 531
 
532 532
         foreach ($returnedValues as $key) {
533 533
             switch ($key) {
534 534
                 case 'name':
535
-                    $fileInfo['name'] = basename($file);
535
+                    $fileInfo[ 'name' ] = basename($file);
536 536
                     break;
537 537
 
538 538
                 case 'server_path':
539
-                    $fileInfo['server_path'] = $file;
539
+                    $fileInfo[ 'server_path' ] = $file;
540 540
                     break;
541 541
 
542 542
                 case 'size':
543
-                    $fileInfo['size'] = filesize($file);
543
+                    $fileInfo[ 'size' ] = filesize($file);
544 544
                     break;
545 545
 
546 546
                 case 'date':
547
-                    $fileInfo['date'] = filemtime($file);
547
+                    $fileInfo[ 'date' ] = filemtime($file);
548 548
                     break;
549 549
 
550 550
                 case 'readable':
551
-                    $fileInfo['readable'] = is_readable($file);
551
+                    $fileInfo[ 'readable' ] = is_readable($file);
552 552
                     break;
553 553
 
554 554
                 case 'writable':
555
-                    $fileInfo['writable'] = is_writable($file);
555
+                    $fileInfo[ 'writable' ] = is_writable($file);
556 556
                     break;
557 557
 
558 558
                 case 'executable':
559
-                    $fileInfo['executable'] = is_executable($file);
559
+                    $fileInfo[ 'executable' ] = is_executable($file);
560 560
                     break;
561 561
 
562 562
                 case 'fileperms':
563
-                    $fileInfo['fileperms'] = fileperms($file);
563
+                    $fileInfo[ 'fileperms' ] = fileperms($file);
564 564
                     break;
565 565
             }
566 566
         }
Please login to merge, or discard this patch.
Handlers/Dummy.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     /**
32 32
      * {@inheritDoc}
33 33
      */
34
-    public function init(array $config = []): bool
34
+    public function init(array $config = [ ]): bool
35 35
     {
36 36
         return true;
37 37
     }
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * {@inheritDoc}
41 41
      */
42
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
42
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
43 43
     {
44 44
         return true;
45 45
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * {@inheritDoc}
49 49
      */
50
-    public function setMultiple(iterable $values, null|DateInterval|int $ttl = null): bool
50
+    public function setMultiple(iterable $values, null | DateInterval | int $ttl = null): bool
51 51
     {
52 52
         return true;
53 53
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function getMultiple(iterable $keys, mixed $default = null): iterable
67 67
     {
68
-        return [];
68
+        return [ ];
69 69
     }
70 70
 
71 71
     /**
Please login to merge, or discard this patch.
Handlers/RedisHandler.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     protected array $_defaultConfig = [
48 48
         'database'    => 0,
49 49
         'duration'    => 3600,
50
-        'groups'      => [],
50
+        'groups'      => [ ],
51 51
         'password'    => false,
52 52
         'persistent'  => true,
53 53
         'port'        => 6379,
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
     /**
62 62
      * {@inheritDoc}
63 63
      */
64
-    public function init(array $config = []): bool
64
+    public function init(array $config = [ ]): bool
65 65
     {
66
-        if (! extension_loaded('redis')) {
66
+        if (!extension_loaded('redis')) {
67 67
             throw new RuntimeException('L\'extension `redis` doit être activée pour utiliser RedisHandler.');
68 68
         }
69 69
 
70
-        if (! empty($config['host'])) {
71
-            $config['server'] = $config['host'];
70
+        if (!empty($config[ 'host' ])) {
71
+            $config[ 'server' ] = $config[ 'host' ];
72 72
         }
73 73
 
74 74
         parent::init($config);
@@ -85,20 +85,20 @@  discard block
 block discarded – undo
85 85
     {
86 86
         try {
87 87
             $this->_Redis = new Redis();
88
-            if (! empty($this->_config['unix_socket'])) {
89
-                $return = $this->_Redis->connect($this->_config['unix_socket']);
90
-            } elseif (empty($this->_config['persistent'])) {
88
+            if (!empty($this->_config[ 'unix_socket' ])) {
89
+                $return = $this->_Redis->connect($this->_config[ 'unix_socket' ]);
90
+            } elseif (empty($this->_config[ 'persistent' ])) {
91 91
                 $return = $this->_Redis->connect(
92
-                    $this->_config['server'],
93
-                    (int) $this->_config['port'],
94
-                    (int) $this->_config['timeout']
92
+                    $this->_config[ 'server' ],
93
+                    (int) $this->_config[ 'port' ],
94
+                    (int) $this->_config[ 'timeout' ]
95 95
                 );
96 96
             } else {
97
-                $persistentId = $this->_config['port'] . $this->_config['timeout'] . $this->_config['database'];
97
+                $persistentId = $this->_config[ 'port' ].$this->_config[ 'timeout' ].$this->_config[ 'database' ];
98 98
                 $return       = $this->_Redis->pconnect(
99
-                    $this->_config['server'],
100
-                    (int) $this->_config['port'],
101
-                    (int) $this->_config['timeout'],
99
+                    $this->_config[ 'server' ],
100
+                    (int) $this->_config[ 'port' ],
101
+                    (int) $this->_config[ 'timeout' ],
102 102
                     $persistentId
103 103
                 );
104 104
             }
@@ -106,17 +106,17 @@  discard block
 block discarded – undo
106 106
             if (function_exists('logger')) {
107 107
                 $logger = logger();
108 108
                 if (is_object($logger) && method_exists($logger, 'error')) {
109
-                    $logger->error('RedisEngine n\'a pas pu se connecter. Erreur: ' . $e->getMessage());
109
+                    $logger->error('RedisEngine n\'a pas pu se connecter. Erreur: '.$e->getMessage());
110 110
                 }
111 111
             }
112 112
 
113 113
             return false;
114 114
         }
115
-        if ($return && $this->_config['password']) {
116
-            $return = $this->_Redis->auth($this->_config['password']);
115
+        if ($return && $this->_config[ 'password' ]) {
116
+            $return = $this->_Redis->auth($this->_config[ 'password' ]);
117 117
         }
118 118
         if ($return) {
119
-            $return = $this->_Redis->select((int) $this->_config['database']);
119
+            $return = $this->_Redis->select((int) $this->_config[ 'database' ]);
120 120
         }
121 121
 
122 122
         return $return;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      * {@inheritDoc}
127 127
      */
128
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
128
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
129 129
     {
130 130
         $key   = $this->_key($key);
131 131
         $value = $this->serialize($value);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function increment(string $key, int $offset = 1)
158 158
     {
159
-        $duration = $this->_config['duration'];
159
+        $duration = $this->_config[ 'duration' ];
160 160
         $key      = $this->_key($key);
161 161
 
162 162
         $value = $this->_Redis->incrBy($key, $offset);
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public function decrement(string $key, int $offset = 1)
174 174
     {
175
-        $duration = $this->_config['duration'];
175
+        $duration = $this->_config[ 'duration' ];
176 176
         $key      = $this->_key($key);
177 177
 
178 178
         $value = $this->_Redis->decrBy($key, $offset);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
         $isAllDeleted = true;
204 204
         $iterator     = null;
205
-        $pattern      = $this->_config['prefix'] . '*';
205
+        $pattern      = $this->_config[ 'prefix' ].'*';
206 206
 
207 207
         while (true) {
208 208
             $keys = $this->_Redis->scan($iterator, $pattern);
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function add(string $key, mixed $value): bool
229 229
     {
230
-        $duration = $this->_config['duration'];
230
+        $duration = $this->_config[ 'duration' ];
231 231
         $key      = $this->_key($key);
232 232
         $value    = $this->serialize($value);
233 233
 
234
-        return (bool) ($this->_Redis->set($key, $value, ['nx', 'ex' => $duration]));
234
+        return (bool) ($this->_Redis->set($key, $value, [ 'nx', 'ex' => $duration ]));
235 235
     }
236 236
 
237 237
     /**
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public function groups(): array
249 249
     {
250
-        $result = [];
250
+        $result = [ ];
251 251
 
252
-        foreach ($this->_config['groups'] as $group) {
253
-            $value = $this->_Redis->get($this->_config['prefix'] . $group);
254
-            if (! $value) {
252
+        foreach ($this->_config[ 'groups' ] as $group) {
253
+            $value = $this->_Redis->get($this->_config[ 'prefix' ].$group);
254
+            if (!$value) {
255 255
                 $value = $this->serialize(1);
256
-                $this->_Redis->set($this->_config['prefix'] . $group, $value);
256
+                $this->_Redis->set($this->_config[ 'prefix' ].$group, $value);
257 257
             }
258
-            $result[] = $group . $value;
258
+            $result[ ] = $group.$value;
259 259
         }
260 260
 
261 261
         return $result;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public function clearGroup(string $group): bool
268 268
     {
269
-        return (bool) $this->_Redis->incr($this->_config['prefix'] . $group);
269
+        return (bool) $this->_Redis->incr($this->_config[ 'prefix' ].$group);
270 270
     }
271 271
 
272 272
     /**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      */
304 304
     public function __destruct()
305 305
     {
306
-        if (empty($this->_config['persistent']) && $this->_Redis instanceof Redis) {
306
+        if (empty($this->_config[ 'persistent' ]) && $this->_Redis instanceof Redis) {
307 307
             $this->_Redis->close();
308 308
         }
309 309
     }
Please login to merge, or discard this patch.
Handlers/Memcached.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     protected array $_defaultConfig = [
59 59
         'compress'   => false,
60 60
         'duration'   => 3600,
61
-        'groups'     => [],
61
+        'groups'     => [ ],
62 62
         'host'       => null,
63 63
         'username'   => null,
64 64
         'password'   => null,
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
         'port'       => null,
67 67
         'prefix'     => 'blitz_',
68 68
         'serialize'  => 'php',
69
-        'servers'    => ['127.0.0.1'],
70
-        'options'    => [],
69
+        'servers'    => [ '127.0.0.1' ],
70
+        'options'    => [ ],
71 71
     ];
72 72
 
73 73
     /**
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
      *
76 76
      * Memcached doit être compilé avec JSON et le support igbinary pour utiliser ces moteurs
77 77
      */
78
-    protected array $_serializers = [];
78
+    protected array $_serializers = [ ];
79 79
 
80 80
     /**
81 81
      * @var string[]
82 82
      */
83
-    protected array $_compiledGroupNames = [];
83
+    protected array $_compiledGroupNames = [ ];
84 84
 
85 85
     /**
86 86
      * {@inheritDoc}
87 87
      */
88
-    public function init(array $config = []): bool
88
+    public function init(array $config = [ ]): bool
89 89
     {
90
-        if (! extension_loaded('memcached')) {
90
+        if (!extension_loaded('memcached')) {
91 91
             throw new RuntimeException('L\'extension `memcached` doit être activée pour utiliser MemcachedHandler.');
92 92
         }
93 93
 
@@ -97,25 +97,25 @@  discard block
 block discarded – undo
97 97
             'php'      => BaseMemcached::SERIALIZER_PHP,
98 98
         ];
99 99
         if (defined('Memcached::HAVE_MSGPACK')) {
100
-            $this->_serializers['msgpack'] = BaseMemcached::SERIALIZER_MSGPACK;
100
+            $this->_serializers[ 'msgpack' ] = BaseMemcached::SERIALIZER_MSGPACK;
101 101
         }
102 102
 
103 103
         parent::init($config);
104 104
 
105
-        if (! empty($config['host'])) {
106
-            if (empty($config['port'])) {
107
-                $config['servers'] = [$config['host']];
105
+        if (!empty($config[ 'host' ])) {
106
+            if (empty($config[ 'port' ])) {
107
+                $config[ 'servers' ] = [ $config[ 'host' ] ];
108 108
             } else {
109
-                $config['servers'] = [sprintf('%s:%d', $config['host'], $config['port'])];
109
+                $config[ 'servers' ] = [ sprintf('%s:%d', $config[ 'host' ], $config[ 'port' ]) ];
110 110
             }
111 111
         }
112 112
 
113
-        if (isset($config['servers'])) {
114
-            $this->setConfig('servers', $config['servers'], false);
113
+        if (isset($config[ 'servers' ])) {
114
+            $this->setConfig('servers', $config[ 'servers' ], false);
115 115
         }
116 116
 
117
-        if (! is_array($this->_config['servers'])) {
118
-            $this->_config['servers'] = [$this->_config['servers']];
117
+        if (!is_array($this->_config[ 'servers' ])) {
118
+            $this->_config[ 'servers' ] = [ $this->_config[ 'servers' ] ];
119 119
         }
120 120
 
121 121
         /** @psalm-suppress RedundantPropertyInitializationCheck */
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
             return true;
124 124
         }
125 125
 
126
-        if ($this->_config['persistent']) {
127
-            $this->_Memcached = new BaseMemcached($this->_config['persistent']);
126
+        if ($this->_config[ 'persistent' ]) {
127
+            $this->_Memcached = new BaseMemcached($this->_config[ 'persistent' ]);
128 128
         } else {
129 129
             $this->_Memcached = new BaseMemcached();
130 130
         }
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
         if ($serverList) {
135 135
             if ($this->_Memcached->isPersistent()) {
136 136
                 foreach ($serverList as $server) {
137
-                    if (! in_array($server['host'] . ':' . $server['port'], $this->_config['servers'], true)) {
137
+                    if (!in_array($server[ 'host' ].':'.$server[ 'port' ], $this->_config[ 'servers' ], true)) {
138 138
                         throw new InvalidArgumentException(
139
-                            'Configuration du cache invalide. Plusieurs configurations de cache persistant sont détectées' .
140
-                            ' avec des valeurs `servers` différentes. `valeurs` des serveurs pour les configurations de cache persistant' .
139
+                            'Configuration du cache invalide. Plusieurs configurations de cache persistant sont détectées'.
140
+                            ' avec des valeurs `servers` différentes. `valeurs` des serveurs pour les configurations de cache persistant'.
141 141
                             ' doit être le même lors de l\'utilisation du même identifiant de persistance.'
142 142
                         );
143 143
                     }
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
             return true;
148 148
         }
149 149
 
150
-        $servers = [];
150
+        $servers = [ ];
151 151
 
152
-        foreach ($this->_config['servers'] as $server) {
153
-            $servers[] = $this->parseServerString($server);
152
+        foreach ($this->_config[ 'servers' ] as $server) {
153
+            $servers[ ] = $this->parseServerString($server);
154 154
         }
155 155
 
156
-        if (! $this->_Memcached->addServers($servers)) {
156
+        if (!$this->_Memcached->addServers($servers)) {
157 157
             return false;
158 158
         }
159 159
 
160
-        if (is_array($this->_config['options'])) {
161
-            foreach ($this->_config['options'] as $opt => $value) {
160
+        if (is_array($this->_config[ 'options' ])) {
161
+            foreach ($this->_config[ 'options' ] as $opt => $value) {
162 162
                 $this->_Memcached->setOption($opt, $value);
163 163
             }
164 164
         }
165 165
 
166
-        if (empty($this->_config['username']) && ! empty($this->_config['login'])) {
166
+        if (empty($this->_config[ 'username' ]) && !empty($this->_config[ 'login' ])) {
167 167
             throw new InvalidArgumentException(
168 168
                 'Veuillez passer "nom d\'utilisateur" au lieu de "login" pour vous connecter à Memcached'
169 169
             );
170 170
         }
171 171
 
172
-        if ($this->_config['username'] !== null && $this->_config['password'] !== null) {
173
-            if (! method_exists($this->_Memcached, 'setSaslAuthData')) {
172
+        if ($this->_config[ 'username' ] !== null && $this->_config[ 'password' ] !== null) {
173
+            if (!method_exists($this->_Memcached, 'setSaslAuthData')) {
174 174
                 throw new InvalidArgumentException(
175 175
                     "L'extension Memcached n'est pas construite avec le support SASL"
176 176
                 );
177 177
             }
178 178
             $this->_Memcached->setOption(BaseMemcached::OPT_BINARY_PROTOCOL, true);
179 179
             $this->_Memcached->setSaslAuthData(
180
-                $this->_config['username'],
181
-                $this->_config['password']
180
+                $this->_config[ 'username' ],
181
+                $this->_config[ 'password' ]
182 182
             );
183 183
         }
184 184
 
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
     {
195 195
         $this->_Memcached->setOption(BaseMemcached::OPT_LIBKETAMA_COMPATIBLE, true);
196 196
 
197
-        $serializer = strtolower($this->_config['serialize']);
198
-        if (! isset($this->_serializers[$serializer])) {
197
+        $serializer = strtolower($this->_config[ 'serialize' ]);
198
+        if (!isset($this->_serializers[ $serializer ])) {
199 199
             throw new InvalidArgumentException(
200 200
                 sprintf('%s n\'est pas un moteur de sérialisation valide pour Memcached', $serializer)
201 201
             );
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
         if (
205 205
             $serializer !== 'php'
206
-            && ! constant('Memcached::HAVE_' . strtoupper($serializer))
206
+            && !constant('Memcached::HAVE_'.strtoupper($serializer))
207 207
         ) {
208 208
             throw new InvalidArgumentException(
209 209
                 sprintf('L\'extension Memcached n\'est pas compilée avec la prise en charge de %s', $serializer)
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
         $this->_Memcached->setOption(
214 214
             BaseMemcached::OPT_SERIALIZER,
215
-            $this->_serializers[$serializer]
215
+            $this->_serializers[ $serializer ]
216 216
         );
217 217
 
218 218
         // Check for Amazon ElastiCache instance
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
         $this->_Memcached->setOption(
230 230
             BaseMemcached::OPT_COMPRESSION,
231
-            (bool) $this->_config['compress']
231
+            (bool) $this->_config[ 'compress' ]
232 232
         );
233 233
     }
234 234
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $socketTransport = 'unix://';
245 245
         if (str_starts_with($server, $socketTransport)) {
246
-            return [substr($server, strlen($socketTransport)), 0];
246
+            return [ substr($server, strlen($socketTransport)), 0 ];
247 247
         }
248 248
         if (substr($server, 0, 1) === '[') {
249 249
             $position = strpos($server, ']:');
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             $port = substr($server, $position + 1);
261 261
         }
262 262
 
263
-        return [$host, (int) $port];
263
+        return [ $host, (int) $port ];
264 264
     }
265 265
 
266 266
     /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      *
281 281
      * @see https://www.php.net/manual/en/memcached.set.php
282 282
      */
283
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
283
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
284 284
     {
285 285
         $duration = $this->duration($ttl);
286 286
 
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
     /**
291 291
      * {@inheritDoc}
292 292
      */
293
-    public function setMultiple(iterable $values, null|DateInterval|int $ttl = null): bool
293
+    public function setMultiple(iterable $values, null | DateInterval | int $ttl = null): bool
294 294
     {
295
-        $cacheData = [];
295
+        $cacheData = [ ];
296 296
 
297 297
         foreach ($values as $key => $value) {
298
-            $cacheData[$this->_key($key)] = $value;
298
+            $cacheData[ $this->_key($key) ] = $value;
299 299
         }
300 300
         $duration = $this->duration($ttl);
301 301
 
@@ -323,17 +323,17 @@  discard block
 block discarded – undo
323 323
      */
324 324
     public function getMultiple(iterable $keys, mixed $default = null): iterable
325 325
     {
326
-        $cacheKeys = [];
326
+        $cacheKeys = [ ];
327 327
 
328 328
         foreach ($keys as $key) {
329
-            $cacheKeys[$key] = $this->_key($key);
329
+            $cacheKeys[ $key ] = $this->_key($key);
330 330
         }
331 331
 
332 332
         $values = $this->_Memcached->getMulti($cacheKeys);
333
-        $return = [];
333
+        $return = [ ];
334 334
 
335 335
         foreach ($cacheKeys as $original => $prefixed) {
336
-            $return[$original] = $values[$prefixed] ?? $default;
336
+            $return[ $original ] = $values[ $prefixed ] ?? $default;
337 337
         }
338 338
 
339 339
         return $return;
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
      */
369 369
     public function deleteMultiple(iterable $keys): bool
370 370
     {
371
-        $cacheKeys = [];
371
+        $cacheKeys = [ ];
372 372
 
373 373
         foreach ($keys as $key) {
374
-            $cacheKeys[] = $this->_key($key);
374
+            $cacheKeys[ ] = $this->_key($key);
375 375
         }
376 376
 
377 377
         return (bool) $this->_Memcached->deleteMulti($cacheKeys);
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
         }
389 389
 
390 390
         foreach ($keys as $key) {
391
-            if (str_starts_with($key, $this->_config['prefix'])) {
391
+            if (str_starts_with($key, $this->_config[ 'prefix' ])) {
392 392
                 $this->_Memcached->delete($key);
393 393
             }
394 394
         }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      */
402 402
     public function add(string $key, mixed $value): bool
403 403
     {
404
-        $duration = $this->_config['duration'];
404
+        $duration = $this->_config[ 'duration' ];
405 405
         $key      = $this->_key($key);
406 406
 
407 407
         return $this->_Memcached->add($key, $value, $duration);
@@ -421,27 +421,27 @@  discard block
 block discarded – undo
421 421
     public function groups(): array
422 422
     {
423 423
         if (empty($this->_compiledGroupNames)) {
424
-            foreach ($this->_config['groups'] as $group) {
425
-                $this->_compiledGroupNames[] = $this->_config['prefix'] . $group;
424
+            foreach ($this->_config[ 'groups' ] as $group) {
425
+                $this->_compiledGroupNames[ ] = $this->_config[ 'prefix' ].$group;
426 426
             }
427 427
         }
428 428
 
429
-        $groups = $this->_Memcached->getMulti($this->_compiledGroupNames) ?: [];
430
-        if (count($groups) !== count($this->_config['groups'])) {
429
+        $groups = $this->_Memcached->getMulti($this->_compiledGroupNames) ?: [ ];
430
+        if (count($groups) !== count($this->_config[ 'groups' ])) {
431 431
             foreach ($this->_compiledGroupNames as $group) {
432
-                if (! isset($groups[$group])) {
432
+                if (!isset($groups[ $group ])) {
433 433
                     $this->_Memcached->set($group, 1, 0);
434
-                    $groups[$group] = 1;
434
+                    $groups[ $group ] = 1;
435 435
                 }
436 436
             }
437 437
             ksort($groups);
438 438
         }
439 439
 
440
-        $result = [];
440
+        $result = [ ];
441 441
         $groups = array_values($groups);
442 442
 
443
-        foreach ($this->_config['groups'] as $i => $group) {
444
-            $result[] = $group . $groups[$i];
443
+        foreach ($this->_config[ 'groups' ] as $i => $group) {
444
+            $result[ ] = $group.$groups[ $i ];
445 445
         }
446 446
 
447 447
         return $result;
@@ -452,6 +452,6 @@  discard block
 block discarded – undo
452 452
      */
453 453
     public function clearGroup(string $group): bool
454 454
     {
455
-        return (bool) $this->_Memcached->increment($this->_config['prefix'] . $group);
455
+        return (bool) $this->_Memcached->increment($this->_config[ 'prefix' ].$group);
456 456
     }
457 457
 }
Please login to merge, or discard this patch.
Handlers/ArrayHandler.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * Structuré comme [clé => [exp => expiration, val => valeur]]
32 32
      */
33
-    protected array $data = [];
33
+    protected array $data = [ ];
34 34
 
35 35
     /**
36 36
      * {@inheritDoc}
37 37
      */
38
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
38
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
39 39
     {
40 40
         $key              = $this->_key($key);
41 41
         $expires          = time() + $this->duration($ttl);
42
-        $this->data[$key] = ['exp' => $expires, 'val' => $value];
42
+        $this->data[ $key ] = [ 'exp' => $expires, 'val' => $value ];
43 43
 
44 44
         return true;
45 45
     }
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
     public function get(string $key, mixed $default = null): mixed
51 51
     {
52 52
         $key = $this->_key($key);
53
-        if (! isset($this->data[$key])) {
53
+        if (!isset($this->data[ $key ])) {
54 54
             return $default;
55 55
         }
56
-        $data = $this->data[$key];
56
+        $data = $this->data[ $key ];
57 57
 
58 58
         // Verifie l'expiration
59 59
         $now = time();
60
-        if ($data['exp'] <= $now) {
61
-            unset($this->data[$key]);
60
+        if ($data[ 'exp' ] <= $now) {
61
+            unset($this->data[ $key ]);
62 62
 
63 63
             return $default;
64 64
         }
65 65
 
66
-        return $data['val'];
66
+        return $data[ 'val' ];
67 67
     }
68 68
 
69 69
     /**
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
             $this->set($key, 0);
76 76
         }
77 77
         $key = $this->_key($key);
78
-        $this->data[$key]['val'] += $offset;
78
+        $this->data[ $key ][ 'val' ] += $offset;
79 79
 
80
-        return $this->data[$key]['val'];
80
+        return $this->data[ $key ][ 'val' ];
81 81
     }
82 82
 
83 83
     /**
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
             $this->set($key, 0);
90 90
         }
91 91
         $key = $this->_key($key);
92
-        $this->data[$key]['val'] -= $offset;
92
+        $this->data[ $key ][ 'val' ] -= $offset;
93 93
 
94
-        return $this->data[$key]['val'];
94
+        return $this->data[ $key ][ 'val' ];
95 95
     }
96 96
 
97 97
     /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     public function delete(string $key): bool
101 101
     {
102 102
         $key = $this->_key($key);
103
-        unset($this->data[$key]);
103
+        unset($this->data[ $key ]);
104 104
 
105 105
         return true;
106 106
     }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function clear(): bool
112 112
     {
113
-        $this->data = [];
113
+        $this->data = [ ];
114 114
 
115 115
         return true;
116 116
     }
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function groups(): array
122 122
     {
123
-        $result = [];
123
+        $result = [ ];
124 124
 
125
-        foreach ($this->_config['groups'] as $group) {
126
-            $key = $this->_config['prefix'] . $group;
127
-            if (! isset($this->data[$key])) {
128
-                $this->data[$key] = ['exp' => PHP_INT_MAX, 'val' => 1];
125
+        foreach ($this->_config[ 'groups' ] as $group) {
126
+            $key = $this->_config[ 'prefix' ].$group;
127
+            if (!isset($this->data[ $key ])) {
128
+                $this->data[ $key ] = [ 'exp' => PHP_INT_MAX, 'val' => 1 ];
129 129
             }
130
-            $value    = $this->data[$key]['val'];
131
-            $result[] = $group . $value;
130
+            $value    = $this->data[ $key ][ 'val' ];
131
+            $result[ ] = $group.$value;
132 132
         }
133 133
 
134 134
         return $result;
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function clearGroup(string $group): bool
141 141
     {
142
-        $key = $this->_config['prefix'] . $group;
143
-        if (isset($this->data[$key])) {
144
-            $this->data[$key]['val']++;
142
+        $key = $this->_config[ 'prefix' ].$group;
143
+        if (isset($this->data[ $key ])) {
144
+            $this->data[ $key ][ 'val' ]++;
145 145
         }
146 146
 
147 147
         return true;
Please login to merge, or discard this patch.
Handlers/Apcu.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @var string[]
28 28
      */
29
-    protected array $_compiledGroupNames = [];
29
+    protected array $_compiledGroupNames = [ ];
30 30
 
31 31
     /**
32 32
      * {@inheritDoc}
33 33
      */
34
-    public function init(array $config = []): bool
34
+    public function init(array $config = [ ]): bool
35 35
     {
36
-        if (! extension_loaded('apcu')) {
36
+        if (!extension_loaded('apcu')) {
37 37
             throw new RuntimeException('L\'extension `apcu` doit être activée pour utiliser ApcuHandler.');
38 38
         }
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * {@inheritDoc}
45 45
      */
46
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
46
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
47 47
     {
48 48
         $key      = $this->_key($key);
49 49
         $duration = $this->duration($ttl);
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     {
113 113
         if (class_exists(APCUIterator::class, false)) {
114 114
             $iterator = new APCUIterator(
115
-                '/^' . preg_quote($this->_config['prefix'], '/') . '/',
115
+                '/^'.preg_quote($this->_config[ 'prefix' ], '/').'/',
116 116
                 APC_ITER_NONE
117 117
             );
118 118
             apcu_delete($iterator);
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 
123 123
         $cache = apcu_cache_info(); // Déclenche déjà un avertissement par lui-même
124 124
 
125
-        foreach ($cache['cache_list'] as $key) {
126
-            if (str_starts_with($key['info'], $this->_config['prefix'])) {
127
-                apcu_delete($key['info']);
125
+        foreach ($cache[ 'cache_list' ] as $key) {
126
+            if (str_starts_with($key[ 'info' ], $this->_config[ 'prefix' ])) {
127
+                apcu_delete($key[ 'info' ]);
128 128
             }
129 129
         }
130 130
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     public function add(string $key, mixed $value): bool
140 140
     {
141 141
         $key      = $this->_key($key);
142
-        $duration = $this->_config['duration'];
142
+        $duration = $this->_config[ 'duration' ];
143 143
 
144 144
         return apcu_add($key, $value, $duration);
145 145
     }
@@ -153,33 +153,33 @@  discard block
 block discarded – undo
153 153
     public function groups(): array
154 154
     {
155 155
         if (empty($this->_compiledGroupNames)) {
156
-            foreach ($this->_config['groups'] as $group) {
157
-                $this->_compiledGroupNames[] = $this->_config['prefix'] . $group;
156
+            foreach ($this->_config[ 'groups' ] as $group) {
157
+                $this->_compiledGroupNames[ ] = $this->_config[ 'prefix' ].$group;
158 158
             }
159 159
         }
160 160
 
161 161
         $success = false;
162 162
         $groups  = apcu_fetch($this->_compiledGroupNames, $success);
163
-        if ($success && count($groups) !== count($this->_config['groups'])) {
163
+        if ($success && count($groups) !== count($this->_config[ 'groups' ])) {
164 164
             foreach ($this->_compiledGroupNames as $group) {
165
-                if (! isset($groups[$group])) {
165
+                if (!isset($groups[ $group ])) {
166 166
                     $value = 1;
167 167
                     if (apcu_store($group, $value) === false) {
168 168
                         $this->warning(
169 169
                             sprintf('Impossible de stocker la clé "%s" avec la valeur "%s" dans le cache APCu.', $group, $value)
170 170
                         );
171 171
                     }
172
-                    $groups[$group] = $value;
172
+                    $groups[ $group ] = $value;
173 173
                 }
174 174
             }
175 175
             ksort($groups);
176 176
         }
177 177
 
178
-        $result = [];
178
+        $result = [ ];
179 179
         $groups = array_values($groups);
180 180
 
181
-        foreach ($this->_config['groups'] as $i => $group) {
182
-            $result[] = $group . $groups[$i];
181
+        foreach ($this->_config[ 'groups' ] as $i => $group) {
182
+            $result[ ] = $group.$groups[ $i ];
183 183
         }
184 184
 
185 185
         return $result;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     public function clearGroup(string $group): bool
194 194
     {
195 195
         $success = false;
196
-        apcu_inc($this->_config['prefix'] . $group, 1, $success);
196
+        apcu_inc($this->_config[ 'prefix' ].$group, 1, $success);
197 197
 
198 198
         return $success;
199 199
     }
Please login to merge, or discard this patch.
Handlers/Wincache.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
      * Contient les noms de groupe compilés
26 26
      * (préfixé par le préfixe de configuration global)
27 27
      */
28
-    protected array $_compiledGroupNames = [];
28
+    protected array $_compiledGroupNames = [ ];
29 29
 
30 30
     /**
31 31
      * {@inheritDoc}
32 32
      */
33
-    public function init(array $config = []): bool
33
+    public function init(array $config = [ ]): bool
34 34
     {
35
-        if (! extension_loaded('wincache')) {
35
+        if (!extension_loaded('wincache')) {
36 36
             throw new RuntimeException('L\'extension `wincache` doit être activée pour utiliser WincacheHandler.');
37 37
         }
38 38
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     /**
45 45
      * {@inheritDoc}
46 46
      */
47
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
47
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
48 48
     {
49 49
         $key      = $this->_key($key);
50 50
         $duration = $this->duration($ttl);
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
     public function clear(): bool
102 102
     {
103 103
         $info      = wincache_ucache_info();
104
-        $cacheKeys = $info['ucache_entries'];
104
+        $cacheKeys = $info[ 'ucache_entries' ];
105 105
         unset($info);
106 106
 
107 107
         foreach ($cacheKeys as $key) {
108
-            if (str_starts_with($key['key_name'], $this->_config['prefix'])) {
109
-                wincache_ucache_delete($key['key_name']);
108
+            if (str_starts_with($key[ 'key_name' ], $this->_config[ 'prefix' ])) {
109
+                wincache_ucache_delete($key[ 'key_name' ]);
110 110
             }
111 111
         }
112 112
 
@@ -127,27 +127,27 @@  discard block
 block discarded – undo
127 127
     public function groups(): array
128 128
     {
129 129
         if (empty($this->_compiledGroupNames)) {
130
-            foreach ($this->_config['groups'] as $group) {
131
-                $this->_compiledGroupNames[] = $this->_config['prefix'] . $group;
130
+            foreach ($this->_config[ 'groups' ] as $group) {
131
+                $this->_compiledGroupNames[ ] = $this->_config[ 'prefix' ].$group;
132 132
             }
133 133
         }
134 134
 
135 135
         $groups = wincache_ucache_get($this->_compiledGroupNames);
136
-        if (count($groups) !== count($this->_config['groups'])) {
136
+        if (count($groups) !== count($this->_config[ 'groups' ])) {
137 137
             foreach ($this->_compiledGroupNames as $group) {
138
-                if (! isset($groups[$group])) {
138
+                if (!isset($groups[ $group ])) {
139 139
                     wincache_ucache_set($group, 1);
140
-                    $groups[$group] = 1;
140
+                    $groups[ $group ] = 1;
141 141
                 }
142 142
             }
143 143
             ksort($groups);
144 144
         }
145 145
 
146
-        $result = [];
146
+        $result = [ ];
147 147
         $groups = array_values($groups);
148 148
 
149
-        foreach ($this->_config['groups'] as $i => $group) {
150
-            $result[] = $group . $groups[$i];
149
+        foreach ($this->_config[ 'groups' ] as $i => $group) {
150
+            $result[ ] = $group.$groups[ $i ];
151 151
         }
152 152
 
153 153
         return $result;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     public function clearGroup(string $group): bool
160 160
     {
161 161
         $success = false;
162
-        wincache_ucache_inc($this->_config['prefix'] . $group, 1, $success);
162
+        wincache_ucache_inc($this->_config[ 'prefix' ].$group, 1, $success);
163 163
 
164 164
         return $success;
165 165
     }
Please login to merge, or discard this patch.
ResponseCache.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
      *                                        true       = Activé, prend en compte tous les paramètres de requête.
37 37
      *                                        Veuillez noter que cela peut entraîner de nombreux fichiers de cache générés encore et encore pour la même page.
38 38
      *                                        array('q') = Activé, mais ne prend en compte que la liste spécifiée de paramètres de requête.
39
-	 */
39
+     */
40 40
     public function __construct(private CacheInterface $cache, private array|bool $cacheQueryString = false)
41 41
     {
42 42
     }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      *                                        Veuillez noter que cela peut entraîner de nombreux fichiers de cache générés encore et encore pour la même page.
38 38
      *                                        array('q') = Activé, mais ne prend en compte que la liste spécifiée de paramètres de requête.
39 39
 	 */
40
-    public function __construct(private CacheInterface $cache, private array|bool $cacheQueryString = false)
40
+    public function __construct(private CacheInterface $cache, private array | bool $cacheQueryString = false)
41 41
     {
42 42
     }
43 43
 
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
             return true;
77 77
         }
78 78
 
79
-        $headers = [];
79
+        $headers = [ ];
80 80
 
81 81
         foreach (array_keys($response->getHeaders()) as $header) {
82
-            $headers[$header] = $response->getHeaderLine($header);
82
+            $headers[ $header ] = $response->getHeaderLine($header);
83 83
         }
84 84
 
85 85
         return $this->cache->set(
86 86
             $this->generateCacheKey($request),
87
-            serialize(['headers' => $headers, 'output' => $response->getBody()->getContents()]),
87
+            serialize([ 'headers' => $headers, 'output' => $response->getBody()->getContents() ]),
88 88
             $this->ttl
89 89
         );
90 90
     }
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
         if ($cachedResponse = $this->cache->get($this->generateCacheKey($request))) {
98 98
             $cachedResponse = unserialize($cachedResponse);
99 99
 
100
-            if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers'])) {
100
+            if (!is_array($cachedResponse) || !isset($cachedResponse[ 'output' ]) || !isset($cachedResponse[ 'headers' ])) {
101 101
                 throw new Exception('Erreur lors de la désérialisation du cache de page');
102 102
             }
103 103
 
104
-            $headers = $cachedResponse['headers'];
105
-            $output  = $cachedResponse['output'];
104
+            $headers = $cachedResponse[ 'headers' ];
105
+            $output  = $cachedResponse[ 'output' ];
106 106
 
107 107
             // Effacer tous les en-têtes par défaut
108 108
             foreach (array_keys($response->getHeaders()) as $key) {
Please login to merge, or discard this patch.
Handlers/BaseHandler.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -182,9 +182,9 @@
 block discarded – undo
182 182
             $ttl      = null;
183 183
         }
184 184
 
185
-		if (null !== $value = $this->get($key)) {
186
-			return $value;
187
-		}
185
+  if (null !== $value = $this->get($key)) {
186
+   return $value;
187
+  }
188 188
 
189 189
         $this->set($key, $value = $callable(), $ttl);
190 190
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     protected array $_defaultConfig = [
62 62
         'duration'            => 3600,
63
-        'groups'              => [],
63
+        'groups'              => [ ],
64 64
         'prefix'              => 'blitz_',
65 65
         'warnOnWriteFailures' => true,
66 66
     ];
@@ -81,16 +81,16 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return bool Vrai si le moteur a été initialisé avec succès, faux sinon
83 83
      */
84
-    public function init(array $config = []): bool
84
+    public function init(array $config = [ ]): bool
85 85
     {
86 86
         $this->setConfig($config);
87 87
 
88
-        if (! empty($this->_config['groups'])) {
89
-            sort($this->_config['groups']);
90
-            $this->_groupPrefix = str_repeat('%s_', count($this->_config['groups']));
88
+        if (!empty($this->_config[ 'groups' ])) {
89
+            sort($this->_config[ 'groups' ]);
90
+            $this->_groupPrefix = str_repeat('%s_', count($this->_config[ 'groups' ]));
91 91
         }
92
-        if (! is_numeric($this->_config['duration'])) {
93
-            $this->_config['duration'] = strtotime($this->_config['duration']) - time();
92
+        if (!is_numeric($this->_config[ 'duration' ])) {
93
+            $this->_config[ 'duration' ] = strtotime($this->_config[ 'duration' ]) - time();
94 94
         }
95 95
 
96 96
         return true;
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function ensureValidKey(string $key): void
113 113
     {
114
-        if (! is_string($key) || $key === '') {
114
+        if (!is_string($key) || $key === '') {
115 115
             throw new InvalidArgumentException('Une clé de cache doit être une chaîne non vide.');
116 116
         }
117 117
 
118 118
         $reserved = self::$reservedCharacters;
119 119
         if ($reserved && strpbrk($key, $reserved) !== false) {
120
-            throw new InvalidArgumentException('La clé de cache contient des caractères réservés ' . $reserved);
120
+            throw new InvalidArgumentException('La clé de cache contient des caractères réservés '.$reserved);
121 121
         }
122 122
     }
123 123
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function ensureValidType($iterable, string $check = self::CHECK_VALUE): void
133 133
     {
134
-        if (! is_iterable($iterable)) {
134
+        if (!is_iterable($iterable)) {
135 135
             throw new InvalidArgumentException(sprintf(
136 136
                 'Un cache %s doit être soit un tableau soit un Traversable.',
137 137
                 $check === self::CHECK_VALUE ? 'key set' : 'set'
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      * @return mixed Si la clé est trouvée : les données en cache.
176 176
      *               Si la clé n'est pas trouvée, la valeur renvoyée par le callable.
177 177
      */
178
-    public function remember(string $key, callable|DateInterval|int|null $ttl, callable $callable = null): mixed
178
+    public function remember(string $key, callable | DateInterval | int | null $ttl, callable $callable = null): mixed
179 179
     {
180 180
         if (is_callable($ttl)) {
181 181
             $callable = $ttl;
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
     {
219 219
         $this->ensureValidType($keys);
220 220
 
221
-        $results = [];
221
+        $results = [ ];
222 222
 
223 223
         foreach ($keys as $key) {
224
-            $results[$key] = $this->get($key, $default);
224
+            $results[ $key ] = $this->get($key, $default);
225 225
         }
226 226
 
227 227
         return $results;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      * @throws InvalidArgumentException Si $values n'est ni un tableau ni un Traversable,
241 241
      *                                  ou si l'une des valeurs $ n'est pas une valeur légale.
242 242
      */
243
-    public function setMultiple(iterable $values, null|DateInterval|int $ttl = null): bool
243
+    public function setMultiple(iterable $values, null | DateInterval | int $ttl = null): bool
244 244
     {
245 245
         $this->ensureValidType($values, self::CHECK_KEY);
246 246
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         $result = true;
287 287
 
288 288
         foreach ($keys as $key) {
289
-            if (! $this->delete($key)) {
289
+            if (!$this->delete($key)) {
290 290
                 $result = false;
291 291
             }
292 292
         }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      *
326 326
      * @return bool Vrai en cas de succès et faux en cas d'échec.
327 327
      */
328
-    abstract public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool;
328
+    abstract public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool;
329 329
 
330 330
     /**
331 331
      * {@inheritDoc}
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public function groups(): array
384 384
     {
385
-        return $this->_config['groups'];
385
+        return $this->_config[ 'groups' ];
386 386
     }
387 387
 
388 388
     /**
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
         }
408 408
         $key = preg_replace('/[\s]+/', '_', $key);
409 409
 
410
-        return $this->_config['prefix'] . $prefix . $key;
410
+        return $this->_config[ 'prefix' ].$prefix.$key;
411 411
     }
412 412
 
413 413
     /**
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
      * @param DateInterval|int|null $ttl La valeur TTL de cet élément. Si null est envoyé,
430 430
      *                                   La durée par défaut du conducteur sera utilisée.
431 431
      */
432
-    protected function duration(null|DateInterval|int $ttl): int
432
+    protected function duration(null | DateInterval | int $ttl): int
433 433
     {
434 434
         if ($ttl === null) {
435
-            return $this->_config['duration'];
435
+            return $this->_config[ 'duration' ];
436 436
         }
437 437
 
438 438
         if (is_int($ttl)) {
Please login to merge, or discard this patch.