@@ -22,29 +22,29 @@ |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!function_exists('grapheme_extract')) { |
| 25 | - function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string|false { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); } |
|
| 25 | + function grapheme_extract(?string $haystack, ?int $size, ?int $type = GRAPHEME_EXTR_COUNT, ?int $offset = 0, &$next = null): string | false { return p\Grapheme::grapheme_extract((string) $haystack, (int) $size, (int) $type, (int) $offset, $next); } |
|
| 26 | 26 | } |
| 27 | 27 | if (!function_exists('grapheme_stripos')) { |
| 28 | - function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 28 | + function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 29 | 29 | } |
| 30 | 30 | if (!function_exists('grapheme_stristr')) { |
| 31 | - function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
|
| 31 | + function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string | false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
|
| 32 | 32 | } |
| 33 | 33 | if (!function_exists('grapheme_strlen')) { |
| 34 | - function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); } |
|
| 34 | + function grapheme_strlen(?string $string): int | false | null { return p\Grapheme::grapheme_strlen((string) $string); } |
|
| 35 | 35 | } |
| 36 | 36 | if (!function_exists('grapheme_strpos')) { |
| 37 | - function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 37 | + function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 38 | 38 | } |
| 39 | 39 | if (!function_exists('grapheme_strripos')) { |
| 40 | - function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 40 | + function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 41 | 41 | } |
| 42 | 42 | if (!function_exists('grapheme_strrpos')) { |
| 43 | - function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 43 | + function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int | false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); } |
|
| 44 | 44 | } |
| 45 | 45 | if (!function_exists('grapheme_strstr')) { |
| 46 | - function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
|
| 46 | + function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string | false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); } |
|
| 47 | 47 | } |
| 48 | 48 | if (!function_exists('grapheme_substr')) { |
| 49 | - function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); } |
|
| 49 | + function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string | false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); } |
|
| 50 | 50 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | private const CASE_FOLD = [ |
| 41 | 41 | ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"], |
| 42 | - ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'], |
|
| 42 | + ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'], |
|
| 43 | 43 | ]; |
| 44 | 44 | |
| 45 | 45 | public static function grapheme_extract($s, $size, $type = \GRAPHEME_EXTR_COUNT, $start = 0, &$next = 0) |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | if (!\is_scalar($s)) { |
| 52 | 52 | $hasError = false; |
| 53 | - set_error_handler(function () use (&$hasError) { $hasError = true; }); |
|
| 53 | + set_error_handler(function() use (&$hasError) { $hasError = true; }); |
|
| 54 | 54 | $next = substr($s, $start); |
| 55 | 55 | restore_error_handler(); |
| 56 | 56 | if ($hasError) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $next = $start; |
| 85 | 85 | |
| 86 | - $s = preg_split('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', "\r\n".$s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); |
|
| 86 | + $s = preg_split('/(' . SYMFONY_GRAPHEME_CLUSTER_RX . ')/u', "\r\n" . $s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE); |
|
| 87 | 87 | |
| 88 | 88 | if (!isset($s[1])) { |
| 89 | 89 | return false; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | public static function grapheme_strlen($s) |
| 115 | 115 | { |
| 116 | - preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $s, -1, $len); |
|
| 116 | + preg_replace('/' . SYMFONY_GRAPHEME_CLUSTER_RX . '/u', '', $s, -1, $len); |
|
| 117 | 117 | |
| 118 | 118 | return 0 === $len && '' !== $s ? null : $len; |
| 119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $len = 2147483647; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - preg_match_all('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', $s, $s); |
|
| 127 | + preg_match_all('/' . SYMFONY_GRAPHEME_CLUSTER_RX . '/u', $s, $s); |
|
| 128 | 128 | |
| 129 | 129 | $slen = \count($s[0]); |
| 130 | 130 | $start = (int) $start; |
@@ -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 = []; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')]; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public function endsWith(string|iterable|AbstractString $suffix): bool |
|
| 83 | + public function endsWith(string | iterable | AbstractString $suffix): bool |
|
| 84 | 84 | { |
| 85 | 85 | if ($suffix instanceof AbstractString) { |
| 86 | 86 | $suffix = $suffix->string; |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | if ($this->ignoreCase) { |
| 96 | - return preg_match('{'.preg_quote($suffix).'$}iuD', $this->string); |
|
| 96 | + return preg_match('{' . preg_quote($suffix) . '$}iuD', $this->string); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | return \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix)); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public function equalsTo(string|iterable|AbstractString $string): bool |
|
| 102 | + public function equalsTo(string | iterable | AbstractString $string): bool |
|
| 103 | 103 | { |
| 104 | 104 | if ($string instanceof AbstractString) { |
| 105 | 105 | $string = $string->string; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | return $string === $this->string; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int |
|
| 117 | + public function indexOf(string | iterable | AbstractString $needle, int $offset = 0): ?int |
|
| 118 | 118 | { |
| 119 | 119 | if ($needle instanceof AbstractString) { |
| 120 | 120 | $needle = $needle->string; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | return false === $i ? null : $i; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int |
|
| 134 | + public function indexOfLast(string | iterable | AbstractString $needle, int $offset = 0): ?int |
|
| 135 | 135 | { |
| 136 | 136 | if ($needle instanceof AbstractString) { |
| 137 | 137 | $needle = $needle->string; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | public function prepend(string ...$prefix): static |
| 157 | 157 | { |
| 158 | 158 | $str = clone $this; |
| 159 | - $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string; |
|
| 159 | + $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)) . $this->string; |
|
| 160 | 160 | |
| 161 | 161 | if (!preg_match('//u', $str->string)) { |
| 162 | 162 | throw new InvalidArgumentException('Invalid UTF-8 string.'); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ($this->ignoreCase) { |
| 181 | - $str->string = implode($to, preg_split('{'.preg_quote($from).'}iuD', $this->string)); |
|
| 181 | + $str->string = implode($to, preg_split('{' . preg_quote($from) . '}iuD', $this->string)); |
|
| 182 | 182 | } else { |
| 183 | 183 | $str->string = str_replace($from, $to, $this->string); |
| 184 | 184 | } |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | if (null !== $flags) { |
| 222 | - return parent::split($delimiter.'u', $limit, $flags); |
|
| 222 | + return parent::split($delimiter . 'u', $limit, $flags); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | if (!preg_match('//u', $delimiter)) { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | $str = clone $this; |
| 230 | 230 | $chunks = $this->ignoreCase |
| 231 | - ? preg_split('{'.preg_quote($delimiter).'}iuD', $this->string, $limit) |
|
| 231 | + ? preg_split('{' . preg_quote($delimiter) . '}iuD', $this->string, $limit) |
|
| 232 | 232 | : explode($delimiter, $this->string, $limit); |
| 233 | 233 | |
| 234 | 234 | foreach ($chunks as &$chunk) { |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | return $chunks; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public function startsWith(string|iterable|AbstractString $prefix): bool |
|
| 242 | + public function startsWith(string | iterable | AbstractString $prefix): bool |
|
| 243 | 243 | { |
| 244 | 244 | if ($prefix instanceof AbstractString) { |
| 245 | 245 | $prefix = $prefix->string; |
@@ -18,19 +18,19 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class LazyString implements \Stringable, \JsonSerializable |
| 20 | 20 | { |
| 21 | - private \Closure|string $value; |
|
| 21 | + private \Closure | string $value; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @param callable|array $callback A callable or a [Closure, method] lazy-callable |
| 25 | 25 | */ |
| 26 | - public static function fromCallable(callable|array $callback, mixed ...$arguments): static |
|
| 26 | + public static function fromCallable(callable | array $callback, mixed ...$arguments): static |
|
| 27 | 27 | { |
| 28 | 28 | if (\is_array($callback) && !\is_callable($callback) && !(($callback[0] ?? null) instanceof \Closure || 2 < \count($callback))) { |
| 29 | - throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map('get_debug_type', $callback)).']')); |
|
| 29 | + throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '[' . implode(', ', array_map('get_debug_type', $callback)) . ']')); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $lazyString = new static(); |
| 33 | - $lazyString->value = static function () use (&$callback, &$arguments): string { |
|
| 33 | + $lazyString->value = static function() use (&$callback, &$arguments): string { |
|
| 34 | 34 | static $value; |
| 35 | 35 | |
| 36 | 36 | if (null !== $arguments) { |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | return $lazyString; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public static function fromStringable(string|int|float|bool|\Stringable $value): static |
|
| 52 | + public static function fromStringable(string | int | float | bool | \Stringable $value): static |
|
| 53 | 53 | { |
| 54 | 54 | if (\is_object($value)) { |
| 55 | 55 | return static::fromCallable($value->__toString(...)); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @throws \TypeError When the provided value is not stringable |
| 76 | 76 | */ |
| 77 | - final public static function resolve(\Stringable|string|int|float|bool $value): string |
|
| 77 | + final public static function resolve(\Stringable | string | int | float | bool $value): string |
|
| 78 | 78 | { |
| 79 | 79 | return $value; |
| 80 | 80 | } |
@@ -140,6 +140,6 @@ discard block |
||
| 140 | 140 | $method = '__invoke'; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return $class.'::'.$method; |
|
| 143 | + return $class . '::' . $method; |
|
| 144 | 144 | } |
| 145 | 145 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * @param string|string[] $needle |
| 95 | 95 | */ |
| 96 | - public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 96 | + public function after(string | iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 97 | 97 | { |
| 98 | 98 | $str = clone $this; |
| 99 | 99 | $i = \PHP_INT_MAX; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | /** |
| 127 | 127 | * @param string|string[] $needle |
| 128 | 128 | */ |
| 129 | - public function afterLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 129 | + public function afterLast(string | iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 130 | 130 | { |
| 131 | 131 | $str = clone $this; |
| 132 | 132 | $i = null; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | /** |
| 162 | 162 | * @param string|string[] $needle |
| 163 | 163 | */ |
| 164 | - public function before(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 164 | + public function before(string | iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 165 | 165 | { |
| 166 | 166 | $str = clone $this; |
| 167 | 167 | $i = \PHP_INT_MAX; |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | /** |
| 195 | 195 | * @param string|string[] $needle |
| 196 | 196 | */ |
| 197 | - public function beforeLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 197 | + public function beforeLast(string | iterable $needle, bool $includeNeedle = false, int $offset = 0): static |
|
| 198 | 198 | { |
| 199 | 199 | $str = clone $this; |
| 200 | 200 | $i = null; |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | /** |
| 253 | 253 | * @param string|string[] $needle |
| 254 | 254 | */ |
| 255 | - public function containsAny(string|iterable $needle): bool |
|
| 255 | + public function containsAny(string | iterable $needle): bool |
|
| 256 | 256 | { |
| 257 | 257 | return null !== $this->indexOf($needle); |
| 258 | 258 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | /** |
| 261 | 261 | * @param string|string[] $suffix |
| 262 | 262 | */ |
| 263 | - public function endsWith(string|iterable $suffix): bool |
|
| 263 | + public function endsWith(string | iterable $suffix): bool |
|
| 264 | 264 | { |
| 265 | 265 | if (\is_string($suffix)) { |
| 266 | 266 | throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | $suffix = preg_quote($suffix); |
| 285 | - $regex = '{('.$suffix.')(?:'.$suffix.')++$}D'; |
|
| 285 | + $regex = '{(' . $suffix . ')(?:' . $suffix . ')++$}D'; |
|
| 286 | 286 | |
| 287 | - return $this->replaceMatches($regex.($this->ignoreCase ? 'i' : ''), '$1'); |
|
| 287 | + return $this->replaceMatches($regex . ($this->ignoreCase ? 'i' : ''), '$1'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | public function ensureStart(string $prefix): static |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | /** |
| 310 | 310 | * @param string|string[] $string |
| 311 | 311 | */ |
| 312 | - public function equalsTo(string|iterable $string): bool |
|
| 312 | + public function equalsTo(string | iterable $string): bool |
|
| 313 | 313 | { |
| 314 | 314 | if (\is_string($string)) { |
| 315 | 315 | throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | /** |
| 338 | 338 | * @param string|string[] $needle |
| 339 | 339 | */ |
| 340 | - public function indexOf(string|iterable $needle, int $offset = 0): ?int |
|
| 340 | + public function indexOf(string | iterable $needle, int $offset = 0): ?int |
|
| 341 | 341 | { |
| 342 | 342 | if (\is_string($needle)) { |
| 343 | 343 | throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | /** |
| 360 | 360 | * @param string|string[] $needle |
| 361 | 361 | */ |
| 362 | - public function indexOfLast(string|iterable $needle, int $offset = 0): ?int |
|
| 362 | + public function indexOfLast(string | iterable $needle, int $offset = 0): ?int |
|
| 363 | 363 | { |
| 364 | 364 | if (\is_string($needle)) { |
| 365 | 365 | throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | abstract public function replace(string $from, string $to): static; |
| 427 | 427 | |
| 428 | - abstract public function replaceMatches(string $fromRegexp, string|callable $to): static; |
|
| 428 | + abstract public function replaceMatches(string $fromRegexp, string | callable $to): static; |
|
| 429 | 429 | |
| 430 | 430 | abstract public function reverse(): static; |
| 431 | 431 | |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | try { |
| 454 | 454 | if (false === $chunks = preg_split($delimiter, $this->string, $limit, $flags)) { |
| 455 | - throw new RuntimeException('Splitting failed with error: '.preg_last_error_msg()); |
|
| 455 | + throw new RuntimeException('Splitting failed with error: ' . preg_last_error_msg()); |
|
| 456 | 456 | } |
| 457 | 457 | } finally { |
| 458 | 458 | restore_error_handler(); |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | /** |
| 479 | 479 | * @param string|string[] $prefix |
| 480 | 480 | */ |
| 481 | - public function startsWith(string|iterable $prefix): bool |
|
| 481 | + public function startsWith(string | iterable $prefix): bool |
|
| 482 | 482 | { |
| 483 | 483 | if (\is_string($prefix)) { |
| 484 | 484 | throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class)); |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | $str = clone $this; |
| 683 | - $str->string = $string.implode('', $chars); |
|
| 683 | + $str->string = $string . implode('', $chars); |
|
| 684 | 684 | |
| 685 | 685 | return $str; |
| 686 | 686 | } |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - return [$singular.'s']; |
|
| 144 | + return [$singular . 's']; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | private function isInflectedWord(string $word): bool |
@@ -487,13 +487,13 @@ discard block |
||
| 487 | 487 | $singulars = []; |
| 488 | 488 | |
| 489 | 489 | foreach ($newSuffix as $newSuffixEntry) { |
| 490 | - $singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry); |
|
| 490 | + $singulars[] = $newBase . ($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | return $singulars; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)]; |
|
| 496 | + return [$newBase . ($firstUpper ? ucfirst($newSuffix) : $newSuffix)]; |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | // Suffix is longer than word |
@@ -564,13 +564,13 @@ discard block |
||
| 564 | 564 | $plurals = []; |
| 565 | 565 | |
| 566 | 566 | foreach ($newSuffix as $newSuffixEntry) { |
| 567 | - $plurals[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry); |
|
| 567 | + $plurals[] = $newBase . ($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | return $plurals; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)]; |
|
| 573 | + return [$newBase . ($firstUpper ? ucfirst($newSuffix) : $newSuffix)]; |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | // Suffix is longer than word |
@@ -581,6 +581,6 @@ discard block |
||
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | // Assume that plural is singular with a trailing `s` |
| 584 | - return [$singular.'s']; |
|
| 584 | + return [$singular . 's']; |
|
| 585 | 585 | } |
| 586 | 586 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | return $chunks; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - public function endsWith(string|iterable|AbstractString $suffix): bool |
|
| 135 | + public function endsWith(string | iterable | AbstractString $suffix): bool |
|
| 136 | 136 | { |
| 137 | 137 | if ($suffix instanceof AbstractString) { |
| 138 | 138 | $suffix = $suffix->string; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public function equalsTo(string|iterable|AbstractString $string): bool |
|
| 146 | + public function equalsTo(string | iterable | AbstractString $string): bool |
|
| 147 | 147 | { |
| 148 | 148 | if ($string instanceof AbstractString) { |
| 149 | 149 | $string = $string->string; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | return $str; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int |
|
| 169 | + public function indexOf(string | iterable | AbstractString $needle, int $offset = 0): ?int |
|
| 170 | 170 | { |
| 171 | 171 | if ($needle instanceof AbstractString) { |
| 172 | 172 | $needle = $needle->string; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | return false === $i ? null : $i; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int |
|
| 186 | + public function indexOfLast(string | iterable | AbstractString $needle, int $offset = 0): ?int |
|
| 187 | 187 | { |
| 188 | 188 | if ($needle instanceof AbstractString) { |
| 189 | 189 | $needle = $needle->string; |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $str = clone $this; |
| 211 | 211 | |
| 212 | - $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : ''; |
|
| 213 | - $str->string = implode($this->string, $strings).$tail; |
|
| 212 | + $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue . array_pop($strings) : ''; |
|
| 213 | + $str->string = implode($this->string, $strings) . $tail; |
|
| 214 | 214 | |
| 215 | 215 | return $str; |
| 216 | 216 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | try { |
| 242 | 242 | if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { |
| 243 | - throw new RuntimeException('Matching failed with error: '.preg_last_error_msg()); |
|
| 243 | + throw new RuntimeException('Matching failed with error: ' . preg_last_error_msg()); |
|
| 244 | 244 | } |
| 245 | 245 | } finally { |
| 246 | 246 | restore_error_handler(); |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | public function prepend(string ...$prefix): static |
| 277 | 277 | { |
| 278 | 278 | $str = clone $this; |
| 279 | - $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string; |
|
| 279 | + $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)) . $str->string; |
|
| 280 | 280 | |
| 281 | 281 | return $str; |
| 282 | 282 | } |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | return $str; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - public function replaceMatches(string $fromRegexp, string|callable $to): static |
|
| 295 | + public function replaceMatches(string $fromRegexp, string | callable $to): static |
|
| 296 | 296 | { |
| 297 | 297 | if ($this->ignoreCase) { |
| 298 | 298 | $fromRegexp .= 'i'; |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | foreach (get_defined_constants(true)['pcre'] as $k => $v) { |
| 310 | 310 | if ($lastError === $v && str_ends_with($k, '_ERROR')) { |
| 311 | - throw new RuntimeException('Matching failed with '.$k.'.'); |
|
| 311 | + throw new RuntimeException('Matching failed with ' . $k . '.'); |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | $str = clone $this; |
| 374 | 374 | $chunks = $this->ignoreCase |
| 375 | - ? preg_split('{'.preg_quote($delimiter).'}iD', $this->string, $limit) |
|
| 375 | + ? preg_split('{' . preg_quote($delimiter) . '}iD', $this->string, $limit) |
|
| 376 | 376 | : explode($delimiter, $this->string, $limit); |
| 377 | 377 | |
| 378 | 378 | foreach ($chunks as &$chunk) { |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | return $chunks; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - public function startsWith(string|iterable|AbstractString $prefix): bool |
|
| 386 | + public function startsWith(string | iterable | AbstractString $prefix): bool |
|
| 387 | 387 | { |
| 388 | 388 | if ($prefix instanceof AbstractString) { |
| 389 | 389 | $prefix = $prefix->string; |
@@ -60,18 +60,18 @@ |
||
| 60 | 60 | } |
| 61 | 61 | foreach ($suffixes as $suffix) { |
| 62 | 62 | foreach ($dirs as $dir) { |
| 63 | - if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) { |
|
| 63 | + if (@is_file($file = $dir . \DIRECTORY_SEPARATOR . $name . $suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) { |
|
| 64 | 64 | return $file; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if (!@is_dir($dir) && basename($dir) === $name.$suffix && @is_executable($dir)) { |
|
| 67 | + if (!@is_dir($dir) && basename($dir) === $name . $suffix && @is_executable($dir)) { |
|
| 68 | 68 | return $dir; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v --'; |
| 74 | - if (\function_exists('exec') && ($executablePath = strtok(@exec($command.' '.escapeshellarg($name)), \PHP_EOL)) && @is_executable($executablePath)) { |
|
| 74 | + if (\function_exists('exec') && ($executablePath = strtok(@exec($command . ' ' . escapeshellarg($name)), \PHP_EOL)) && @is_executable($executablePath)) { |
|
| 75 | 75 | return $executablePath; |
| 76 | 76 | } |
| 77 | 77 | |