@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | |
227 | 227 | $segments = preg_split($pattern, $this->value, $limit, $flags); |
228 | 228 | |
229 | - return ! empty($segments) ? new Collection($segments) : new Collection(); |
|
229 | + return !empty($segments) ? new Collection($segments) : new Collection(); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function isNotEmpty(): bool |
296 | 296 | { |
297 | - return ! $this->isEmpty(); |
|
297 | + return !$this->isEmpty(); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -831,8 +831,8 @@ |
||
831 | 831 | $shortRight = ceil($short / 2); |
832 | 832 | |
833 | 833 | return mb_substr(str_repeat($pad, $shortLeft), 0, $shortLeft) . |
834 | - $value . |
|
835 | - mb_substr(str_repeat($pad, $shortRight), 0, $shortRight); |
|
834 | + $value . |
|
835 | + mb_substr(str_repeat($pad, $shortRight), 0, $shortRight); |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | /** |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use Transliterator; |
19 | 19 | use Traversable; |
20 | 20 | |
21 | -if (! defined('MB_ENABLED')) { |
|
21 | +if (!defined('MB_ENABLED')) { |
|
22 | 22 | if (extension_loaded('mbstring')) { |
23 | 23 | define('MB_ENABLED', true); |
24 | 24 | // mbstring.internal_encoding est obsolète à partir de PHP 5.6 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | define('MB_ENABLED', false); |
32 | 32 | } |
33 | 33 | } |
34 | -if (! defined('ICONV_ENABLED')) { |
|
34 | +if (!defined('ICONV_ENABLED')) { |
|
35 | 35 | if (extension_loaded('iconv')) { |
36 | 36 | define('ICONV_ENABLED', true); |
37 | 37 | // iconv.internal_encoding est obsolète à partir de PHP 5.6 |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $converter = preg_replace('#Case$#i', '', $converter); |
141 | 141 | $converter = str_replace('to', '', strtolower($converter)); |
142 | 142 | |
143 | - if (! in_array($converter, $available_case, true)) { |
|
143 | + if (!in_array($converter, $available_case, true)) { |
|
144 | 144 | throw new InvalidArgumentException("Invalid converter type: `{$converter}`"); |
145 | 145 | } |
146 | 146 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | public static function cleanInsert(string $str, array $options): string |
295 | 295 | { |
296 | 296 | $clean = $options['clean']; |
297 | - if (! $clean) { |
|
297 | + if (!$clean) { |
|
298 | 298 | return $str; |
299 | 299 | } |
300 | 300 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | $clean = ['method' => 'text']; |
303 | 303 | } |
304 | 304 | |
305 | - if (! is_array($clean)) { |
|
305 | + if (!is_array($clean)) { |
|
306 | 306 | $clean = ['method' => $options['clean']]; |
307 | 307 | } |
308 | 308 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $haystack = mb_strtolower($haystack); |
363 | 363 | } |
364 | 364 | |
365 | - if (! is_iterable($needles)) { |
|
365 | + if (!is_iterable($needles)) { |
|
366 | 366 | $needles = (array) $needles; |
367 | 367 | } |
368 | 368 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | public static function containsAll(string $haystack, iterable $needles, bool $ignoreCase = false): bool |
388 | 388 | { |
389 | 389 | foreach ($needles as $needle) { |
390 | - if (! static::contains($haystack, $needle, $ignoreCase)) { |
|
390 | + if (!static::contains($haystack, $needle, $ignoreCase)) { |
|
391 | 391 | return false; |
392 | 392 | } |
393 | 393 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | public static function endsWith($haystack, $needles) |
407 | 407 | { |
408 | - if (! is_iterable($needles)) { |
|
408 | + if (!is_iterable($needles)) { |
|
409 | 409 | $needles = (array) $needles; |
410 | 410 | } |
411 | 411 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | return $options['clean'] ? static::cleanInsert($str, $options) : $str; |
578 | 578 | } |
579 | 579 | |
580 | - if (! isset($format)) { |
|
580 | + if (!isset($format)) { |
|
581 | 581 | $format = sprintf( |
582 | 582 | '/(?<!%s)%s%%s%s/', |
583 | 583 | preg_quote($options['escape'], '/'), |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | $str = str_replace($tmpHash, $tmpValue, $str); |
615 | 615 | } |
616 | 616 | |
617 | - if (! isset($options['format']) && isset($options['before'])) { |
|
617 | + if (!isset($options['format']) && isset($options['before'])) { |
|
618 | 618 | $str = str_replace($options['escape'] . $options['before'], $options['before'], $str); |
619 | 619 | } |
620 | 620 | |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | */ |
629 | 629 | public static function is(iterable|string $pattern, string $value): bool |
630 | 630 | { |
631 | - if (! is_iterable($pattern)) { |
|
631 | + if (!is_iterable($pattern)) { |
|
632 | 632 | $pattern = [$pattern]; |
633 | 633 | } |
634 | 634 | |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | */ |
673 | 673 | public static function isJson($value): bool |
674 | 674 | { |
675 | - if (! is_string($value)) { |
|
675 | + if (!is_string($value)) { |
|
676 | 676 | return false; |
677 | 677 | } |
678 | 678 | |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | */ |
703 | 703 | public static function isUlid($value) |
704 | 704 | { |
705 | - if (! is_string($value)) { |
|
705 | + if (!is_string($value)) { |
|
706 | 706 | return false; |
707 | 707 | } |
708 | 708 | |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | { |
758 | 758 | preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $value, $matches); |
759 | 759 | |
760 | - if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
760 | + if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
761 | 761 | return $value; |
762 | 762 | } |
763 | 763 | |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | { |
801 | 801 | preg_match($pattern, $subject, $matches); |
802 | 802 | |
803 | - if (! $matches) { |
|
803 | + if (!$matches) { |
|
804 | 804 | return ''; |
805 | 805 | } |
806 | 806 | |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | */ |
908 | 908 | public static function random(int $length = 16): string |
909 | 909 | { |
910 | - return (static::$randomStringFactory ?? static function ($length) { |
|
910 | + return (static::$randomStringFactory ?? static function($length) { |
|
911 | 911 | $string = ''; |
912 | 912 | |
913 | 913 | while (($len = strlen($string)) < $length) { |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | { |
944 | 944 | $next = 0; |
945 | 945 | |
946 | - $whenMissing ??= static function ($length) use (&$next) { |
|
946 | + $whenMissing ??= static function($length) use (&$next) { |
|
947 | 947 | $factoryCache = static::$randomStringFactory; |
948 | 948 | |
949 | 949 | static::$randomStringFactory = null; |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | return $randomString; |
958 | 958 | }; |
959 | 959 | |
960 | - static::createRandomStringsUsing(static function ($length) use (&$next, $sequence, $whenMissing) { |
|
960 | + static::createRandomStringsUsing(static function($length) use (&$next, $sequence, $whenMissing) { |
|
961 | 961 | if (array_key_exists($next, $sequence)) { |
962 | 962 | return $sequence[$next++]; |
963 | 963 | } |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | return static::$snakeCache[$key][$delimiter]; |
1204 | 1204 | } |
1205 | 1205 | |
1206 | - if (! ctype_lower($value)) { |
|
1206 | + if (!ctype_lower($value)) { |
|
1207 | 1207 | $value = preg_replace('/\s+/u', '', ucwords($value)); |
1208 | 1208 | |
1209 | 1209 | $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1' . $delimiter, $value)); |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | */ |
1228 | 1228 | public static function startsWith(string $haystack, $needles): bool |
1229 | 1229 | { |
1230 | - if (! is_iterable($needles)) { |
|
1230 | + if (!is_iterable($needles)) { |
|
1231 | 1231 | $needles = [$needles]; |
1232 | 1232 | } |
1233 | 1233 | |
@@ -1263,8 +1263,8 @@ discard block |
||
1263 | 1263 | $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i'; |
1264 | 1264 | $replace = preg_replace_callback( |
1265 | 1265 | $pattern, |
1266 | - function ($match) use ($strlen) { |
|
1267 | - $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8'); |
|
1266 | + function($match) use ($strlen) { |
|
1267 | + $utf8 = html_entity_decode($match[0], ENT_HTML5|ENT_QUOTES, 'UTF-8'); |
|
1268 | 1268 | |
1269 | 1269 | return str_repeat(' ', $strlen($utf8, 'UTF-8')); |
1270 | 1270 | }, |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | $result = ''; |
1347 | 1347 | |
1348 | 1348 | $pattern = '/(&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};)/i'; |
1349 | - $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
1349 | + $parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); |
|
1350 | 1350 | |
1351 | 1351 | foreach ($parts as $part) { |
1352 | 1352 | $offset = 0; |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | if ($offset !== 0 || $totalLength + $len > $length) { |
1368 | 1368 | if ( |
1369 | 1369 | strpos($part, '&') === 0 && preg_match($pattern, $part) |
1370 | - && $part !== html_entity_decode($part, ENT_HTML5 | ENT_QUOTES, $options['encoding']) |
|
1370 | + && $part !== html_entity_decode($part, ENT_HTML5|ENT_QUOTES, $options['encoding']) |
|
1371 | 1371 | ) { |
1372 | 1372 | // Entities cannot be passed substr. |
1373 | 1373 | continue; |
@@ -1481,7 +1481,7 @@ discard block |
||
1481 | 1481 | } |
1482 | 1482 | |
1483 | 1483 | $truncate = mb_substr($text, mb_strlen($text) - $length + mb_strlen($ellipsis)); |
1484 | - if (! $exact) { |
|
1484 | + if (!$exact) { |
|
1485 | 1485 | $spacepos = mb_strpos($truncate, ' '); |
1486 | 1486 | $truncate = $spacepos === false ? '' : trim(mb_substr($truncate, $spacepos)); |
1487 | 1487 | } |
@@ -1521,7 +1521,7 @@ discard block |
||
1521 | 1521 | } |
1522 | 1522 | if ($tmpOffset !== -1) { |
1523 | 1523 | $buffer .= substr($data, $offset, ($tmpOffset - $offset)); |
1524 | - if (! $depth && $data[$tmpOffset] === $separator) { |
|
1524 | + if (!$depth && $data[$tmpOffset] === $separator) { |
|
1525 | 1525 | $results[] = $buffer; |
1526 | 1526 | $buffer = ''; |
1527 | 1527 | } else { |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | } |
1537 | 1537 | } else { |
1538 | 1538 | if ($data[$tmpOffset] === $leftBound) { |
1539 | - if (! $open) { |
|
1539 | + if (!$open) { |
|
1540 | 1540 | $depth++; |
1541 | 1541 | $open = true; |
1542 | 1542 | } else { |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | $offset = $length + 1; |
1551 | 1551 | } |
1552 | 1552 | } |
1553 | - if (empty($results) && ! empty($buffer)) { |
|
1553 | + if (empty($results) && !empty($buffer)) { |
|
1554 | 1554 | $results[] = $buffer; |
1555 | 1555 | } |
1556 | 1556 | |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | */ |
1608 | 1608 | public static function transliterate(string $string, $transliterator = null) |
1609 | 1609 | { |
1610 | - if (! $transliterator) { |
|
1610 | + if (!$transliterator) { |
|
1611 | 1611 | $transliterator = static::$_defaultTransliterator ?: static::$_defaultTransliteratorId; |
1612 | 1612 | } |
1613 | 1613 | |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | $default = [ |
1633 | 1633 | 'ellipsis' => '...', 'exact' => true, 'html' => false, 'trimWidth' => false, |
1634 | 1634 | ]; |
1635 | - if (! empty($options['html']) && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
1635 | + if (!empty($options['html']) && strtolower(mb_internal_encoding()) === 'utf-8') { |
|
1636 | 1636 | $default['ellipsis'] = "\xe2\x80\xa6"; |
1637 | 1637 | } |
1638 | 1638 | $options += $default; |
@@ -1652,12 +1652,12 @@ discard block |
||
1652 | 1652 | |
1653 | 1653 | foreach ($tags as $tag) { |
1654 | 1654 | $contentLength = 0; |
1655 | - if (! in_array($tag[2], static::$_defaultHtmlNoCount, true)) { |
|
1655 | + if (!in_array($tag[2], static::$_defaultHtmlNoCount, true)) { |
|
1656 | 1656 | $contentLength = self::strlen($tag[3], $options); |
1657 | 1657 | } |
1658 | 1658 | |
1659 | 1659 | if ($truncate === '') { |
1660 | - if (! preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
1660 | + if (!preg_match('/img|br|input|hr|area|base|basefont|col|frame|isindex|link|meta|param/i', $tag[2])) { |
|
1661 | 1661 | if (preg_match('/<[\w]+[^>]*>/', $tag[0])) { |
1662 | 1662 | array_unshift($openTags, $tag[2]); |
1663 | 1663 | } elseif (preg_match('/<\/([\w]+)[^>]*>/', $tag[0], $closeTag)) { |
@@ -1703,13 +1703,13 @@ discard block |
||
1703 | 1703 | |
1704 | 1704 | $result = self::substr($text, 0, $length - $ellipsisLength, $options); |
1705 | 1705 | |
1706 | - if (! $options['exact']) { |
|
1706 | + if (!$options['exact']) { |
|
1707 | 1707 | if (self::substr($text, $length - $ellipsisLength, 1, $options) !== ' ') { |
1708 | 1708 | $result = self::removeLastWord($result); |
1709 | 1709 | } |
1710 | 1710 | |
1711 | 1711 | // If result is empty, then we don't need to count ellipsis in the cut. |
1712 | - if (! strlen($result)) { |
|
1712 | + if (!strlen($result)) { |
|
1713 | 1713 | $result = self::substr($text, 0, $length, $options); |
1714 | 1714 | } |
1715 | 1715 | } |
@@ -1913,7 +1913,7 @@ discard block |
||
1913 | 1913 | { |
1914 | 1914 | static $languageSpecific; |
1915 | 1915 | |
1916 | - if (! isset($languageSpecific)) { |
|
1916 | + if (!isset($languageSpecific)) { |
|
1917 | 1917 | $languageSpecific = [ |
1918 | 1918 | 'bg' => [ |
1919 | 1919 | ['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'], |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function v3(string $namespace, string $name) |
25 | 25 | { |
26 | - if (! static::isValid($namespace)) { |
|
26 | + if (!static::isValid($namespace)) { |
|
27 | 27 | return false; |
28 | 28 | } |
29 | 29 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | '%08s-%04s-%04x-%04x-%12s', |
42 | 42 | substr($hash, 0, 8), |
43 | 43 | substr($hash, 8, 4), |
44 | - (hexdec(substr($hash, 12, 4)) & 0x0FFF) | 0x3000, |
|
45 | - (hexdec(substr($hash, 16, 4)) & 0x3FFF) | 0x8000, |
|
44 | + (hexdec(substr($hash, 12, 4)) & 0x0FFF)|0x3000, |
|
45 | + (hexdec(substr($hash, 16, 4)) & 0x3FFF)|0x8000, |
|
46 | 46 | substr($hash, 20, 12) |
47 | 47 | ); |
48 | 48 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | mt_rand(0, 0xFFFF), |
58 | 58 | mt_rand(0, 0xFFFF), |
59 | 59 | mt_rand(0, 0xFFFF), |
60 | - mt_rand(0, 0x0FFF) | 0x4000, |
|
61 | - mt_rand(0, 0x3FFF) | 0x8000, |
|
60 | + mt_rand(0, 0x0FFF)|0x4000, |
|
61 | + mt_rand(0, 0x3FFF)|0x8000, |
|
62 | 62 | mt_rand(0, 0xFFFF), |
63 | 63 | mt_rand(0, 0xFFFF), |
64 | 64 | mt_rand(0, 0xFFFF) |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public static function v5(string $namespace, string $name) |
74 | 74 | { |
75 | - if (! static::isValid($namespace)) { |
|
75 | + if (!static::isValid($namespace)) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | '%08s-%04s-%04x-%04x-%12s', |
91 | 91 | substr($hash, 0, 8), |
92 | 92 | substr($hash, 8, 4), |
93 | - (hexdec(substr($hash, 12, 4)) & 0x0FFF) | 0x5000, |
|
94 | - (hexdec(substr($hash, 16, 4)) & 0x3FFF) | 0x8000, |
|
93 | + (hexdec(substr($hash, 12, 4)) & 0x0FFF)|0x5000, |
|
94 | + (hexdec(substr($hash, 16, 4)) & 0x3FFF)|0x8000, |
|
95 | 95 | substr($hash, 20, 12) |
96 | 96 | ); |
97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public static function isValid($value): bool |
105 | 105 | { |
106 | - if (! is_string($value)) { |
|
106 | + if (!is_string($value)) { |
|
107 | 107 | return false; |
108 | 108 | } |
109 | 109 |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | '/us$/i' => 'uses', |
46 | 46 | '/(alias)$/i' => '\1es', |
47 | 47 | '/(ax|cris|test)is$/i' => '\1es', |
48 | - '/(m)an$/' => '\1en', // man, woman, spokesman |
|
49 | - '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
50 | - '/(octop)us$/' => '\1i', // octopus |
|
48 | + '/(m)an$/' => '\1en', // man, woman, spokesman |
|
49 | + '/(bu|campu)s$/' => '\1\2ses', // bus, campus |
|
50 | + '/(octop)us$/' => '\1i', // octopus |
|
51 | 51 | '/s$/' => 's', |
52 | 52 | '/^$/' => '', |
53 | 53 | '/$/' => 's', |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | |
433 | 433 | return $value; |
434 | 434 | } |
435 | - if (! isset(static::$_cache[$type][$key])) { |
|
435 | + if (!isset(static::$_cache[$type][$key])) { |
|
436 | 436 | return false; |
437 | 437 | } |
438 | 438 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | return static::$_cache['pluralize'][$word]; |
513 | 513 | } |
514 | 514 | |
515 | - if (! isset(static::$_cache['irregular']['pluralize'])) { |
|
515 | + if (!isset(static::$_cache['irregular']['pluralize'])) { |
|
516 | 516 | static::$_cache['irregular']['pluralize'] = '(?:' . implode('|', array_keys(static::$_irregular)) . ')'; |
517 | 517 | } |
518 | 518 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | return static::$_cache['pluralize'][$word]; |
524 | 524 | } |
525 | 525 | |
526 | - if (! isset(static::$_cache['uninflected'])) { |
|
526 | + if (!isset(static::$_cache['uninflected'])) { |
|
527 | 527 | static::$_cache['uninflected'] = '(?:' . implode('|', static::$_uninflected) . ')'; |
528 | 528 | } |
529 | 529 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | return static::$_cache['singularize'][$word]; |
558 | 558 | } |
559 | 559 | |
560 | - if (! isset(static::$_cache['irregular']['singular'])) { |
|
560 | + if (!isset(static::$_cache['irregular']['singular'])) { |
|
561 | 561 | static::$_cache['irregular']['singular'] = '(?:' . implode('|', static::$_irregular) . ')'; |
562 | 562 | } |
563 | 563 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | return static::$_cache['singularize'][$word]; |
569 | 569 | } |
570 | 570 | |
571 | - if (! isset(static::$_cache['uninflected'])) { |
|
571 | + if (!isset(static::$_cache['uninflected'])) { |
|
572 | 572 | static::$_cache['uninflected'] = '(?:' . implode('|', static::$_uninflected) . ')'; |
573 | 573 | } |
574 | 574 |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | { |
49 | 49 | parent::init($config, $ipAddress); |
50 | 50 | |
51 | - if (! empty($this->_config['savePath'])) { |
|
51 | + if (!empty($this->_config['savePath'])) { |
|
52 | 52 | $this->_config['savePath'] = rtrim($this->_config['savePath'], '/\\'); |
53 | 53 | ini_set('session.save_path', $this->_config['savePath']); |
54 | 54 | } else { |
55 | 55 | $sessionPath = rtrim(ini_get('session.save_path'), '/\\'); |
56 | 56 | |
57 | - if (! $sessionPath) { |
|
57 | + if (!$sessionPath) { |
|
58 | 58 | $sessionPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'blitz-php' . DIRECTORY_SEPARATOR . 'session'; |
59 | 59 | } |
60 | 60 | |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function open(string $path, string $name): bool |
73 | 73 | { |
74 | - if (! is_dir($path) && ! mkdir($path, 0700, true)) { |
|
74 | + if (!is_dir($path) && !mkdir($path, 0700, true)) { |
|
75 | 75 | throw SessionException::invalidSavePath($this->_config['savePath']); |
76 | 76 | } |
77 | 77 | |
78 | - if (! is_writable($path)) { |
|
78 | + if (!is_writable($path)) { |
|
79 | 79 | throw SessionException::writeProtectedSavePath($this->_config['savePath']); |
80 | 80 | } |
81 | 81 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | // Cela peut sembler bizarre, mais PHP 5.6 a introduit session_reset(), qui relit les données de session |
96 | 96 | if ($this->fileHandle === null) { |
97 | - $this->fileNew = ! is_file($this->filePath . $id); |
|
97 | + $this->fileNew = !is_file($this->filePath . $id); |
|
98 | 98 | |
99 | 99 | if (($this->fileHandle = fopen($this->filePath . $id, 'c+b')) === false) { |
100 | 100 | $this->logMessage("Session : Impossible d'ouvrir le fichier '" . $this->filePath . $id . "'."); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - if (! isset($this->sessionID)) { |
|
113 | + if (!isset($this->sessionID)) { |
|
114 | 114 | $this->sessionID = $id; |
115 | 115 | } |
116 | 116 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $this->sessionID = $id; |
152 | 152 | } |
153 | 153 | |
154 | - if (! is_resource($this->fileHandle)) { |
|
154 | + if (!is_resource($this->fileHandle)) { |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | return ($this->fileNew) ? true : touch($this->filePath . $id); |
160 | 160 | } |
161 | 161 | |
162 | - if (! $this->fileNew) { |
|
162 | + if (!$this->fileNew) { |
|
163 | 163 | ftruncate($this->fileHandle, 0); |
164 | 164 | rewind($this->fileHandle); |
165 | 165 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - if (! is_int($result)) { |
|
176 | + if (!is_int($result)) { |
|
177 | 177 | $this->fingerprint = md5(substr($data, 0, $written)); |
178 | 178 | $this->logMessage("Session\u{a0}: impossible d'écrire des données."); |
179 | 179 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function gc(int $max_lifetime): false|int |
231 | 231 | { |
232 | - if (! is_dir($this->_config['savePath']) || ($directory = opendir($this->_config['savePath'])) === false) { |
|
232 | + if (!is_dir($this->_config['savePath']) || ($directory = opendir($this->_config['savePath'])) === false) { |
|
233 | 233 | $this->logMessage("Session\u{a0}: le récupérateur de place n'a pas pu répertorier les fichiers dans le répertoire '" . $this->_config['savePath'] . "'.", 'debug'); |
234 | 234 | |
235 | 235 | return false; |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | |
249 | 249 | while (($file = readdir($directory)) !== false) { |
250 | 250 | // Si le nom du fichier ne correspond pas à ce modèle, ce n'est pas un fichier de session ou ce n'est pas le nôtre |
251 | - if (! preg_match($pattern, $file) |
|
252 | - || ! is_file($this->_config['savePath'] . DIRECTORY_SEPARATOR . $file) |
|
251 | + if (!preg_match($pattern, $file) |
|
252 | + || !is_file($this->_config['savePath'] . DIRECTORY_SEPARATOR . $file) |
|
253 | 253 | || ($mtime = filemtime($this->_config['savePath'] . DIRECTORY_SEPARATOR . $file)) === false |
254 | 254 | || $mtime > $ts |
255 | 255 | ) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $this->_config['keyPrefix'] .= $this->ipAddress . ':'; |
51 | 51 | } |
52 | 52 | |
53 | - if (! empty($this->_config['keyPrefix'])) { |
|
53 | + if (!empty($this->_config['keyPrefix'])) { |
|
54 | 54 | ini_set('memcached.sess_prefix', $this->_config['keyPrefix']); |
55 | 55 | } |
56 | 56 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | if ( |
75 | - ! preg_match_all( |
|
75 | + !preg_match_all( |
|
76 | 76 | '#,?([^,:]+)\:(\d{1,5})(?:\:(\d+))?#', |
77 | 77 | $this->_config['savePath'], |
78 | 78 | $matches, |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - if (! $this->memcached->addServer($match[1], (int) $match[2], $match[3] ?? 0)) { |
|
99 | + if (!$this->memcached->addServer($match[1], (int) $match[2], $match[3] ?? 0)) { |
|
100 | 100 | $this->logMessage( |
101 | 101 | 'Impossible d\'ajouter ' . $match[1] . ':' . $match[2] . ' au pool de serveurs Memcached.' |
102 | 102 | ); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function read(string $id): false|string |
121 | 121 | { |
122 | 122 | if (isset($this->memcached) && $this->lockSession($id)) { |
123 | - if (! isset($this->sessionID)) { |
|
123 | + if (!isset($this->sessionID)) { |
|
124 | 124 | $this->sessionID = $id; |
125 | 125 | } |
126 | 126 | |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function write(string $id, string $data): bool |
141 | 141 | { |
142 | - if (! isset($this->memcached)) { |
|
142 | + if (!isset($this->memcached)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | if ($this->sessionID !== $id) { |
147 | - if (! $this->releaseLock() || ! $this->lockSession($id)) { |
|
147 | + if (!$this->releaseLock() || !$this->lockSession($id)) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $this->memcached->delete($this->lockKey); |
182 | 182 | } |
183 | 183 | |
184 | - if (! $this->memcached->quit()) { |
|
184 | + if (!$this->memcached->quit()) { |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
229 | - if (! $this->memcached->set($lockKey, Date::now()->getTimestamp(), 300)) { |
|
229 | + if (!$this->memcached->set($lockKey, Date::now()->getTimestamp(), 300)) { |
|
230 | 230 | $this->logMessage( |
231 | 231 | "Session\u{a0}: erreur lors de la tentative d'obtention du verrou pour" . $this->_config['keyPrefix'] . $sessionID |
232 | 232 | ); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | { |
259 | 259 | if (isset($this->memcached, $this->lockKey) && $this->lock) { |
260 | 260 | if ( |
261 | - ! $this->memcached->delete($this->lockKey) |
|
261 | + !$this->memcached->delete($this->lockKey) |
|
262 | 262 | && $this->memcached->getResultCode() !== BaseMemcached::RES_NOTFOUND |
263 | 263 | ) { |
264 | 264 | $this->logMessage( |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | protected function releaseLock(): bool |
40 | 40 | { |
41 | - if (! $this->lock) { |
|
41 | + if (!$this->lock) { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | 44 |
@@ -74,7 +74,7 @@ |
||
74 | 74 | */ |
75 | 75 | protected function releaseLock(): bool |
76 | 76 | { |
77 | - if (! $this->lock) { |
|
77 | + if (!$this->lock) { |
|
78 | 78 | return true; |
79 | 79 | } |
80 | 80 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | parent::init($config, $ipAddress); |
63 | 63 | |
64 | - if (! empty($config['group'])) { |
|
64 | + if (!empty($config['group'])) { |
|
65 | 65 | $this->group = $config['group']; |
66 | 66 | } |
67 | 67 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | return ''; |
102 | 102 | } |
103 | 103 | |
104 | - if (! isset($this->sessionID)) { |
|
104 | + if (!isset($this->sessionID)) { |
|
105 | 105 | $this->sessionID = $id; |
106 | 106 | } |
107 | 107 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | 'data' => $this->prepareData($data), |
170 | 170 | ]; |
171 | 171 | |
172 | - if (! $this->db->table($this->table)->set('timestamp', 'now()', false)->insert($insertData)) { |
|
172 | + if (!$this->db->table($this->table)->set('timestamp', 'now()', false)->insert($insertData)) { |
|
173 | 173 | return $this->fail(); |
174 | 174 | } |
175 | 175 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $updateData['data'] = $this->prepareData($data); |
192 | 192 | } |
193 | 193 | |
194 | - if (! $builder->set('timestamp', 'now()', false)->update($updateData)) { |
|
194 | + if (!$builder->set('timestamp', 'now()', false)->update($updateData)) { |
|
195 | 195 | return $this->fail(); |
196 | 196 | } |
197 | 197 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public function close(): bool |
225 | 225 | { |
226 | - return ($this->lock && ! $this->releaseLock()) ? $this->fail() : true; |
|
226 | + return ($this->lock && !$this->releaseLock()) ? $this->fail() : true; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $builder = $builder->where('ip_address', $this->ipAddress); |
239 | 239 | } |
240 | 240 | |
241 | - if (! $builder->delete()) { |
|
241 | + if (!$builder->delete()) { |
|
242 | 242 | return $this->fail(); |
243 | 243 | } |
244 | 244 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | protected function releaseLock(): bool |
274 | 274 | { |
275 | - if (! $this->lock) { |
|
275 | + if (!$this->lock) { |
|
276 | 276 | return true; |
277 | 277 | } |
278 | 278 |