@@ -31,7 +31,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | /** |
@@ -60,7 +60,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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' |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | { |
193 | 193 | $this->ensureValidType($keys); |
194 | 194 | |
195 | - $results = []; |
|
195 | + $results = [ ]; |
|
196 | 196 | |
197 | 197 | foreach ($keys as $key) { |
198 | - $results[$key] = $this->get($key, $default); |
|
198 | + $results[ $key ] = $this->get($key, $default); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return $results; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @throws InvalidArgumentException Si $values n'est ni un tableau ni un Traversable, |
215 | 215 | * ou si l'une des valeurs $ n'est pas une valeur légale. |
216 | 216 | */ |
217 | - public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool |
|
217 | + public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool |
|
218 | 218 | { |
219 | 219 | $this->ensureValidType($values, self::CHECK_KEY); |
220 | 220 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $result = true; |
261 | 261 | |
262 | 262 | foreach ($keys as $key) { |
263 | - if (! $this->delete($key)) { |
|
263 | + if (!$this->delete($key)) { |
|
264 | 264 | $result = false; |
265 | 265 | } |
266 | 266 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return bool Vrai en cas de succès et faux en cas d'échec. |
306 | 306 | */ |
307 | - abstract public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool; |
|
307 | + abstract public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool; |
|
308 | 308 | |
309 | 309 | /** |
310 | 310 | * {@inheritDoc} |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function groups(): array |
355 | 355 | { |
356 | - return $this->_config['groups']; |
|
356 | + return $this->_config[ 'groups' ]; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | $key = preg_replace('/[\s]+/', '_', $key); |
380 | 380 | |
381 | - return $this->_config['prefix'] . $prefix . $key; |
|
381 | + return $this->_config[ 'prefix' ].$prefix.$key; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | * @param DateInterval|int|null $ttl La valeur TTL de cet élément. Si null est envoyé, |
401 | 401 | * La durée par défaut du conducteur sera utilisée. |
402 | 402 | */ |
403 | - protected function duration(DateInterval|int|null $ttl): int |
|
403 | + protected function duration(DateInterval | int | null $ttl): int |
|
404 | 404 | { |
405 | 405 | if ($ttl === null) { |
406 | - return $this->_config['duration']; |
|
406 | + return $this->_config[ 'duration' ]; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (is_int($ttl)) { |
@@ -47,7 +47,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -58,7 +58,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
243 | 243 | { |
244 | 244 | $socketTransport = 'unix://'; |
245 | 245 | if (strpos($server, $socketTransport) === 0) { |
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 |
||
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 |
||
280 | 280 | * |
281 | 281 | * @see https://www.php.net/manual/en/memcached.set.php |
282 | 282 | */ |
283 | - public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool |
|
283 | + public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool |
|
284 | 284 | { |
285 | 285 | $duration = $this->duration($ttl); |
286 | 286 | |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | /** |
291 | 291 | * {@inheritDoc} |
292 | 292 | */ |
293 | - public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool |
|
293 | + public function setMultiple(iterable $values, DateInterval | int | null $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 |
||
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 |
||
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 |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | foreach ($keys as $key) { |
391 | - if (strpos($key, $this->_config['prefix']) === 0) { |
|
391 | + if (strpos($key, $this->_config[ 'prefix' ]) === 0) { |
|
392 | 392 | $this->_Memcached->delete($key); |
393 | 393 | } |
394 | 394 | } |
@@ -401,7 +401,7 @@ discard block |
||
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); |
@@ -413,27 +413,27 @@ discard block |
||
413 | 413 | public function groups(): array |
414 | 414 | { |
415 | 415 | if (empty($this->_compiledGroupNames)) { |
416 | - foreach ($this->_config['groups'] as $group) { |
|
417 | - $this->_compiledGroupNames[] = $this->_config['prefix'] . $group; |
|
416 | + foreach ($this->_config[ 'groups' ] as $group) { |
|
417 | + $this->_compiledGroupNames[ ] = $this->_config[ 'prefix' ].$group; |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | - $groups = $this->_Memcached->getMulti($this->_compiledGroupNames) ?: []; |
|
422 | - if (count($groups) !== count($this->_config['groups'])) { |
|
421 | + $groups = $this->_Memcached->getMulti($this->_compiledGroupNames) ?: [ ]; |
|
422 | + if (count($groups) !== count($this->_config[ 'groups' ])) { |
|
423 | 423 | foreach ($this->_compiledGroupNames as $group) { |
424 | - if (! isset($groups[$group])) { |
|
424 | + if (!isset($groups[ $group ])) { |
|
425 | 425 | $this->_Memcached->set($group, 1, 0); |
426 | - $groups[$group] = 1; |
|
426 | + $groups[ $group ] = 1; |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | ksort($groups); |
430 | 430 | } |
431 | 431 | |
432 | - $result = []; |
|
432 | + $result = [ ]; |
|
433 | 433 | $groups = array_values($groups); |
434 | 434 | |
435 | - foreach ($this->_config['groups'] as $i => $group) { |
|
436 | - $result[] = $group . $groups[$i]; |
|
435 | + foreach ($this->_config[ 'groups' ] as $i => $group) { |
|
436 | + $result[ ] = $group.$groups[ $i ]; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $result; |
@@ -444,6 +444,6 @@ discard block |
||
444 | 444 | */ |
445 | 445 | public function clearGroup(string $group): bool |
446 | 446 | { |
447 | - return (bool) $this->_Memcached->increment($this->_config['prefix'] . $group); |
|
447 | + return (bool) $this->_Memcached->increment($this->_config[ 'prefix' ].$group); |
|
448 | 448 | } |
449 | 449 | } |
@@ -30,16 +30,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -26,14 +26,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 (strpos($key['info'], $this->_config['prefix']) === 0) { |
|
127 | - apcu_delete($key['info']); |
|
125 | + foreach ($cache[ 'cache_list' ] as $key) { |
|
126 | + if (strpos($key[ 'info' ], $this->_config[ 'prefix' ]) === 0) { |
|
127 | + apcu_delete($key[ 'info' ]); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -139,7 +139,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -25,14 +25,14 @@ discard block |
||
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 |
||
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 |
||
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 (strpos($key['key_name'], $this->_config['prefix']) === 0) { |
|
109 | - wincache_ucache_delete($key['key_name']); |
|
108 | + if (strpos($key[ 'key_name' ], $this->_config[ 'prefix' ]) === 0) { |
|
109 | + wincache_ucache_delete($key[ 'key_name' ]); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -119,27 +119,27 @@ discard block |
||
119 | 119 | public function groups(): array |
120 | 120 | { |
121 | 121 | if (empty($this->_compiledGroupNames)) { |
122 | - foreach ($this->_config['groups'] as $group) { |
|
123 | - $this->_compiledGroupNames[] = $this->_config['prefix'] . $group; |
|
122 | + foreach ($this->_config[ 'groups' ] as $group) { |
|
123 | + $this->_compiledGroupNames[ ] = $this->_config[ 'prefix' ].$group; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | 127 | $groups = wincache_ucache_get($this->_compiledGroupNames); |
128 | - if (count($groups) !== count($this->_config['groups'])) { |
|
128 | + if (count($groups) !== count($this->_config[ 'groups' ])) { |
|
129 | 129 | foreach ($this->_compiledGroupNames as $group) { |
130 | - if (! isset($groups[$group])) { |
|
130 | + if (!isset($groups[ $group ])) { |
|
131 | 131 | wincache_ucache_set($group, 1); |
132 | - $groups[$group] = 1; |
|
132 | + $groups[ $group ] = 1; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | ksort($groups); |
136 | 136 | } |
137 | 137 | |
138 | - $result = []; |
|
138 | + $result = [ ]; |
|
139 | 139 | $groups = array_values($groups); |
140 | 140 | |
141 | - foreach ($this->_config['groups'] as $i => $group) { |
|
142 | - $result[] = $group . $groups[$i]; |
|
141 | + foreach ($this->_config[ 'groups' ] as $i => $group) { |
|
142 | + $result[ ] = $group.$groups[ $i ]; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $result; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | public function clearGroup(string $group): bool |
152 | 152 | { |
153 | 153 | $success = false; |
154 | - wincache_ucache_inc($this->_config['prefix'] . $group, 1, $success); |
|
154 | + wincache_ucache_inc($this->_config[ 'prefix' ].$group, 1, $success); |
|
155 | 155 | |
156 | 156 | return $success; |
157 | 157 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | protected array $_defaultConfig = [ |
50 | 50 | 'duration' => 3600, |
51 | - 'groups' => [], |
|
51 | + 'groups' => [ ], |
|
52 | 52 | 'lock' => true, |
53 | 53 | 'mask' => 0664, |
54 | 54 | 'path' => null, |
@@ -64,15 +64,15 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | /** @var SplFileInfo $fileInfo */ |
222 | 222 | foreach ($contents as $fileInfo) { |
223 | 223 | if ($fileInfo->isFile()) { |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | $realPath = $fileInfo->getRealPath(); |
230 | - if (! $realPath) { |
|
230 | + if (!$realPath) { |
|
231 | 231 | unset($fileInfo); |
232 | 232 | |
233 | 233 | continue; |
234 | 234 | } |
235 | 235 | |
236 | - $path = $realPath . DIRECTORY_SEPARATOR; |
|
237 | - if (! in_array($path, $cleared, true)) { |
|
236 | + $path = $realPath.DIRECTORY_SEPARATOR; |
|
237 | + if (!in_array($path, $cleared, true)) { |
|
238 | 238 | $this->_clearDirectory($path); |
239 | - $cleared[] = $path; |
|
239 | + $cleared[ ] = $path; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // les itérateurs internes possibles doivent également être désactivés pour que les verrous sur les parents soient libérés |
@@ -255,24 +255,24 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function _clearDirectory(string $path): void |
257 | 257 | { |
258 | - if (! is_dir($path)) { |
|
258 | + if (!is_dir($path)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $dir = dir($path); |
263 | - if (! $dir) { |
|
263 | + if (!$dir) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - $prefixLength = strlen($this->_config['prefix']); |
|
267 | + $prefixLength = strlen($this->_config[ 'prefix' ]); |
|
268 | 268 | |
269 | 269 | while (($entry = $dir->read()) !== false) { |
270 | - if (substr($entry, 0, $prefixLength) !== $this->_config['prefix']) { |
|
270 | + if (substr($entry, 0, $prefixLength) !== $this->_config[ 'prefix' ]) { |
|
271 | 271 | continue; |
272 | 272 | } |
273 | 273 | |
274 | 274 | try { |
275 | - $file = new SplFileObject($path . $entry, 'r'); |
|
275 | + $file = new SplFileObject($path.$entry, 'r'); |
|
276 | 276 | } catch (Exception $e) { |
277 | 277 | continue; |
278 | 278 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function info() |
317 | 317 | { |
318 | - return $this->getDirFileInfo($this->_config['path']); |
|
318 | + return $this->getDirFileInfo($this->_config[ 'path' ]); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -332,15 +332,15 @@ discard block |
||
332 | 332 | if ($this->_groupPrefix) { |
333 | 333 | $groups = vsprintf($this->_groupPrefix, $this->groups()); |
334 | 334 | } |
335 | - $dir = $this->_config['path'] . $groups; |
|
335 | + $dir = $this->_config[ 'path' ].$groups; |
|
336 | 336 | |
337 | - if (! is_dir($dir)) { |
|
337 | + if (!is_dir($dir)) { |
|
338 | 338 | mkdir($dir, 0775, true); |
339 | 339 | } |
340 | 340 | |
341 | - $path = new SplFileInfo($dir . $key); |
|
341 | + $path = new SplFileInfo($dir.$key); |
|
342 | 342 | |
343 | - if (! $createKey && ! $path->isFile()) { |
|
343 | + if (!$createKey && !$path->isFile()) { |
|
344 | 344 | return false; |
345 | 345 | } |
346 | 346 | if ( |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | } |
360 | 360 | unset($path); |
361 | 361 | |
362 | - if (! $exists && ! chmod($this->_File->getPathname(), (int) $this->_config['mask'])) { |
|
362 | + if (!$exists && !chmod($this->_File->getPathname(), (int) $this->_config[ 'mask' ])) { |
|
363 | 363 | trigger_error(sprintf( |
364 | 364 | 'Impossible d\'appliquer le masque d\'autorisation "%s" sur le fichier cache "%s"', |
365 | 365 | $this->_File->getPathname(), |
366 | - $this->_config['mask'] |
|
366 | + $this->_config[ 'mask' ] |
|
367 | 367 | ), E_USER_WARNING); |
368 | 368 | } |
369 | 369 | } |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | */ |
377 | 377 | protected function _active(): bool |
378 | 378 | { |
379 | - $dir = new SplFileInfo($this->_config['path']); |
|
379 | + $dir = new SplFileInfo($this->_config[ 'path' ]); |
|
380 | 380 | $path = $dir->getPathname(); |
381 | 381 | $success = true; |
382 | - if (! is_dir($path)) { |
|
382 | + if (!is_dir($path)) { |
|
383 | 383 | // phpcs:disable |
384 | 384 | $success = @mkdir($path, 0775, true); |
385 | 385 | // phpcs:enable |
386 | 386 | } |
387 | 387 | |
388 | 388 | $isWritableDir = ($dir->isDir() && $dir->isWritable()); |
389 | - if (! $success || ($this->_init && ! $isWritableDir)) { |
|
389 | + if (!$success || ($this->_init && !$isWritableDir)) { |
|
390 | 390 | $this->_init = false; |
391 | 391 | trigger_error(sprintf( |
392 | 392 | '%s is not writable', |
393 | - $this->_config['path'] |
|
393 | + $this->_config[ 'path' ] |
|
394 | 394 | ), E_USER_WARNING); |
395 | 395 | } |
396 | 396 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | |
407 | 407 | if (preg_match('/[\/\\<>?:|*"]/', $key)) { |
408 | 408 | throw new InvalidArgumentException( |
409 | - "La clé de cache `{$key}` contient des caractères non valides. " . |
|
409 | + "La clé de cache `{$key}` contient des caractères non valides. ". |
|
410 | 410 | 'Vous ne pouvez pas utiliser /, \\, <, >, ?, :, |, * ou " dans les clés de cache.' |
411 | 411 | ); |
412 | 412 | } |
@@ -421,17 +421,17 @@ discard block |
||
421 | 421 | { |
422 | 422 | $this->_File = null; |
423 | 423 | |
424 | - $prefix = (string) $this->_config['prefix']; |
|
424 | + $prefix = (string) $this->_config[ 'prefix' ]; |
|
425 | 425 | |
426 | - $directoryIterator = new RecursiveDirectoryIterator($this->_config['path']); |
|
426 | + $directoryIterator = new RecursiveDirectoryIterator($this->_config[ 'path' ]); |
|
427 | 427 | $contents = new RecursiveIteratorIterator( |
428 | 428 | $directoryIterator, |
429 | 429 | RecursiveIteratorIterator::CHILD_FIRST |
430 | 430 | ); |
431 | 431 | $filtered = new CallbackFilterIterator( |
432 | 432 | $contents, |
433 | - static function (SplFileInfo $current) use ($group, $prefix) { |
|
434 | - if (! $current->isFile()) { |
|
433 | + static function(SplFileInfo $current) use ($group, $prefix) { |
|
434 | + if (!$current->isFile()) { |
|
435 | 435 | return false; |
436 | 436 | } |
437 | 437 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | |
444 | 444 | $pos = strpos( |
445 | 445 | $current->getPathname(), |
446 | - DIRECTORY_SEPARATOR . $group . DIRECTORY_SEPARATOR |
|
446 | + DIRECTORY_SEPARATOR.$group.DIRECTORY_SEPARATOR |
|
447 | 447 | ); |
448 | 448 | |
449 | 449 | return $pos !== false; |
@@ -478,23 +478,23 @@ discard block |
||
478 | 478 | */ |
479 | 479 | protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true, bool $_recursion = false) |
480 | 480 | { |
481 | - static $_filedata = []; |
|
481 | + static $_filedata = [ ]; |
|
482 | 482 | $relativePath = $sourceDir; |
483 | 483 | |
484 | 484 | if ($fp = @opendir($sourceDir)) { |
485 | 485 | // réinitialise le tableau et s'assure que $source_dir a une barre oblique à la fin de l'appel initial |
486 | 486 | if ($_recursion === false) { |
487 | - $_filedata = []; |
|
488 | - $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
487 | + $_filedata = [ ]; |
|
488 | + $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | // Utilisé pour être foreach (scandir($source_dir, 1) comme $file), mais scandir() n'est tout simplement pas aussi rapide |
492 | 492 | while (false !== ($file = readdir($fp))) { |
493 | - if (is_dir($sourceDir . $file) && $file[0] !== '.' && $topLevelOnly === false) { |
|
494 | - $this->getDirFileInfo($sourceDir . $file . DIRECTORY_SEPARATOR, $topLevelOnly, true); |
|
495 | - } elseif (! is_dir($sourceDir . $file) && $file[0] !== '.') { |
|
496 | - $_filedata[$file] = $this->getFileInfo($sourceDir . $file); |
|
497 | - $_filedata[$file]['relative_path'] = $relativePath; |
|
493 | + if (is_dir($sourceDir.$file) && $file[ 0 ] !== '.' && $topLevelOnly === false) { |
|
494 | + $this->getDirFileInfo($sourceDir.$file.DIRECTORY_SEPARATOR, $topLevelOnly, true); |
|
495 | + } elseif (!is_dir($sourceDir.$file) && $file[ 0 ] !== '.') { |
|
496 | + $_filedata[ $file ] = $this->getFileInfo($sourceDir.$file); |
|
497 | + $_filedata[ $file ][ 'relative_path' ] = $relativePath; |
|
498 | 498 | } |
499 | 499 | } |
500 | 500 | |
@@ -516,9 +516,9 @@ discard block |
||
516 | 516 | * |
517 | 517 | * @return array|false |
518 | 518 | */ |
519 | - protected function getFileInfo(string $file, $returnedValues = ['name', 'server_path', 'size', 'date']) |
|
519 | + protected function getFileInfo(string $file, $returnedValues = [ 'name', 'server_path', 'size', 'date' ]) |
|
520 | 520 | { |
521 | - if (! is_file($file)) { |
|
521 | + if (!is_file($file)) { |
|
522 | 522 | return false; |
523 | 523 | } |
524 | 524 | |
@@ -526,40 +526,40 @@ discard block |
||
526 | 526 | $returnedValues = explode(',', $returnedValues); |
527 | 527 | } |
528 | 528 | |
529 | - $fileInfo = []; |
|
529 | + $fileInfo = [ ]; |
|
530 | 530 | |
531 | 531 | foreach ($returnedValues as $key) { |
532 | 532 | switch ($key) { |
533 | 533 | case 'name': |
534 | - $fileInfo['name'] = basename($file); |
|
534 | + $fileInfo[ 'name' ] = basename($file); |
|
535 | 535 | break; |
536 | 536 | |
537 | 537 | case 'server_path': |
538 | - $fileInfo['server_path'] = $file; |
|
538 | + $fileInfo[ 'server_path' ] = $file; |
|
539 | 539 | break; |
540 | 540 | |
541 | 541 | case 'size': |
542 | - $fileInfo['size'] = filesize($file); |
|
542 | + $fileInfo[ 'size' ] = filesize($file); |
|
543 | 543 | break; |
544 | 544 | |
545 | 545 | case 'date': |
546 | - $fileInfo['date'] = filemtime($file); |
|
546 | + $fileInfo[ 'date' ] = filemtime($file); |
|
547 | 547 | break; |
548 | 548 | |
549 | 549 | case 'readable': |
550 | - $fileInfo['readable'] = is_readable($file); |
|
550 | + $fileInfo[ 'readable' ] = is_readable($file); |
|
551 | 551 | break; |
552 | 552 | |
553 | 553 | case 'writable': |
554 | - $fileInfo['writable'] = is_writable($file); |
|
554 | + $fileInfo[ 'writable' ] = is_writable($file); |
|
555 | 555 | break; |
556 | 556 | |
557 | 557 | case 'executable': |
558 | - $fileInfo['executable'] = is_executable($file); |
|
558 | + $fileInfo[ 'executable' ] = is_executable($file); |
|
559 | 559 | break; |
560 | 560 | |
561 | 561 | case 'fileperms': |
562 | - $fileInfo['fileperms'] = fileperms($file); |
|
562 | + $fileInfo[ 'fileperms' ] = fileperms($file); |
|
563 | 563 | break; |
564 | 564 | } |
565 | 565 | } |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @param bool|string[] $cacheQueryString Whether to take the URL query string into consideration when generating output cache files. |
34 | - * Valid options are: |
|
34 | + * Valid options are: |
|
35 | 35 | * false = Disabled |
36 | 36 | * true = Enabled, take all query parameters into account. |
37 | - * Please be aware that this may result in numerous cache |
|
37 | + * Please be aware that this may result in numerous cache |
|
38 | 38 | * files generated for the same page over and over again. |
39 | 39 | * array('q') = Enabled, but only take into account the specified list of query parameters. |
40 | 40 | */ |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | { |
59 | 59 | $uri = clone $request->getUri(); |
60 | 60 | |
61 | - // @todo implementation de la recuperation des queriestring |
|
61 | + // @todo implementation de la recuperation des queriestring |
|
62 | 62 | /* $query = $this->cacheQueryString |
63 | 63 | ? $uri->getQuery(is_array($this->cacheQueryString) ? ['only' => $this->cacheQueryString] : []) |
64 | 64 | : ''; */ |
65 | 65 | |
66 | - $query = ''; |
|
66 | + $query = ''; |
|
67 | 67 | |
68 | 68 | return md5($uri->withFragment('')->withQuery($query)); |
69 | 69 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | |
80 | - $headers = []; |
|
80 | + $headers = []; |
|
81 | 81 | |
82 | 82 | foreach (array_keys($response->getHeaders()) as $header) { |
83 | 83 | $headers[$header] = $response->getHeaderLine($header); |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function get(ServerRequestInterface $request, ResponseInterface $response): ?ResponseInterface |
97 | 97 | { |
98 | - if ($cachedResponse = $this->cache->get($this->generateCacheKey($request))) { |
|
98 | + if ($cachedResponse = $this->cache->get($this->generateCacheKey($request))) { |
|
99 | 99 | $cachedResponse = unserialize($cachedResponse); |
100 | 100 | |
101 | - if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers'])) { |
|
101 | + if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers'])) { |
|
102 | 102 | throw new Exception('Erreur lors de la désérialisation du cache de page'); |
103 | 103 | } |
104 | 104 | |
105 | 105 | $headers = $cachedResponse['headers']; |
106 | 106 | $output = $cachedResponse['output']; |
107 | 107 | |
108 | - // Effacer tous les en-têtes par défaut |
|
108 | + // Effacer tous les en-têtes par défaut |
|
109 | 109 | foreach (array_keys($response->getHeaders()) as $key) { |
110 | 110 | $response = $response->withoutHeader($key); |
111 | 111 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $response = $response->withHeader($name, $value); |
116 | 116 | } |
117 | 117 | |
118 | - return $response->withBody(to_stream($output)); |
|
118 | + return $response->withBody(to_stream($output)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | return null; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * files generated for the same page over and over again. |
39 | 39 | * array('q') = Enabled, but only take into account the specified list of query parameters. |
40 | 40 | */ |
41 | - public function __construct(private CacheInterface $cache, private bool|array $cacheQueryString = false) |
|
41 | + public function __construct(private CacheInterface $cache, private bool | array $cacheQueryString = false) |
|
42 | 42 | { |
43 | 43 | } |
44 | 44 | |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | |
80 | - $headers = []; |
|
80 | + $headers = [ ]; |
|
81 | 81 | |
82 | 82 | foreach (array_keys($response->getHeaders()) as $header) { |
83 | - $headers[$header] = $response->getHeaderLine($header); |
|
83 | + $headers[ $header ] = $response->getHeaderLine($header); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this->cache->set( |
87 | 87 | $this->generateCacheKey($request), |
88 | - serialize(['headers' => $headers, 'output' => $response->getBody()->getContents()]), |
|
88 | + serialize([ 'headers' => $headers, 'output' => $response->getBody()->getContents() ]), |
|
89 | 89 | $this->ttl |
90 | 90 | ); |
91 | 91 | } |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | if ($cachedResponse = $this->cache->get($this->generateCacheKey($request))) { |
99 | 99 | $cachedResponse = unserialize($cachedResponse); |
100 | 100 | |
101 | - if (! is_array($cachedResponse) || ! isset($cachedResponse['output']) || ! isset($cachedResponse['headers'])) { |
|
101 | + if (!is_array($cachedResponse) || !isset($cachedResponse[ 'output' ]) || !isset($cachedResponse[ 'headers' ])) { |
|
102 | 102 | throw new Exception('Erreur lors de la désérialisation du cache de page'); |
103 | 103 | } |
104 | 104 | |
105 | - $headers = $cachedResponse['headers']; |
|
106 | - $output = $cachedResponse['output']; |
|
105 | + $headers = $cachedResponse[ 'headers' ]; |
|
106 | + $output = $cachedResponse[ 'output' ]; |
|
107 | 107 | |
108 | 108 | // Effacer tous les en-têtes par défaut |
109 | 109 | foreach (array_keys($response->getHeaders()) as $key) { |