@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | throw new LogicException('Les fichiers ne peuvent pas être incrémentés de manière atomique.'); |
311 | 311 | } |
312 | 312 | |
313 | - /** |
|
314 | - * {@inheritDoc} |
|
315 | - */ |
|
316 | - public function info() |
|
317 | - { |
|
313 | + /** |
|
314 | + * {@inheritDoc} |
|
315 | + */ |
|
316 | + public function info() |
|
317 | + { |
|
318 | 318 | return $this->getDirFileInfo($this->_config['path']); |
319 | - } |
|
319 | + } |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Définit la clé de cache actuelle que cette classe gère et crée un SplFileObject inscriptible |
@@ -485,13 +485,13 @@ discard block |
||
485 | 485 | |
486 | 486 | if ($fp = @opendir($sourceDir)) { |
487 | 487 | // réinitialise le tableau et s'assure que $source_dir a une barre oblique à la fin de l'appel initial |
488 | - if ($_recursion === false) { |
|
488 | + if ($_recursion === false) { |
|
489 | 489 | $_filedata = []; |
490 | 490 | $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
491 | 491 | } |
492 | 492 | |
493 | 493 | // Utilisé pour être foreach (scandir($source_dir, 1) comme $file), mais scandir() n'est tout simplement pas aussi rapide |
494 | - while (false !== ($file = readdir($fp))) { |
|
494 | + while (false !== ($file = readdir($fp))) { |
|
495 | 495 | if (is_dir($sourceDir . $file) && $file[0] !== '.' && $topLevelOnly === false) { |
496 | 496 | $this->getDirFileInfo($sourceDir . $file . DIRECTORY_SEPARATOR, $topLevelOnly, true); |
497 | 497 | } elseif (! is_dir($sourceDir . $file) && $file[0] !== '.') { |
@@ -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; |
@@ -480,23 +480,23 @@ discard block |
||
480 | 480 | */ |
481 | 481 | protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true, bool $_recursion = false) |
482 | 482 | { |
483 | - static $_filedata = []; |
|
483 | + static $_filedata = [ ]; |
|
484 | 484 | $relativePath = $sourceDir; |
485 | 485 | |
486 | 486 | if ($fp = @opendir($sourceDir)) { |
487 | 487 | // réinitialise le tableau et s'assure que $source_dir a une barre oblique à la fin de l'appel initial |
488 | 488 | if ($_recursion === false) { |
489 | - $_filedata = []; |
|
490 | - $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
489 | + $_filedata = [ ]; |
|
490 | + $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | // Utilisé pour être foreach (scandir($source_dir, 1) comme $file), mais scandir() n'est tout simplement pas aussi rapide |
494 | 494 | while (false !== ($file = readdir($fp))) { |
495 | - if (is_dir($sourceDir . $file) && $file[0] !== '.' && $topLevelOnly === false) { |
|
496 | - $this->getDirFileInfo($sourceDir . $file . DIRECTORY_SEPARATOR, $topLevelOnly, true); |
|
497 | - } elseif (! is_dir($sourceDir . $file) && $file[0] !== '.') { |
|
498 | - $_filedata[$file] = $this->getFileInfo($sourceDir . $file); |
|
499 | - $_filedata[$file]['relative_path'] = $relativePath; |
|
495 | + if (is_dir($sourceDir.$file) && $file[ 0 ] !== '.' && $topLevelOnly === false) { |
|
496 | + $this->getDirFileInfo($sourceDir.$file.DIRECTORY_SEPARATOR, $topLevelOnly, true); |
|
497 | + } elseif (!is_dir($sourceDir.$file) && $file[ 0 ] !== '.') { |
|
498 | + $_filedata[ $file ] = $this->getFileInfo($sourceDir.$file); |
|
499 | + $_filedata[ $file ][ 'relative_path' ] = $relativePath; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -518,9 +518,9 @@ discard block |
||
518 | 518 | * |
519 | 519 | * @return array|false |
520 | 520 | */ |
521 | - protected function getFileInfo(string $file, $returnedValues = ['name', 'server_path', 'size', 'date']) |
|
521 | + protected function getFileInfo(string $file, $returnedValues = [ 'name', 'server_path', 'size', 'date' ]) |
|
522 | 522 | { |
523 | - if (! is_file($file)) { |
|
523 | + if (!is_file($file)) { |
|
524 | 524 | return false; |
525 | 525 | } |
526 | 526 | |
@@ -528,40 +528,40 @@ discard block |
||
528 | 528 | $returnedValues = explode(',', $returnedValues); |
529 | 529 | } |
530 | 530 | |
531 | - $fileInfo = []; |
|
531 | + $fileInfo = [ ]; |
|
532 | 532 | |
533 | 533 | foreach ($returnedValues as $key) { |
534 | 534 | switch ($key) { |
535 | 535 | case 'name': |
536 | - $fileInfo['name'] = basename($file); |
|
536 | + $fileInfo[ 'name' ] = basename($file); |
|
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'server_path': |
540 | - $fileInfo['server_path'] = $file; |
|
540 | + $fileInfo[ 'server_path' ] = $file; |
|
541 | 541 | break; |
542 | 542 | |
543 | 543 | case 'size': |
544 | - $fileInfo['size'] = filesize($file); |
|
544 | + $fileInfo[ 'size' ] = filesize($file); |
|
545 | 545 | break; |
546 | 546 | |
547 | 547 | case 'date': |
548 | - $fileInfo['date'] = filemtime($file); |
|
548 | + $fileInfo[ 'date' ] = filemtime($file); |
|
549 | 549 | break; |
550 | 550 | |
551 | 551 | case 'readable': |
552 | - $fileInfo['readable'] = is_readable($file); |
|
552 | + $fileInfo[ 'readable' ] = is_readable($file); |
|
553 | 553 | break; |
554 | 554 | |
555 | 555 | case 'writable': |
556 | - $fileInfo['writable'] = is_writable($file); |
|
556 | + $fileInfo[ 'writable' ] = is_writable($file); |
|
557 | 557 | break; |
558 | 558 | |
559 | 559 | case 'executable': |
560 | - $fileInfo['executable'] = is_executable($file); |
|
560 | + $fileInfo[ 'executable' ] = is_executable($file); |
|
561 | 561 | break; |
562 | 562 | |
563 | 563 | case 'fileperms': |
564 | - $fileInfo['fileperms'] = fileperms($file); |
|
564 | + $fileInfo[ 'fileperms' ] = fileperms($file); |
|
565 | 565 | break; |
566 | 566 | } |
567 | 567 | } |
@@ -234,13 +234,13 @@ |
||
234 | 234 | return (bool) ($this->_Redis->set($key, $value, ['nx', 'ex' => $duration])); |
235 | 235 | } |
236 | 236 | |
237 | - /** |
|
238 | - * {@inheritDoc} |
|
239 | - */ |
|
240 | - public function info() |
|
241 | - { |
|
242 | - return $this->_Redis->info(); |
|
243 | - } |
|
237 | + /** |
|
238 | + * {@inheritDoc} |
|
239 | + */ |
|
240 | + public function info() |
|
241 | + { |
|
242 | + return $this->_Redis->info(); |
|
243 | + } |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * {@inheritDoc} |
@@ -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 | /** |
@@ -247,15 +247,15 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function groups(): array |
249 | 249 | { |
250 | - $result = []; |
|
250 | + $result = [ ]; |
|
251 | 251 | |
252 | - foreach ($this->_config['groups'] as $group) { |
|
253 | - $value = $this->_Redis->get($this->_config['prefix'] . $group); |
|
254 | - if (! $value) { |
|
252 | + foreach ($this->_config[ 'groups' ] as $group) { |
|
253 | + $value = $this->_Redis->get($this->_config[ 'prefix' ].$group); |
|
254 | + if (!$value) { |
|
255 | 255 | $value = $this->serialize(1); |
256 | - $this->_Redis->set($this->_config['prefix'] . $group, $value); |
|
256 | + $this->_Redis->set($this->_config[ 'prefix' ].$group, $value); |
|
257 | 257 | } |
258 | - $result[] = $group . $value; |
|
258 | + $result[ ] = $group.$value; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $result; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function clearGroup(string $group): bool |
268 | 268 | { |
269 | - return (bool) $this->_Redis->incr($this->_config['prefix'] . $group); |
|
269 | + return (bool) $this->_Redis->incr($this->_config[ 'prefix' ].$group); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function __destruct() |
305 | 305 | { |
306 | - if (empty($this->_config['persistent']) && $this->_Redis instanceof Redis) { |
|
306 | + if (empty($this->_config[ 'persistent' ]) && $this->_Redis instanceof Redis) { |
|
307 | 307 | $this->_Redis->close(); |
308 | 308 | } |
309 | 309 | } |
@@ -407,13 +407,13 @@ |
||
407 | 407 | return $this->_Memcached->add($key, $value, $duration); |
408 | 408 | } |
409 | 409 | |
410 | - /** |
|
411 | - * {@inheritDoc} |
|
412 | - */ |
|
413 | - public function info() |
|
414 | - { |
|
415 | - return $this->_Memcached->getStats(); |
|
416 | - } |
|
410 | + /** |
|
411 | + * {@inheritDoc} |
|
412 | + */ |
|
413 | + public function info() |
|
414 | + { |
|
415 | + return $this->_Memcached->getStats(); |
|
416 | + } |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * {@inheritDoc} |
@@ -339,13 +339,13 @@ |
||
339 | 339 | */ |
340 | 340 | abstract public function clearGroup(string $group): bool; |
341 | 341 | |
342 | - /** |
|
343 | - * {@inheritDoc} |
|
344 | - */ |
|
345 | - public function info() |
|
346 | - { |
|
347 | - return null; |
|
348 | - } |
|
342 | + /** |
|
343 | + * {@inheritDoc} |
|
344 | + */ |
|
345 | + public function info() |
|
346 | + { |
|
347 | + return null; |
|
348 | + } |
|
349 | 349 | |
350 | 350 | /** |
351 | 351 | * Effectue toute initialisation pour chaque groupe est nécessaire |
@@ -113,13 +113,13 @@ |
||
113 | 113 | return true; |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * {@inheritDoc} |
|
118 | - */ |
|
119 | - public function info() |
|
120 | - { |
|
121 | - return wincache_ucache_info(true); |
|
122 | - } |
|
116 | + /** |
|
117 | + * {@inheritDoc} |
|
118 | + */ |
|
119 | + public function info() |
|
120 | + { |
|
121 | + return wincache_ucache_info(true); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * {@inheritDoc} |
@@ -53,13 +53,13 @@ |
||
53 | 53 | */ |
54 | 54 | public function clearGroup(string $group): bool; |
55 | 55 | |
56 | - /** |
|
57 | - * Renvoie des informations sur l'ensemble du cache. |
|
58 | - * |
|
59 | - * Les informations retournées et la structure des données |
|
60 | - * varie selon le gestionnaire. |
|
61 | - * |
|
62 | - * @return array|false|object|null |
|
63 | - */ |
|
56 | + /** |
|
57 | + * Renvoie des informations sur l'ensemble du cache. |
|
58 | + * |
|
59 | + * Les informations retournées et la structure des données |
|
60 | + * varie selon le gestionnaire. |
|
61 | + * |
|
62 | + * @return array|false|object|null |
|
63 | + */ |
|
64 | 64 | public function info(); |
65 | 65 | } |