Passed
Push — main ( 523453...7c2b5d )
by Dimitri
11:41
created
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, DateInterval|int|null $ttl = null): bool
42
+    public function set(string $key, mixed $value, DateInterval | int | null $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, DateInterval|int|null $ttl = null): bool
50
+    public function setMultiple(iterable $values, DateInterval | int | null $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, DateInterval|int|null $ttl = null): bool
128
+    public function set(string $key, mixed $value, DateInterval | int | null $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
     /**
@@ -239,15 +239,15 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function groups(): array
241 241
     {
242
-        $result = [];
242
+        $result = [ ];
243 243
 
244
-        foreach ($this->_config['groups'] as $group) {
245
-            $value = $this->_Redis->get($this->_config['prefix'] . $group);
246
-            if (! $value) {
244
+        foreach ($this->_config[ 'groups' ] as $group) {
245
+            $value = $this->_Redis->get($this->_config[ 'prefix' ].$group);
246
+            if (!$value) {
247 247
                 $value = $this->serialize(1);
248
-                $this->_Redis->set($this->_config['prefix'] . $group, $value);
248
+                $this->_Redis->set($this->_config[ 'prefix' ].$group, $value);
249 249
             }
250
-            $result[] = $group . $value;
250
+            $result[ ] = $group.$value;
251 251
         }
252 252
 
253 253
         return $result;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function clearGroup(string $group): bool
260 260
     {
261
-        return (bool) $this->_Redis->incr($this->_config['prefix'] . $group);
261
+        return (bool) $this->_Redis->incr($this->_config[ 'prefix' ].$group);
262 262
     }
263 263
 
264 264
     /**
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      */
296 296
     public function __destruct()
297 297
     {
298
-        if (empty($this->_config['persistent']) && $this->_Redis instanceof Redis) {
298
+        if (empty($this->_config[ 'persistent' ]) && $this->_Redis instanceof Redis) {
299 299
             $this->_Redis->close();
300 300
         }
301 301
     }
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, DateInterval|int|null $ttl = null): bool
38
+    public function set(string $key, mixed $value, DateInterval | int | null $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.
Cache.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     /**
75 75
      * Configuration des caches
76 76
      */
77
-    protected array $config = [];
77
+    protected array $config = [ ];
78 78
 
79 79
     /**
80 80
      * Adapter a utiliser pour la mise en cache
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * Constructeur
86 86
      */
87
-    public function __construct(array $config = [])
87
+    public function __construct(array $config = [ ])
88 88
     {
89 89
         $this->setConfig($config);
90 90
     }
@@ -107,51 +107,51 @@  discard block
 block discarded – undo
107 107
      */
108 108
     protected function factory(): CacheInterface
109 109
     {
110
-        if (! static::$_enabled) {
110
+        if (!static::$_enabled) {
111 111
             return new Dummy();
112 112
         }
113
-        if (! empty($this->adapter)) {
113
+        if (!empty($this->adapter)) {
114 114
             return $this->adapter;
115 115
         }
116 116
 
117
-        $validHandlers = $this->config['valid_handlers'] ?? self::$validHandlers;
117
+        $validHandlers = $this->config[ 'valid_handlers' ] ?? self::$validHandlers;
118 118
 
119
-        if (empty($validHandlers) || ! is_array($validHandlers)) {
119
+        if (empty($validHandlers) || !is_array($validHandlers)) {
120 120
             throw new InvalidArgumentException('La configuration du cache doit avoir un tableau de $valid_handlers.');
121 121
         }
122 122
 
123
-        $handler  = $this->config['handler'] ?? null;
124
-        $fallback = $this->config['fallback_handler'] ?? null;
123
+        $handler  = $this->config[ 'handler' ] ?? null;
124
+        $fallback = $this->config[ 'fallback_handler' ] ?? null;
125 125
 
126 126
         if (empty($handler)) {
127 127
             throw new InvalidArgumentException('La configuration du cache doit avoir un ensemble de gestionnaires.');
128 128
         }
129 129
 
130
-        if (! array_key_exists($handler, $validHandlers)) {
130
+        if (!array_key_exists($handler, $validHandlers)) {
131 131
             throw new InvalidArgumentException('La configuration du cache a un gestionnaire non valide spécifié.');
132 132
         }
133 133
 
134
-        $adapter = new $validHandlers[$handler]();
135
-        if (! ($adapter instanceof BaseHandler)) {
134
+        $adapter = new $validHandlers[ $handler ]();
135
+        if (!($adapter instanceof BaseHandler)) {
136 136
             if (empty($fallback)) {
137 137
                 $adapter = new Dummy();
138
-            } elseif (! array_key_exists($fallback, $validHandlers)) {
138
+            } elseif (!array_key_exists($fallback, $validHandlers)) {
139 139
                 throw new InvalidArgumentException('La configuration du cache a un gestionnaire de secours non valide spécifié.');
140 140
             } else {
141
-                $adapter = new $validHandlers[$fallback]();
141
+                $adapter = new $validHandlers[ $fallback ]();
142 142
             }
143 143
         }
144 144
 
145
-        if (! ($adapter instanceof BaseHandler)) {
145
+        if (!($adapter instanceof BaseHandler)) {
146 146
             throw new InvalidArgumentException('Le gestionnaire de cache doit utiliser BlitzPHP\Cache\Handlers\BaseHandler comme classe de base.');
147 147
         }
148 148
 
149
-        if (isset($this->config[$handler]) && is_array($this->config[$handler])) {
150
-            $this->config = array_merge($this->config, $this->config[$handler]);
151
-            unset($this->config[$handler]);
149
+        if (isset($this->config[ $handler ]) && is_array($this->config[ $handler ])) {
150
+            $this->config = array_merge($this->config, $this->config[ $handler ]);
151
+            unset($this->config[ $handler ]);
152 152
         }
153 153
 
154
-        if (! $adapter->init($this->config)) {
154
+        if (!$adapter->init($this->config)) {
155 155
             throw new RuntimeException(
156 156
                 sprintf(
157 157
                     'Le moteur de cache %s n\'est pas correctement configuré. Consultez le journal des erreurs pour plus d\'informations.',
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @return bool Vrai si les données ont été mises en cache avec succès, faux en cas d'échec
183 183
      */
184
-    public function write(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
184
+    public function write(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
185 185
     {
186 186
         if (is_resource($value)) {
187 187
             return false;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     /**
207 207
      * {@inheritDoc}
208 208
      */
209
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
209
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
210 210
     {
211 211
         return $this->write($key, $value, $ttl);
212 212
     }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @throws InvalidArgumentException
233 233
      */
234
-    public function writeMany(iterable $data, DateInterval|int|null $ttl = null): bool
234
+    public function writeMany(iterable $data, DateInterval | int | null $ttl = null): bool
235 235
     {
236 236
         return $this->factory()->setMultiple($data, $ttl);
237 237
     }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     /**
240 240
      * {@inheritDoc}
241 241
      */
242
-    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool
242
+    public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool
243 243
     {
244 244
         return $this->writeMany($values, $ttl);
245 245
     }
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
      * @return mixed Si la clé est trouvée : les données en cache.
489 489
      *               Si la clé n'est pas trouvée, la valeur renvoyée par le callable.
490 490
      */
491
-    public function remember(string $key, callable|DateInterval|int|null $ttl, ?callable $callable = null): mixed
491
+    public function remember(string $key, callable | DateInterval | int | null $ttl, ?callable $callable = null): mixed
492 492
     {
493 493
         return $this->factory()->remember($key, $ttl, $callable);
494 494
     }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
      */
542 542
     public function pull(string $key, $default = null)
543 543
     {
544
-        return Helpers::tap($this->read($key, $default), function () use ($key) {
544
+        return Helpers::tap($this->read($key, $default), function() use ($key) {
545 545
             $this->delete($key);
546 546
         });
547 547
     }
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
      */
558 558
     public function pullMany(iterable $keys, $default = null)
559 559
     {
560
-        return Helpers::tap($this->readMany($keys, $default), function () use ($keys) {
560
+        return Helpers::tap($this->readMany($keys, $default), function() use ($keys) {
561 561
             $this->deleteMany($keys);
562 562
         });
563 563
     }
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 list<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, DateInterval|int|null $ttl = null): bool
46
+    public function set(string $key, mixed $value, DateInterval | int | null $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/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, DateInterval|int|null $ttl = null): bool
87
+    public function set(string $key, mixed $value, DateInterval | int | null $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/BaseHandler.php 1 patch
Spacing   +22 added lines, -22 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,20 +81,20 @@  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
-        if (isset($config['prefix'])) {
87
-            $config['prefix'] = str_replace(' ', '-', strtolower($config['prefix']));
86
+        if (isset($config[ 'prefix' ])) {
87
+            $config[ 'prefix' ] = str_replace(' ', '-', strtolower($config[ 'prefix' ]));
88 88
         }
89 89
 
90 90
         $this->setConfig($config);
91 91
 
92
-        if (! empty($this->_config['groups'])) {
93
-            sort($this->_config['groups']);
94
-            $this->_groupPrefix = str_repeat('%s_', count($this->_config['groups']));
92
+        if (!empty($this->_config[ 'groups' ])) {
93
+            sort($this->_config[ 'groups' ]);
94
+            $this->_groupPrefix = str_repeat('%s_', count($this->_config[ 'groups' ]));
95 95
         }
96
-        if (! is_numeric($this->_config['duration'])) {
97
-            $this->_config['duration'] = strtotime($this->_config['duration']) - time();
96
+        if (!is_numeric($this->_config[ 'duration' ])) {
97
+            $this->_config[ 'duration' ] = strtotime($this->_config[ 'duration' ]) - time();
98 98
         }
99 99
 
100 100
         return true;
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function ensureValidKey(string $key): void
117 117
     {
118
-        if (! is_string($key) || $key === '') {
118
+        if (!is_string($key) || $key === '') {
119 119
             throw new InvalidArgumentException('Une clé de cache doit être une chaîne non vide.');
120 120
         }
121 121
 
122 122
         $reserved = self::$reservedCharacters;
123 123
         if ($reserved && strpbrk($key, $reserved) !== false) {
124
-            throw new InvalidArgumentException('La clé de cache contient des caractères réservés ' . $reserved);
124
+            throw new InvalidArgumentException('La clé de cache contient des caractères réservés '.$reserved);
125 125
         }
126 126
     }
127 127
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     protected function ensureValidType($iterable, string $check = self::CHECK_VALUE): void
137 137
     {
138
-        if (! is_iterable($iterable)) {
138
+        if (!is_iterable($iterable)) {
139 139
             throw new InvalidArgumentException(sprintf(
140 140
                 'Un cache %s doit être soit un tableau soit un Traversable.',
141 141
                 $check === self::CHECK_VALUE ? 'key set' : 'set'
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @return mixed Si la clé est trouvée : les données en cache.
179 179
      *               Si la clé n'est pas trouvée, la valeur renvoyée par le callable.
180 180
      */
181
-    public function remember(string $key, callable|DateInterval|int|null $ttl, ?callable $callable = null): mixed
181
+    public function remember(string $key, callable | DateInterval | int | null $ttl, ?callable $callable = null): mixed
182 182
     {
183 183
         if (is_callable($ttl)) {
184 184
             $callable = $ttl;
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
     {
222 222
         $this->ensureValidType($keys);
223 223
 
224
-        $results = [];
224
+        $results = [ ];
225 225
 
226 226
         foreach ($keys as $key) {
227
-            $results[$key] = $this->get($key, $default);
227
+            $results[ $key ] = $this->get($key, $default);
228 228
         }
229 229
 
230 230
         return $results;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      * @throws InvalidArgumentException Si $values n'est ni un tableau ni un Traversable,
244 244
      *                                  ou si l'une des valeurs $ n'est pas une valeur légale.
245 245
      */
246
-    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool
246
+    public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool
247 247
     {
248 248
         $this->ensureValidType($values, self::CHECK_KEY);
249 249
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
         $result = true;
290 290
 
291 291
         foreach ($keys as $key) {
292
-            if (! $this->delete($key)) {
292
+            if (!$this->delete($key)) {
293 293
                 $result = false;
294 294
             }
295 295
         }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
      *
329 329
      * @return bool Vrai en cas de succès et faux en cas d'échec.
330 330
      */
331
-    abstract public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool;
331
+    abstract public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool;
332 332
 
333 333
     /**
334 334
      * {@inheritDoc}
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      */
386 386
     public function groups(): array
387 387
     {
388
-        return $this->_config['groups'];
388
+        return $this->_config[ 'groups' ];
389 389
     }
390 390
 
391 391
     /**
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
         }
411 411
         $key = preg_replace('/[\s]+/', '_', $key);
412 412
 
413
-        return $this->_config['prefix'] . $prefix . $key;
413
+        return $this->_config[ 'prefix' ].$prefix.$key;
414 414
     }
415 415
 
416 416
     /**
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
      * @param DateInterval|int|null $ttl La valeur TTL de cet élément. Si null est envoyé,
433 433
      *                                   La durée par défaut du conducteur sera utilisée.
434 434
      */
435
-    protected function duration(DateInterval|int|null $ttl): int
435
+    protected function duration(DateInterval | int | null $ttl): int
436 436
     {
437 437
         if ($ttl === null) {
438
-            return $this->_config['duration'];
438
+            return $this->_config[ 'duration' ];
439 439
         }
440 440
 
441 441
         if (is_int($ttl)) {
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, DateInterval|int|null $ttl = null): bool
47
+    public function set(string $key, mixed $value, DateInterval | int | null $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.
Handlers/FileVarExportHandler.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
     public function __construct(?string $path = null)
27 27
     {
28 28
         if (null === $path) {
29
-            $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'blitz-php' . DIRECTORY_SEPARATOR . 'cache';
29
+            $path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'blitz-php'.DIRECTORY_SEPARATOR.'cache';
30 30
         }
31 31
 
32 32
         $this->path = rtrim($path, '/\\');
33 33
 
34
-        if (! is_dir($this->path)) {
34
+        if (!is_dir($this->path)) {
35 35
             mkdir($this->path, 0777, true);
36 36
         }
37 37
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * {@inheritDoc}
49 49
      */
50
-    public function init(array $config = []): bool
50
+    public function init(array $config = [ ]): bool
51 51
     {
52 52
         return true;
53 53
     }
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @param array|bool|float|int|object|string|null $value
59 59
      */
60
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
60
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
61 61
     {
62 62
         $value = var_export($value, true);
63 63
 
64 64
         // Écrire d'abord dans le fichier temporaire pour assurer l'atomicité
65
-        $tmp = $this->path . "/{$key}." . uniqid('', true) . '.tmp';
66
-        file_put_contents($tmp, '<?php return ' . $value . ';', LOCK_EX);
65
+        $tmp = $this->path."/{$key}.".uniqid('', true).'.tmp';
66
+        file_put_contents($tmp, '<?php return '.$value.';', LOCK_EX);
67 67
 
68
-        return rename($tmp, $this->path . "/{$key}");
68
+        return rename($tmp, $this->path."/{$key}");
69 69
     }
70 70
 
71 71
     /**
72 72
      * {@inheritDoc}
73 73
      */
74
-    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool
74
+    public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool
75 75
     {
76 76
         return true;
77 77
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function get(string $key, mixed $default = null): mixed
85 85
     {
86
-        return @include $this->path . "/{$key}";
86
+        return @include $this->path."/{$key}";
87 87
     }
88 88
 
89 89
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function getMultiple(iterable $keys, mixed $default = null): iterable
93 93
     {
94
-        return [];
94
+        return [ ];
95 95
     }
96 96
 
97 97
     /**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function delete(string $key): bool
117 117
     {
118
-        return @unlink($this->path . "/{$key}");
118
+        return @unlink($this->path."/{$key}");
119 119
     }
120 120
 
121 121
     /**
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function clear(): bool
133 133
     {
134
-        if (! is_dir($this->path)) {
134
+        if (!is_dir($this->path)) {
135 135
             return false;
136 136
         }
137 137
 
138
-        $files = glob($this->path . '/*');
138
+        $files = glob($this->path.'/*');
139 139
 
140 140
         foreach ($files as $file) {
141 141
             if (is_file($file)) {
Please login to merge, or discard this patch.