@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | public const TIMEOUT_PRECISION = 0.2; |
| 48 | 48 | |
| 49 | 49 | public const ITER_NON_BLOCKING = 1; // By default, iterating over outputs is a blocking call, use this flag to make it non-blocking |
| 50 | - public const ITER_KEEP_OUTPUT = 2; // By default, outputs are cleared while iterating, use this flag to keep them in memory |
|
| 51 | - public const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating |
|
| 52 | - public const ITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating |
|
| 50 | + public const ITER_KEEP_OUTPUT = 2; // By default, outputs are cleared while iterating, use this flag to keep them in memory |
|
| 51 | + public const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating |
|
| 52 | + public const ITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating |
|
| 53 | 53 | |
| 54 | 54 | private ?\Closure $callback = null; |
| 55 | - private array|string $commandline; |
|
| 55 | + private array | string $commandline; |
|
| 56 | 56 | private ?string $cwd; |
| 57 | 57 | private array $env = []; |
| 58 | 58 | /** @var resource|string|\Iterator|null */ |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | private array $options = ['suppress_errors' => true, 'bypass_shell' => true]; |
| 80 | 80 | private array $ignoredSignals = []; |
| 81 | 81 | |
| 82 | - private WindowsPipes|UnixPipes $processPipes; |
|
| 82 | + private WindowsPipes | UnixPipes $processPipes; |
|
| 83 | 83 | |
| 84 | 84 | private ?int $latestSignal = null; |
| 85 | 85 | private ?int $cachedExitCode = null; |
@@ -199,12 +199,12 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | public function __sleep(): array |
| 201 | 201 | { |
| 202 | - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); |
|
| 202 | + throw new \BadMethodCallException('Cannot serialize ' . __CLASS__); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | public function __wakeup(): void |
| 206 | 206 | { |
| 207 | - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
|
| 207 | + throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | public function __destruct() |
@@ -322,18 +322,18 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | if (\is_array($commandline)) { |
| 324 | 324 | // exec is mandatory to deal with sending a signal to the process |
| 325 | - $commandline = 'exec '.$this->buildShellCommandline($commandline); |
|
| 325 | + $commandline = 'exec ' . $this->buildShellCommandline($commandline); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // See https://unix.stackexchange.com/questions/71205/background-process-pipe-input |
| 329 | - $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; |
|
| 329 | + $commandline = '{ (' . $commandline . ') <&3 3<&- 3>/dev/null & } 3<&0;'; |
|
| 330 | 330 | $commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code'; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | $envPairs = []; |
| 334 | 334 | foreach ($env as $k => $v) { |
| 335 | 335 | if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) { |
| 336 | - $envPairs[] = $k.'='.$v; |
|
| 336 | + $envPairs[] = $k . '=' . $v; |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $lastError = null; |
| 345 | - set_error_handler(function ($type, $msg) use (&$lastError) { |
|
| 345 | + set_error_handler(function($type, $msg) use (&$lastError) { |
|
| 346 | 346 | $lastError = $msg; |
| 347 | 347 | |
| 348 | 348 | return true; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | // Ensure array vs string commands behave the same |
| 363 | 363 | if (!$process && \is_array($commandline)) { |
| 364 | - $process = @proc_open('exec '.$this->buildShellCommandline($commandline), $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); |
|
| 364 | + $process = @proc_open('exec ' . $this->buildShellCommandline($commandline), $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); |
|
| 365 | 365 | } |
| 366 | 366 | } finally { |
| 367 | 367 | if ($this->ignoredSignals && \function_exists('pcntl_sigprocmask')) { |
@@ -1301,7 +1301,7 @@ discard block |
||
| 1301 | 1301 | |
| 1302 | 1302 | $out = self::OUT; |
| 1303 | 1303 | |
| 1304 | - return function ($type, $data) use ($callback, $out): bool { |
|
| 1304 | + return function($type, $data) use ($callback, $out): bool { |
|
| 1305 | 1305 | if ($out == $type) { |
| 1306 | 1306 | $this->addOutput($data); |
| 1307 | 1307 | } else { |
@@ -1469,8 +1469,8 @@ discard block |
||
| 1469 | 1469 | $this->exitcode = null; |
| 1470 | 1470 | $this->fallbackStatus = []; |
| 1471 | 1471 | $this->processInformation = []; |
| 1472 | - $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
|
| 1473 | - $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
|
| 1472 | + $this->stdout = fopen('php://temp/maxmemory:' . (1024 * 1024), 'w+'); |
|
| 1473 | + $this->stderr = fopen('php://temp/maxmemory:' . (1024 * 1024), 'w+'); |
|
| 1474 | 1474 | $this->process = null; |
| 1475 | 1475 | $this->latestSignal = null; |
| 1476 | 1476 | $this->status = self::STATUS_READY; |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | return true; |
| 1538 | 1538 | } |
| 1539 | 1539 | |
| 1540 | - private function buildShellCommandline(string|array $commandline): string |
|
| 1540 | + private function buildShellCommandline(string | array $commandline): string |
|
| 1541 | 1541 | { |
| 1542 | 1542 | if (\is_string($commandline)) { |
| 1543 | 1543 | return $commandline; |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | return implode(' ', array_map($this->escapeArgument(...), $commandline)); |
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | - private function prepareWindowsCommandLine(string|array $cmd, array &$env): string |
|
| 1549 | + private function prepareWindowsCommandLine(string | array $cmd, array &$env): string |
|
| 1550 | 1550 | { |
| 1551 | 1551 | $cmd = $this->buildShellCommandline($cmd); |
| 1552 | 1552 | $uid = uniqid('', true); |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | [^"%!^]*+ |
| 1559 | 1559 | )++ |
| 1560 | 1560 | ) | [^"]*+ )"/x', |
| 1561 | - function ($m) use (&$env, $uid) { |
|
| 1561 | + function($m) use (&$env, $uid) { |
|
| 1562 | 1562 | static $varCount = 0; |
| 1563 | 1563 | static $varCache = []; |
| 1564 | 1564 | if (!isset($m[1])) { |
@@ -1571,23 +1571,23 @@ discard block |
||
| 1571 | 1571 | $value = str_replace("\0", '?', $value); |
| 1572 | 1572 | } |
| 1573 | 1573 | if (false === strpbrk($value, "\"%!\n")) { |
| 1574 | - return '"'.$value.'"'; |
|
| 1574 | + return '"' . $value . '"'; |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | $value = str_replace(['!LF!', '"^!"', '"^%"', '"^^"', '""'], ["\n", '!', '%', '^', '"'], $value); |
| 1578 | - $value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"'; |
|
| 1579 | - $var = $uid.++$varCount; |
|
| 1578 | + $value = '"' . preg_replace('/(\\\\*)"/', '$1$1\\"', $value) . '"'; |
|
| 1579 | + $var = $uid . ++$varCount; |
|
| 1580 | 1580 | |
| 1581 | 1581 | $env[$var] = $value; |
| 1582 | 1582 | |
| 1583 | - return $varCache[$m[0]] = '!'.$var.'!'; |
|
| 1583 | + return $varCache[$m[0]] = '!' . $var . '!'; |
|
| 1584 | 1584 | }, |
| 1585 | 1585 | $cmd |
| 1586 | 1586 | ); |
| 1587 | 1587 | |
| 1588 | - $cmd = 'cmd /V:ON /E:ON /D /C ('.str_replace("\n", ' ', $cmd).')'; |
|
| 1588 | + $cmd = 'cmd /V:ON /E:ON /D /C (' . str_replace("\n", ' ', $cmd) . ')'; |
|
| 1589 | 1589 | foreach ($this->processPipes->getFiles() as $offset => $filename) { |
| 1590 | - $cmd .= ' '.$offset.'>"'.$filename.'"'; |
|
| 1590 | + $cmd .= ' ' . $offset . '>"' . $filename . '"'; |
|
| 1591 | 1591 | } |
| 1592 | 1592 | |
| 1593 | 1593 | return $cmd; |
@@ -1626,7 +1626,7 @@ discard block |
||
| 1626 | 1626 | return '""'; |
| 1627 | 1627 | } |
| 1628 | 1628 | if ('\\' !== \DIRECTORY_SEPARATOR) { |
| 1629 | - return "'".str_replace("'", "'\\''", $argument)."'"; |
|
| 1629 | + return "'" . str_replace("'", "'\\''", $argument) . "'"; |
|
| 1630 | 1630 | } |
| 1631 | 1631 | if (str_contains($argument, "\0")) { |
| 1632 | 1632 | $argument = str_replace("\0", '?', $argument); |
@@ -1636,14 +1636,14 @@ discard block |
||
| 1636 | 1636 | } |
| 1637 | 1637 | $argument = preg_replace('/(\\\\+)$/', '$1$1', $argument); |
| 1638 | 1638 | |
| 1639 | - return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"'; |
|
| 1639 | + return '"' . str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument) . '"'; |
|
| 1640 | 1640 | } |
| 1641 | 1641 | |
| 1642 | 1642 | private function replacePlaceholders(string $commandline, array $env): string |
| 1643 | 1643 | { |
| 1644 | - return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) { |
|
| 1644 | + return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function($matches) use ($commandline, $env) { |
|
| 1645 | 1645 | if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) { |
| 1646 | - throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline); |
|
| 1646 | + throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]) . $commandline); |
|
| 1647 | 1647 | } |
| 1648 | 1648 | |
| 1649 | 1649 | return $this->escapeArgument($env[$matches[1]]); |
@@ -37,12 +37,12 @@ |
||
| 37 | 37 | |
| 38 | 38 | public function __sleep(): array |
| 39 | 39 | { |
| 40 | - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); |
|
| 40 | + throw new \BadMethodCallException('Cannot serialize ' . __CLASS__); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function __wakeup(): void |
| 44 | 44 | { |
| 45 | - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
|
| 45 | + throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function __destruct() |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | ]; |
| 51 | 51 | $tmpDir = sys_get_temp_dir(); |
| 52 | 52 | $lastError = 'unknown reason'; |
| 53 | - set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; }); |
|
| 54 | - for ($i = 0;; ++$i) { |
|
| 53 | + set_error_handler(function($type, $msg) use (&$lastError) { $lastError = $msg; }); |
|
| 54 | + for ($i = 0; ; ++$i) { |
|
| 55 | 55 | foreach ($pipes as $pipe => $name) { |
| 56 | 56 | $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name); |
| 57 | 57 | |
| 58 | - if (!$h = fopen($file.'.lock', 'w')) { |
|
| 59 | - if (file_exists($file.'.lock')) { |
|
| 58 | + if (!$h = fopen($file . '.lock', 'w')) { |
|
| 59 | + if (file_exists($file . '.lock')) { |
|
| 60 | 60 | continue 2; |
| 61 | 61 | } |
| 62 | 62 | restore_error_handler(); |
| 63 | - throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError); |
|
| 63 | + throw new RuntimeException('A temporary file could not be opened to write the process output: ' . $lastError); |
|
| 64 | 64 | } |
| 65 | 65 | if (!flock($h, \LOCK_EX | \LOCK_NB)) { |
| 66 | 66 | continue 2; |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | public function __sleep(): array |
| 92 | 92 | { |
| 93 | - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); |
|
| 93 | + throw new \BadMethodCallException('Cannot serialize ' . __CLASS__); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function __wakeup(): void |
| 97 | 97 | { |
| 98 | - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
|
| 98 | + throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function __destruct() |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | if (0x80 > $code %= 0x200000) { |
| 57 | 57 | $string .= \chr($code); |
| 58 | 58 | } elseif (0x800 > $code) { |
| 59 | - $string .= \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F); |
|
| 59 | + $string .= \chr(0xC0 | $code >> 6) . \chr(0x80 | $code & 0x3F); |
|
| 60 | 60 | } elseif (0x10000 > $code) { |
| 61 | - $string .= \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F); |
|
| 61 | + $string .= \chr(0xE0 | $code >> 12) . \chr(0x80 | $code >> 6 & 0x3F) . \chr(0x80 | $code & 0x3F); |
|
| 62 | 62 | } else { |
| 63 | - $string .= \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F); |
|
| 63 | + $string .= \chr(0xF0 | $code >> 18) . \chr(0x80 | $code >> 12 & 0x3F) . \chr(0x80 | $code >> 6 & 0x3F) . \chr(0x80 | $code & 0x3F); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } elseif (!\function_exists('iconv')) { |
| 136 | 136 | $s = preg_replace('/[^\x00-\x7F]/u', '?', $s); |
| 137 | 137 | } else { |
| 138 | - $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) { |
|
| 138 | + $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function($c) { |
|
| 139 | 139 | $c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]); |
| 140 | 140 | |
| 141 | 141 | if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | public function camel(): static |
| 156 | 156 | { |
| 157 | 157 | $str = clone $this; |
| 158 | - $str->string = str_replace(' ', '', preg_replace_callback('/\b.(?!\p{Lu})/u', static function ($m) { |
|
| 158 | + $str->string = str_replace(' ', '', preg_replace_callback('/\b.(?!\p{Lu})/u', static function($m) { |
|
| 159 | 159 | static $i = 0; |
| 160 | 160 | |
| 161 | 161 | return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8'); |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | $str = clone $this; |
| 204 | 204 | |
| 205 | - $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : ''; |
|
| 206 | - $str->string = implode($this->string, $strings).$tail; |
|
| 205 | + $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue . array_pop($strings) : ''; |
|
| 206 | + $str->string = implode($this->string, $strings) . $tail; |
|
| 207 | 207 | |
| 208 | 208 | if (!preg_match('//u', $str->string)) { |
| 209 | 209 | throw new InvalidArgumentException('Invalid UTF-8 string.'); |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m)); |
| 247 | 247 | |
| 248 | 248 | try { |
| 249 | - if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { |
|
| 250 | - throw new RuntimeException('Matching failed with error: '.preg_last_error_msg()); |
|
| 249 | + if (false === $match($regexp . 'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) { |
|
| 250 | + throw new RuntimeException('Matching failed with error: ' . preg_last_error_msg()); |
|
| 251 | 251 | } |
| 252 | 252 | } finally { |
| 253 | 253 | restore_error_handler(); |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | return $this->pad($length, $pad, \STR_PAD_LEFT); |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - public function replaceMatches(string $fromRegexp, string|callable $to): static |
|
| 307 | + public function replaceMatches(string $fromRegexp, string | callable $to): static |
|
| 308 | 308 | { |
| 309 | 309 | if ($this->ignoreCase) { |
| 310 | 310 | $fromRegexp .= 'i'; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | if (\is_array($to) || $to instanceof \Closure) { |
| 314 | 314 | $replace = 'preg_replace_callback'; |
| 315 | - $to = static function (array $m) use ($to): string { |
|
| 315 | + $to = static function(array $m) use ($to): string { |
|
| 316 | 316 | $to = $to($m); |
| 317 | 317 | |
| 318 | 318 | if ('' !== $to && (!\is_string($to) || !preg_match('//u', $to))) { |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m)); |
| 331 | 331 | |
| 332 | 332 | try { |
| 333 | - if (null === $string = $replace($fromRegexp.'u', $to, $this->string)) { |
|
| 333 | + if (null === $string = $replace($fromRegexp . 'u', $to, $this->string)) { |
|
| 334 | 334 | $lastError = preg_last_error(); |
| 335 | 335 | |
| 336 | 336 | foreach (get_defined_constants(true)['pcre'] as $k => $v) { |
| 337 | 337 | if ($lastError === $v && str_ends_with($k, '_ERROR')) { |
| 338 | - throw new RuntimeException('Matching failed with '.$k.'.'); |
|
| 338 | + throw new RuntimeException('Matching failed with ' . $k . '.'); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
@@ -541,22 +541,22 @@ discard block |
||
| 541 | 541 | |
| 542 | 542 | switch ($type) { |
| 543 | 543 | case \STR_PAD_RIGHT: |
| 544 | - return $this->append(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : '')); |
|
| 544 | + return $this->append(str_repeat($pad->string, intdiv($freeLen, $padLen)) . ($len ? $pad->slice(0, $len) : '')); |
|
| 545 | 545 | |
| 546 | 546 | case \STR_PAD_LEFT: |
| 547 | - return $this->prepend(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : '')); |
|
| 547 | + return $this->prepend(str_repeat($pad->string, intdiv($freeLen, $padLen)) . ($len ? $pad->slice(0, $len) : '')); |
|
| 548 | 548 | |
| 549 | 549 | case \STR_PAD_BOTH: |
| 550 | 550 | $freeLen /= 2; |
| 551 | 551 | |
| 552 | 552 | $rightLen = ceil($freeLen); |
| 553 | 553 | $len = $rightLen % $padLen; |
| 554 | - $str = $this->append(str_repeat($pad->string, intdiv($rightLen, $padLen)).($len ? $pad->slice(0, $len) : '')); |
|
| 554 | + $str = $this->append(str_repeat($pad->string, intdiv($rightLen, $padLen)) . ($len ? $pad->slice(0, $len) : '')); |
|
| 555 | 555 | |
| 556 | 556 | $leftLen = floor($freeLen); |
| 557 | 557 | $len = $leftLen % $padLen; |
| 558 | 558 | |
| 559 | - return $str->prepend(str_repeat($pad->string, intdiv($leftLen, $padLen)).($len ? $pad->slice(0, $len) : '')); |
|
| 559 | + return $str->prepend(str_repeat($pad->string, intdiv($leftLen, $padLen)) . ($len ? $pad->slice(0, $len) : '')); |
|
| 560 | 560 | |
| 561 | 561 | default: |
| 562 | 562 | throw new InvalidArgumentException('Invalid padding type.'); |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | return -1; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - self::$tableZero ??= require __DIR__.'/Resources/data/wcswidth_table_zero.php'; |
|
| 594 | + self::$tableZero ??= require __DIR__ . '/Resources/data/wcswidth_table_zero.php'; |
|
| 595 | 595 | |
| 596 | 596 | if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) { |
| 597 | 597 | $lbound = 0; |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - self::$tableWide ??= require __DIR__.'/Resources/data/wcswidth_table_wide.php'; |
|
| 611 | + self::$tableWide ??= require __DIR__ . '/Resources/data/wcswidth_table_wide.php'; |
|
| 612 | 612 | |
| 613 | 613 | if ($codePoint >= self::$tableWide[0][0] && $codePoint <= self::$tableWide[$ubound = \count(self::$tableWide) - 1][1]) { |
| 614 | 614 | $lbound = 0; |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | |
| 636 | 636 | private function getLocaleTransliterator(string $locale, string $id): ?\Transliterator |
| 637 | 637 | { |
| 638 | - $rule = $locale.'-'.$id; |
|
| 638 | + $rule = $locale . '-' . $id; |
|
| 639 | 639 | if (\array_key_exists($rule, self::$transliterators)) { |
| 640 | 640 | return self::$transliterators[$rule]; |
| 641 | 641 | } |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | return null; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - $parentRule = substr_replace($locale, '-'.$id, $i); |
|
| 652 | + $parentRule = substr_replace($locale, '-' . $id, $i); |
|
| 653 | 653 | |
| 654 | 654 | // Parent locale was already cached, return and store as current locale |
| 655 | 655 | if (\array_key_exists($parentRule, self::$transliterators)) { |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | 'zh' => 'Han-Latin', |
| 56 | 56 | ]; |
| 57 | 57 | |
| 58 | - private \Closure|array $symbolsMap = [ |
|
| 58 | + private \Closure | array $symbolsMap = [ |
|
| 59 | 59 | 'en' => ['@' => 'at', '&' => 'and'], |
| 60 | 60 | ]; |
| 61 | - private bool|string $emoji = false; |
|
| 61 | + private bool | string $emoji = false; |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Cache of transliterators per locale. |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | public function __construct( |
| 71 | 71 | private ?string $defaultLocale = null, |
| 72 | - array|\Closure|null $symbolsMap = null, |
|
| 72 | + array | \Closure | null $symbolsMap = null, |
|
| 73 | 73 | ) { |
| 74 | 74 | $this->symbolsMap = $symbolsMap ?? $this->symbolsMap; |
| 75 | 75 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * false will disable emoji, |
| 90 | 90 | * and a string to use a specific locale |
| 91 | 91 | */ |
| 92 | - public function withEmoji(bool|string $emoji = true): static |
|
| 92 | + public function withEmoji(bool | string $emoji = true): static |
|
| 93 | 93 | { |
| 94 | 94 | if (false !== $emoji && !class_exists(EmojiTransliterator::class)) { |
| 95 | 95 | throw new \LogicException(sprintf('You cannot use the "%s()" method as the "symfony/emoji" package is not installed. Try running "composer require symfony/emoji".', __METHOD__)); |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | if ($map) { |
| 140 | 140 | foreach ($map as $char => $replace) { |
| 141 | - $unicodeString = $unicodeString->replace($char, ' '.$replace.' '); |
|
| 141 | + $unicodeString = $unicodeString->replace($char, ' ' . $replace . ' '); |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | // Exact locale supported, cache and return |
| 159 | 159 | if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$locale] ?? null) { |
| 160 | - return $this->transliterators[$locale] = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id); |
|
| 160 | + return $this->transliterators[$locale] = \Transliterator::create($id . '/BGN') ?? \Transliterator::create($id); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Locale not supported and no parent, fallback to any-latin |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | // Try to use the parent locale (ie. try "de" for "de_AT") and cache both locales |
| 169 | 169 | if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$parent] ?? null) { |
| 170 | - $transliterator = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id); |
|
| 170 | + $transliterator = \Transliterator::create($id . '/BGN') ?? \Transliterator::create($id); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $this->transliterators[$locale] = $this->transliterators[$parent] = $transliterator ?? null; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | public function append(string ...$suffix): static |
| 49 | 49 | { |
| 50 | 50 | $str = clone $this; |
| 51 | - $str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix)); |
|
| 51 | + $str->string = $this->string . (1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix)); |
|
| 52 | 52 | |
| 53 | 53 | if (normalizer_is_normalized($str->string)) { |
| 54 | 54 | return $str; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $rx .= '\X{65535}'; |
| 79 | 79 | $length -= 65535; |
| 80 | 80 | } |
| 81 | - $rx .= '\X{'.$length.'})/u'; |
|
| 81 | + $rx .= '\X{' . $length . '})/u'; |
|
| 82 | 82 | |
| 83 | 83 | $str = clone $this; |
| 84 | 84 | $chunks = []; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | return $chunks; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function endsWith(string|iterable|AbstractString $suffix): bool |
|
| 94 | + public function endsWith(string | iterable | AbstractString $suffix): bool |
|
| 95 | 95 | { |
| 96 | 96 | if ($suffix instanceof AbstractString) { |
| 97 | 97 | $suffix = $suffix->string; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function equalsTo(string|iterable|AbstractString $string): bool |
|
| 116 | + public function equalsTo(string | iterable | AbstractString $string): bool |
|
| 117 | 117 | { |
| 118 | 118 | if ($string instanceof AbstractString) { |
| 119 | 119 | $string = $string->string; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | return $string === $this->string; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int |
|
| 134 | + public function indexOf(string | iterable | AbstractString $needle, int $offset = 0): ?int |
|
| 135 | 135 | { |
| 136 | 136 | if ($needle instanceof AbstractString) { |
| 137 | 137 | $needle = $needle->string; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | return false === $i ? null : $i; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int |
|
| 158 | + public function indexOfLast(string | iterable | AbstractString $needle, int $offset = 0): ?int |
|
| 159 | 159 | { |
| 160 | 160 | if ($needle instanceof AbstractString) { |
| 161 | 161 | $needle = $needle->string; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | public function prepend(string ...$prefix): static |
| 218 | 218 | { |
| 219 | 219 | $str = clone $this; |
| 220 | - $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string; |
|
| 220 | + $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)) . $this->string; |
|
| 221 | 221 | |
| 222 | 222 | if (normalizer_is_normalized($str->string)) { |
| 223 | 223 | return $str; |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | while ('' !== $tail && false !== $i = $indexOf($tail, $from)) { |
| 246 | 246 | $slice = grapheme_substr($tail, 0, $i); |
| 247 | - $result .= $slice.$to; |
|
| 247 | + $result .= $slice . $to; |
|
| 248 | 248 | $tail = substr($tail, \strlen($slice) + \strlen($from)); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $str->string = $result.$tail; |
|
| 251 | + $str->string = $result . $tail; |
|
| 252 | 252 | |
| 253 | 253 | if (normalizer_is_normalized($str->string)) { |
| 254 | 254 | return $str; |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | return $str; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - public function replaceMatches(string $fromRegexp, string|callable $to): static |
|
| 267 | + public function replaceMatches(string $fromRegexp, string | callable $to): static |
|
| 268 | 268 | { |
| 269 | 269 | $str = parent::replaceMatches($fromRegexp, $to); |
| 270 | 270 | normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | if (null !== $flags) { |
| 316 | - return parent::split($delimiter.'u', $limit, $flags); |
|
| 316 | + return parent::split($delimiter . 'u', $limit, $flags); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | normalizer_is_normalized($delimiter) ?: $delimiter = normalizer_normalize($delimiter); |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | return $chunks; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - public function startsWith(string|iterable|AbstractString $prefix): bool |
|
| 343 | + public function startsWith(string | iterable | AbstractString $prefix): bool |
|
| 344 | 344 | { |
| 345 | 345 | if ($prefix instanceof AbstractString) { |
| 346 | 346 | $prefix = $prefix->string; |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | public function __wakeup(): void |
| 366 | 366 | { |
| 367 | 367 | if (!\is_string($this->string)) { |
| 368 | - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
|
| 368 | + throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | if (null === $commandName) { |
| 64 | 64 | if (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag('container.private')) { |
| 65 | - $commandId = 'console.command.public_alias.'.$id; |
|
| 65 | + $commandId = 'console.command.public_alias.' . $id; |
|
| 66 | 66 | $container->setAlias($commandId, $id)->setPublic(true); |
| 67 | 67 | $id = $commandId; |
| 68 | 68 | } |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | if ($description) { |
| 114 | 114 | $definition->addMethodCall('setDescription', [$description]); |
| 115 | 115 | |
| 116 | - $container->register('.'.$id.'.lazy', LazyCommand::class) |
|
| 116 | + $container->register('.' . $id . '.lazy', LazyCommand::class) |
|
| 117 | 117 | ->setArguments([$commandName, $aliases, $description, $isHidden, new ServiceClosureArgument($lazyCommandRefs[$id])]); |
| 118 | 118 | |
| 119 | - $lazyCommandRefs[$id] = new Reference('.'.$id.'.lazy'); |
|
| 119 | + $lazyCommandRefs[$id] = new Reference('.' . $id . '.lazy'); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | public function getUri(): string |
| 34 | 34 | { |
| 35 | 35 | if ($this->server->has('SYMFONY_CLI_BINARY_NAME')) { |
| 36 | - $binary = $this->server->get('SYMFONY_CLI_BINARY_NAME').' console'; |
|
| 36 | + $binary = $this->server->get('SYMFONY_CLI_BINARY_NAME') . ' console'; |
|
| 37 | 37 | } else { |
| 38 | 38 | $binary = $this->server->get('argv')[0]; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return $binary.' '.$this->command->input; |
|
| 41 | + return $binary . ' ' . $this->command->input; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function getMethod(): string |
@@ -65,6 +65,6 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $application = $this->command->getApplication(); |
| 67 | 67 | |
| 68 | - return $application->getName().' '.$application->getVersion(); |
|
| 68 | + return $application->getName() . ' ' . $application->getVersion(); |
|
| 69 | 69 | } |
| 70 | 70 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null')); |
|
| 131 | + return self::$stty = (bool) shell_exec('stty 2> ' . ('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null')); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | private static function initDimensions(): void |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | return self::readFromProcess(['stty', '-a']); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - private static function readFromProcess(string|array $command): ?string |
|
| 199 | + private static function readFromProcess(string | array $command): ?string |
|
| 200 | 200 | { |
| 201 | 201 | if (!\function_exists('proc_open')) { |
| 202 | 202 | return null; |