@@ -22,6 +22,6 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | function trigger_deprecation(string $package, string $version, string $message, ...$args): void |
| 24 | 24 | { |
| 25 | - @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); |
|
| 25 | + @trigger_error(($package || $version ? "Since $package $version: " : '') . ($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); |
|
| 26 | 26 | } |
| 27 | 27 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | public function __construct(OptionsResolver $optionsResolver) |
| 28 | 28 | { |
| 29 | - $this->get = \Closure::bind(function ($property, $option, $message) { |
|
| 29 | + $this->get = \Closure::bind(function($property, $option, $message) { |
|
| 30 | 30 | /** @var OptionsResolver $this */ |
| 31 | 31 | if (!$this->isDefined($option)) { |
| 32 | 32 | throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option)); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | throw new AccessException('Options cannot be made required from a lazy option or normalizer.'); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - foreach ((array) $optionNames as $option) { |
|
| 311 | + foreach ((array)$optionNames as $option) { |
|
| 312 | 312 | $this->defined[$option] = true; |
| 313 | 313 | $this->required[$option] = true; |
| 314 | 314 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | throw new AccessException('Options cannot be defined from a lazy option or normalizer.'); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - foreach ((array) $optionNames as $option) { |
|
| 392 | + foreach ((array)$optionNames as $option) { |
|
| 393 | 393 | $this->defined[$option] = true; |
| 394 | 394 | } |
| 395 | 395 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $this->formatOptions([$option]), implode('", "', array_keys($this->defined)))); |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - $this->allowedTypes[$option] = (array) $allowedTypes; |
|
| 708 | + $this->allowedTypes[$option] = (array)$allowedTypes; |
|
| 709 | 709 | |
| 710 | 710 | // Make sure the option is processed |
| 711 | 711 | unset($this->resolved[$option]); |
@@ -741,9 +741,9 @@ discard block |
||
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | if (!isset($this->allowedTypes[$option])) { |
| 744 | - $this->allowedTypes[$option] = (array) $allowedTypes; |
|
| 744 | + $this->allowedTypes[$option] = (array)$allowedTypes; |
|
| 745 | 745 | } else { |
| 746 | - $this->allowedTypes[$option] = array_merge($this->allowedTypes[$option], (array) $allowedTypes); |
|
| 746 | + $this->allowedTypes[$option] = array_merge($this->allowedTypes[$option], (array)$allowedTypes); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | // Make sure the option is processed |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | throw new AccessException('Options cannot be removed from a lazy option or normalizer.'); |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | - foreach ((array) $optionNames as $option) { |
|
| 846 | + foreach ((array)$optionNames as $option) { |
|
| 847 | 847 | unset($this->defined[$option], $this->defaults[$option], $this->required[$option], $this->resolved[$option]); |
| 848 | 848 | unset($this->lazy[$option], $this->normalizers[$option], $this->allowedTypes[$option], $this->allowedValues[$option], $this->info[$option]); |
| 849 | 849 | } |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | ksort($clone->defined); |
| 920 | 920 | ksort($diff); |
| 921 | 921 | |
| 922 | - throw new UndefinedOptionsException(sprintf((\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".', $this->formatOptions(array_keys($diff)), implode('", "', array_keys($clone->defined)))); |
|
| 922 | + throw new UndefinedOptionsException(sprintf((\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.') . ' Defined options are: "%s".', $this->formatOptions(array_keys($diff)), implode('", "', array_keys($clone->defined)))); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | // Override options set by the user |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | $fmtActualValue = $this->formatValue($value); |
| 1073 | 1073 | $fmtAllowedTypes = implode('" or "', $this->allowedTypes[$option]); |
| 1074 | 1074 | $fmtProvidedTypes = implode('|', array_keys($invalidTypes)); |
| 1075 | - $allowedContainsArrayType = \count(array_filter($this->allowedTypes[$option], static function ($item) { |
|
| 1075 | + $allowedContainsArrayType = \count(array_filter($this->allowedTypes[$option], static function($item) { |
|
| 1076 | 1076 | return '[]' === substr($item, -2); |
| 1077 | 1077 | })) > 0; |
| 1078 | 1078 | |
@@ -1292,7 +1292,7 @@ discard block |
||
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | if (\is_string($value)) { |
| 1295 | - return '"'.$value.'"'; |
|
| 1295 | + return '"' . $value . '"'; |
|
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | 1298 | if (\is_resource($value)) { |
@@ -1311,7 +1311,7 @@ discard block |
||
| 1311 | 1311 | return 'true'; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | - return (string) $value; |
|
| 1314 | + return (string)$value; |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | /** |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | $prefix .= sprintf('[%s]', $this->prototypeIndex); |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | - $options = array_map(static function (string $option) use ($prefix): string { |
|
| 1346 | + $options = array_map(static function(string $option) use ($prefix): string { |
|
| 1347 | 1347 | return sprintf('%s[%s]', $prefix, $option); |
| 1348 | 1348 | }, $options); |
| 1349 | 1349 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $rx .= '.{65535}'; |
| 61 | 61 | $length -= 65535; |
| 62 | 62 | } |
| 63 | - $rx .= '.{'.$length.'})/us'; |
|
| 63 | + $rx .= '.{' . $length . '})/us'; |
|
| 64 | 64 | |
| 65 | 65 | $str = clone $this; |
| 66 | 66 | $chunks = []; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } elseif (\is_array($suffix) || $suffix instanceof \Traversable) { |
| 88 | 88 | return parent::endsWith($suffix); |
| 89 | 89 | } else { |
| 90 | - $suffix = (string) $suffix; |
|
| 90 | + $suffix = (string)$suffix; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if ('' === $suffix || !preg_match('//u', $suffix)) { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | if ($this->ignoreCase) { |
| 98 | - return preg_match('{'.preg_quote($suffix).'$}iuD', $this->string); |
|
| 98 | + return preg_match('{' . preg_quote($suffix) . '$}iuD', $this->string); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | return \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix)); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | } elseif (\is_array($string) || $string instanceof \Traversable) { |
| 109 | 109 | return parent::equalsTo($string); |
| 110 | 110 | } else { |
| 111 | - $string = (string) $string; |
|
| 111 | + $string = (string)$string; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if ('' !== $string && $this->ignoreCase) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } elseif (\is_array($needle) || $needle instanceof \Traversable) { |
| 126 | 126 | return parent::indexOf($needle, $offset); |
| 127 | 127 | } else { |
| 128 | - $needle = (string) $needle; |
|
| 128 | + $needle = (string)$needle; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if ('' === $needle) { |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } elseif (\is_array($needle) || $needle instanceof \Traversable) { |
| 145 | 145 | return parent::indexOfLast($needle, $offset); |
| 146 | 146 | } else { |
| 147 | - $needle = (string) $needle; |
|
| 147 | + $needle = (string)$needle; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | if ('' === $needle) { |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | public function prepend(string ...$prefix): AbstractString |
| 165 | 165 | { |
| 166 | 166 | $str = clone $this; |
| 167 | - $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string; |
|
| 167 | + $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)) . $this->string; |
|
| 168 | 168 | |
| 169 | 169 | if (!preg_match('//u', $str->string)) { |
| 170 | 170 | throw new InvalidArgumentException('Invalid UTF-8 string.'); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if ($this->ignoreCase) { |
| 189 | - $str->string = implode($to, preg_split('{'.preg_quote($from).'}iuD', $this->string)); |
|
| 189 | + $str->string = implode($to, preg_split('{' . preg_quote($from) . '}iuD', $this->string)); |
|
| 190 | 190 | } else { |
| 191 | 191 | $str->string = str_replace($from, $to, $this->string); |
| 192 | 192 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if (null !== $flags) { |
| 230 | - return parent::split($delimiter.'u', $limit, $flags); |
|
| 230 | + return parent::split($delimiter . 'u', $limit, $flags); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | if (!preg_match('//u', $delimiter)) { |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | $str = clone $this; |
| 238 | 238 | $chunks = $this->ignoreCase |
| 239 | - ? preg_split('{'.preg_quote($delimiter).'}iuD', $this->string, $limit) |
|
| 239 | + ? preg_split('{' . preg_quote($delimiter) . '}iuD', $this->string, $limit) |
|
| 240 | 240 | : explode($delimiter, $this->string, $limit); |
| 241 | 241 | |
| 242 | 242 | foreach ($chunks as &$chunk) { |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | } elseif (\is_array($prefix) || $prefix instanceof \Traversable) { |
| 255 | 255 | return parent::startsWith($prefix); |
| 256 | 256 | } else { |
| 257 | - $prefix = (string) $prefix; |
|
| 257 | + $prefix = (string)$prefix; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | if ('' === $prefix || !preg_match('//u', $prefix)) { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $lazyString = new static(); |
| 35 | - $lazyString->value = static function () use (&$callback, &$arguments, &$value): string { |
|
| 35 | + $lazyString->value = static function() use (&$callback, &$arguments, &$value): string { |
|
| 36 | 36 | if (null !== $arguments) { |
| 37 | 37 | if (!\is_callable($callback)) { |
| 38 | 38 | $callback[0] = $callback[0](); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $lazyString = new static(); |
| 68 | - $lazyString->value = (string) $value; |
|
| 68 | + $lazyString->value = (string)$value; |
|
| 69 | 69 | |
| 70 | 70 | return $lazyString; |
| 71 | 71 | } |
@@ -159,6 +159,6 @@ discard block |
||
| 159 | 159 | $method = '__invoke'; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return $class.'::'.$method; |
|
| 162 | + return $class . '::' . $method; |
|
| 163 | 163 | } |
| 164 | 164 | } |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | if (0x80 > $code %= 0x200000) { |
| 62 | 62 | $string .= \chr($code); |
| 63 | 63 | } elseif (0x800 > $code) { |
| 64 | - $string .= \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F); |
|
| 64 | + $string .= \chr(0xC0 | $code >> 6) . \chr(0x80 | $code & 0x3F); |
|
| 65 | 65 | } elseif (0x10000 > $code) { |
| 66 | - $string .= \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F); |
|
| 66 | + $string .= \chr(0xE0 | $code >> 12) . \chr(0x80 | $code >> 6 & 0x3F) . \chr(0x80 | $code & 0x3F); |
|
| 67 | 67 | } else { |
| 68 | - $string .= \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F); |
|
| 68 | + $string .= \chr(0xF0 | $code >> 18) . \chr(0x80 | $code >> 12 & 0x3F) . \chr(0x80 | $code >> 6 & 0x3F) . \chr(0x80 | $code & 0x3F); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | } elseif (!\function_exists('iconv')) { |
| 141 | 141 | $s = preg_replace('/[^\x00-\x7F]/u', '?', $s); |
| 142 | 142 | } else { |
| 143 | - $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) { |
|
| 144 | - $c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]); |
|
| 143 | + $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function($c) { |
|
| 144 | + $c = (string)iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]); |
|
| 145 | 145 | |
| 146 | 146 | if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) { |
| 147 | 147 | throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class)); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | public function camel(): parent |
| 161 | 161 | { |
| 162 | 162 | $str = clone $this; |
| 163 | - $str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) { |
|
| 163 | + $str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function($m) use (&$i) { |
|
| 164 | 164 | return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8'); |
| 165 | 165 | }, preg_replace('/[^\pL0-9]++/u', ' ', $this->string))); |
| 166 | 166 | |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | { |
| 206 | 206 | $str = clone $this; |
| 207 | 207 | |
| 208 | - $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : ''; |
|
| 209 | - $str->string = implode($this->string, $strings).$tail; |
|
| 208 | + $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue . array_pop($strings) : ''; |
|
| 209 | + $str->string = implode($this->string, $strings) . $tail; |
|
| 210 | 210 | |
| 211 | 211 | if (!preg_match('//u', $str->string)) { |
| 212 | 212 | throw new InvalidArgumentException('Invalid UTF-8 string.'); |
@@ -231,15 +231,15 @@ discard block |
||
| 231 | 231 | $regexp .= 'i'; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 234 | + set_error_handler(static function($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 235 | 235 | |
| 236 | 236 | try { |
| 237 | - if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { |
|
| 237 | + if (false === $match($regexp . 'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { |
|
| 238 | 238 | $lastError = preg_last_error(); |
| 239 | 239 | |
| 240 | 240 | foreach (get_defined_constants(true)['pcre'] as $k => $v) { |
| 241 | 241 | if ($lastError === $v && '_ERROR' === substr($k, -6)) { |
| 242 | - throw new RuntimeException('Matching failed with '.$k.'.'); |
|
| 242 | + throw new RuntimeException('Matching failed with ' . $k . '.'); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | $replace = 'preg_replace_callback'; |
| 318 | - $to = static function (array $m) use ($to): string { |
|
| 318 | + $to = static function(array $m) use ($to): string { |
|
| 319 | 319 | $to = $to($m); |
| 320 | 320 | |
| 321 | 321 | if ('' !== $to && (!\is_string($to) || !preg_match('//u', $to))) { |
@@ -330,15 +330,15 @@ discard block |
||
| 330 | 330 | $replace = 'preg_replace'; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 333 | + set_error_handler(static function($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 334 | 334 | |
| 335 | 335 | try { |
| 336 | - if (null === $string = $replace($fromRegexp.'u', $to, $this->string)) { |
|
| 336 | + if (null === $string = $replace($fromRegexp . 'u', $to, $this->string)) { |
|
| 337 | 337 | $lastError = preg_last_error(); |
| 338 | 338 | |
| 339 | 339 | foreach (get_defined_constants(true)['pcre'] as $k => $v) { |
| 340 | 340 | if ($lastError === $v && '_ERROR' === substr($k, -6)) { |
| 341 | - throw new RuntimeException('Matching failed with '.$k.'.'); |
|
| 341 | + throw new RuntimeException('Matching failed with ' . $k . '.'); |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | |
| 377 | 377 | $limit = $allWords ? -1 : 1; |
| 378 | 378 | |
| 379 | - $str->string = preg_replace_callback('/\b./u', static function (array $m): string { |
|
| 379 | + $str->string = preg_replace_callback('/\b./u', static function(array $m): string { |
|
| 380 | 380 | return mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8'); |
| 381 | 381 | }, $str->string, $limit); |
| 382 | 382 | |
@@ -480,22 +480,22 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | switch ($type) { |
| 482 | 482 | case \STR_PAD_RIGHT: |
| 483 | - return $this->append(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : '')); |
|
| 483 | + return $this->append(str_repeat($pad->string, $freeLen / $padLen) . ($len ? $pad->slice(0, $len) : '')); |
|
| 484 | 484 | |
| 485 | 485 | case \STR_PAD_LEFT: |
| 486 | - return $this->prepend(str_repeat($pad->string, $freeLen / $padLen).($len ? $pad->slice(0, $len) : '')); |
|
| 486 | + return $this->prepend(str_repeat($pad->string, $freeLen / $padLen) . ($len ? $pad->slice(0, $len) : '')); |
|
| 487 | 487 | |
| 488 | 488 | case \STR_PAD_BOTH: |
| 489 | 489 | $freeLen /= 2; |
| 490 | 490 | |
| 491 | 491 | $rightLen = ceil($freeLen); |
| 492 | 492 | $len = $rightLen % $padLen; |
| 493 | - $str = $this->append(str_repeat($pad->string, $rightLen / $padLen).($len ? $pad->slice(0, $len) : '')); |
|
| 493 | + $str = $this->append(str_repeat($pad->string, $rightLen / $padLen) . ($len ? $pad->slice(0, $len) : '')); |
|
| 494 | 494 | |
| 495 | 495 | $leftLen = floor($freeLen); |
| 496 | 496 | $len = $leftLen % $padLen; |
| 497 | 497 | |
| 498 | - return $str->prepend(str_repeat($pad->string, $leftLen / $padLen).($len ? $pad->slice(0, $len) : '')); |
|
| 498 | + return $str->prepend(str_repeat($pad->string, $leftLen / $padLen) . ($len ? $pad->slice(0, $len) : '')); |
|
| 499 | 499 | |
| 500 | 500 | default: |
| 501 | 501 | throw new InvalidArgumentException('Invalid padding type.'); |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | static $tableZero; |
| 534 | 534 | if (null === $tableZero) { |
| 535 | - $tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php'; |
|
| 535 | + $tableZero = require __DIR__ . '/Resources/data/wcswidth_table_zero.php'; |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | if ($codePoint >= $tableZero[0][0] && $codePoint <= $tableZero[$ubound = \count($tableZero) - 1][1]) { |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | static $tableWide; |
| 554 | 554 | if (null === $tableWide) { |
| 555 | - $tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php'; |
|
| 555 | + $tableWide = require __DIR__ . '/Resources/data/wcswidth_table_wide.php'; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | if ($codePoint >= $tableWide[0][0] && $codePoint <= $tableWide[$ubound = \count($tableWide) - 1][1]) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public function append(string ...$suffix): AbstractString |
| 45 | 45 | { |
| 46 | 46 | $str = clone $this; |
| 47 | - $str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix)); |
|
| 47 | + $str->string = $this->string . (1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix)); |
|
| 48 | 48 | normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); |
| 49 | 49 | |
| 50 | 50 | if (false === $str->string) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $rx .= '\X{65535}'; |
| 70 | 70 | $length -= 65535; |
| 71 | 71 | } |
| 72 | - $rx .= '\X{'.$length.'})/u'; |
|
| 72 | + $rx .= '\X{' . $length . '})/u'; |
|
| 73 | 73 | |
| 74 | 74 | $str = clone $this; |
| 75 | 75 | $chunks = []; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } elseif (\is_array($suffix) || $suffix instanceof \Traversable) { |
| 90 | 90 | return parent::endsWith($suffix); |
| 91 | 91 | } else { |
| 92 | - $suffix = (string) $suffix; |
|
| 92 | + $suffix = (string)$suffix; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } elseif (\is_array($string) || $string instanceof \Traversable) { |
| 114 | 114 | return parent::equalsTo($string); |
| 115 | 115 | } else { |
| 116 | - $string = (string) $string; |
|
| 116 | + $string = (string)$string; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } elseif (\is_array($needle) || $needle instanceof \Traversable) { |
| 134 | 134 | return parent::indexOf($needle, $offset); |
| 135 | 135 | } else { |
| 136 | - $needle = (string) $needle; |
|
| 136 | + $needle = (string)$needle; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } elseif (\is_array($needle) || $needle instanceof \Traversable) { |
| 160 | 160 | return parent::indexOfLast($needle, $offset); |
| 161 | 161 | } else { |
| 162 | - $needle = (string) $needle; |
|
| 162 | + $needle = (string)$needle; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | public function prepend(string ...$prefix): AbstractString |
| 220 | 220 | { |
| 221 | 221 | $str = clone $this; |
| 222 | - $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string; |
|
| 222 | + $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)) . $this->string; |
|
| 223 | 223 | normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); |
| 224 | 224 | |
| 225 | 225 | if (false === $str->string) { |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | while ('' !== $tail && false !== $i = $indexOf($tail, $from)) { |
| 243 | 243 | $slice = grapheme_substr($tail, 0, $i); |
| 244 | - $result .= $slice.$to; |
|
| 244 | + $result .= $slice . $to; |
|
| 245 | 245 | $tail = substr($tail, \strlen($slice) + \strlen($from)); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $str->string = $result.$tail; |
|
| 248 | + $str->string = $result . $tail; |
|
| 249 | 249 | normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); |
| 250 | 250 | |
| 251 | 251 | if (false === $str->string) { |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) { |
| 272 | 272 | $start = 0; |
| 273 | 273 | } |
| 274 | - $str->string = (string) grapheme_substr($this->string, $start, $length ?? 2147483647); |
|
| 274 | + $str->string = (string)grapheme_substr($this->string, $start, $length ?? 2147483647); |
|
| 275 | 275 | |
| 276 | 276 | return $str; |
| 277 | 277 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | if (null !== $flags) { |
| 309 | - return parent::split($delimiter.'u', $limit, $flags); |
|
| 309 | + return parent::split($delimiter . 'u', $limit, $flags); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | normalizer_is_normalized($delimiter) ?: $delimiter = normalizer_normalize($delimiter); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | } elseif (\is_array($prefix) || $prefix instanceof \Traversable) { |
| 341 | 341 | return parent::startsWith($prefix); |
| 342 | 342 | } else { |
| 343 | - $prefix = (string) $prefix; |
|
| 343 | + $prefix = (string)$prefix; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC; |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | public function __wakeup() |
| 361 | 361 | { |
| 362 | 362 | if (!\is_string($this->string)) { |
| 363 | - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
|
| 363 | + throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $keys = null; |
| 74 | 74 | |
| 75 | 75 | foreach ($values as $k => $v) { |
| 76 | - if (\is_string($k) && '' !== $k && $k !== $j = (string) new static($k)) { |
|
| 76 | + if (\is_string($k) && '' !== $k && $k !== $j = (string)new static($k)) { |
|
| 77 | 77 | $keys = $keys ?? array_keys($values); |
| 78 | 78 | $keys[$i] = $j; |
| 79 | 79 | } |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | $str = clone $this; |
| 101 | 101 | $i = \PHP_INT_MAX; |
| 102 | 102 | |
| 103 | - foreach ((array) $needle as $n) { |
|
| 104 | - $n = (string) $n; |
|
| 103 | + foreach ((array)$needle as $n) { |
|
| 104 | + $n = (string)$n; |
|
| 105 | 105 | $j = $this->indexOf($n, $offset); |
| 106 | 106 | |
| 107 | 107 | if (null !== $j && $j < $i) { |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | $str = clone $this; |
| 132 | 132 | $i = null; |
| 133 | 133 | |
| 134 | - foreach ((array) $needle as $n) { |
|
| 135 | - $n = (string) $n; |
|
| 134 | + foreach ((array)$needle as $n) { |
|
| 135 | + $n = (string)$n; |
|
| 136 | 136 | $j = $this->indexOfLast($n, $offset); |
| 137 | 137 | |
| 138 | 138 | if (null !== $j && $j >= $i) { |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | $str = clone $this; |
| 168 | 168 | $i = \PHP_INT_MAX; |
| 169 | 169 | |
| 170 | - foreach ((array) $needle as $n) { |
|
| 171 | - $n = (string) $n; |
|
| 170 | + foreach ((array)$needle as $n) { |
|
| 171 | + $n = (string)$n; |
|
| 172 | 172 | $j = $this->indexOf($n, $offset); |
| 173 | 173 | |
| 174 | 174 | if (null !== $j && $j < $i) { |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | $str = clone $this; |
| 199 | 199 | $i = null; |
| 200 | 200 | |
| 201 | - foreach ((array) $needle as $n) { |
|
| 202 | - $n = (string) $n; |
|
| 201 | + foreach ((array)$needle as $n) { |
|
| 202 | + $n = (string)$n; |
|
| 203 | 203 | $j = $this->indexOfLast($n, $offset); |
| 204 | 204 | |
| 205 | 205 | if (null !== $j && $j >= $i) { |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | foreach ($suffix as $s) { |
| 271 | - if ($this->endsWith((string) $s)) { |
|
| 271 | + if ($this->endsWith((string)$s)) { |
|
| 272 | 272 | return true; |
| 273 | 273 | } |
| 274 | 274 | } |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $suffix = preg_quote($suffix); |
| 289 | - $regex = '{('.$suffix.')(?:'.$suffix.')++$}D'; |
|
| 289 | + $regex = '{(' . $suffix . ')(?:' . $suffix . ')++$}D'; |
|
| 290 | 290 | |
| 291 | - return $this->replaceMatches($regex.($this->ignoreCase ? 'i' : ''), '$1'); |
|
| 291 | + return $this->replaceMatches($regex . ($this->ignoreCase ? 'i' : ''), '$1'); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | foreach ($string as $s) { |
| 326 | - if ($this->equalsTo((string) $s)) { |
|
| 326 | + if ($this->equalsTo((string)$s)) { |
|
| 327 | 327 | return true; |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $i = \PHP_INT_MAX; |
| 360 | 360 | |
| 361 | 361 | foreach ($needle as $n) { |
| 362 | - $j = $this->indexOf((string) $n, $offset); |
|
| 362 | + $j = $this->indexOf((string)$n, $offset); |
|
| 363 | 363 | |
| 364 | 364 | if (null !== $j && $j < $i) { |
| 365 | 365 | $i = $j; |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $i = null; |
| 382 | 382 | |
| 383 | 383 | foreach ($needle as $n) { |
| 384 | - $j = $this->indexOfLast((string) $n, $offset); |
|
| 384 | + $j = $this->indexOfLast((string)$n, $offset); |
|
| 385 | 385 | |
| 386 | 386 | if (null !== $j && $j >= $i) { |
| 387 | 387 | $i = $offset = $j; |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | $delimiter .= 'i'; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 505 | + set_error_handler(static function($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 506 | 506 | |
| 507 | 507 | try { |
| 508 | 508 | if (false === $chunks = preg_split($delimiter, $this->string, $limit, $flags)) { |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | foreach (get_defined_constants(true)['pcre'] as $k => $v) { |
| 512 | 512 | if ($lastError === $v && '_ERROR' === substr($k, -6)) { |
| 513 | - throw new RuntimeException('Splitting failed with '.$k.'.'); |
|
| 513 | + throw new RuntimeException('Splitting failed with ' . $k . '.'); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | foreach ($prefix as $prefix) { |
| 550 | - if ($this->startsWith((string) $prefix)) { |
|
| 550 | + if ($this->startsWith((string)$prefix)) { |
|
| 551 | 551 | return true; |
| 552 | 552 | } |
| 553 | 553 | } |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | return $b; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 575 | + set_error_handler(static function($t, $m) { throw new InvalidArgumentException($m); }); |
|
| 576 | 576 | |
| 577 | 577 | try { |
| 578 | 578 | try { |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | $str = clone $this; |
| 708 | - $str->string = $string.implode('', $chars); |
|
| 708 | + $str->string = $string . implode('', $chars); |
|
| 709 | 709 | |
| 710 | 710 | return $str; |
| 711 | 711 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | // Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl) |
| 108 | 108 | $transliterator = ['de-ASCII']; |
| 109 | 109 | } elseif (\function_exists('transliterator_transliterate') && $locale) { |
| 110 | - $transliterator = (array) $this->createTransliterator($locale); |
|
| 110 | + $transliterator = (array)$this->createTransliterator($locale); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if ($this->symbolsMap instanceof \Closure) { |
| 114 | 114 | // If the symbols map is passed as a closure, there is no need to fallback to the parent locale |
| 115 | 115 | // as the closure can just provide substitutions for all locales of interest. |
| 116 | 116 | $symbolsMap = $this->symbolsMap; |
| 117 | - array_unshift($transliterator, static function ($s) use ($symbolsMap, $locale) { |
|
| 117 | + array_unshift($transliterator, static function($s) use ($symbolsMap, $locale) { |
|
| 118 | 118 | return $symbolsMap($s, $locale); |
| 119 | 119 | }); |
| 120 | 120 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | if ($map) { |
| 135 | 135 | foreach ($map as $char => $replace) { |
| 136 | - $unicodeString = $unicodeString->replace($char, ' '.$replace.' '); |
|
| 136 | + $unicodeString = $unicodeString->replace($char, ' ' . $replace . ' '); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | // Exact locale supported, cache and return |
| 154 | 154 | if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$locale] ?? null) { |
| 155 | - return $this->transliterators[$locale] = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id); |
|
| 155 | + return $this->transliterators[$locale] = \Transliterator::create($id . '/BGN') ?? \Transliterator::create($id); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Locale not supported and no parent, fallback to any-latin |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | // Try to use the parent locale (ie. try "de" for "de_AT") and cache both locales |
| 164 | 164 | if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$parent] ?? null) { |
| 165 | - $transliterator = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id); |
|
| 165 | + $transliterator = \Transliterator::create($id . '/BGN') ?? \Transliterator::create($id); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $this->transliterators[$locale] = $this->transliterators[$parent] = $transliterator ?? null; |