@@ -215,7 +215,7 @@ |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($int < -128 || $int > 255) { |
218 | - return (string) $int; |
|
218 | + return (string)$int; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | if ($int < 0) { |
@@ -12,7 +12,7 @@ |
||
12 | 12 | use Symfony\Polyfill\Ctype as p; |
13 | 13 | |
14 | 14 | if (\PHP_VERSION_ID >= 80000) { |
15 | - return require __DIR__.'/bootstrap80.php'; |
|
15 | + return require __DIR__ . '/bootstrap80.php'; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | if (!function_exists('ctype_alnum')) { |
@@ -75,7 +75,7 @@ |
||
75 | 75 | } |
76 | 76 | foreach ($suffixes as $suffix) { |
77 | 77 | foreach ($dirs as $dir) { |
78 | - if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) { |
|
78 | + if (@is_file($file = $dir . \DIRECTORY_SEPARATOR . $name . $suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) { |
|
79 | 79 | return $file; |
80 | 80 | } |
81 | 81 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | public const TIMEOUT_PRECISION = 0.2; |
46 | 46 | |
47 | 47 | public const ITER_NON_BLOCKING = 1; // By default, iterating over outputs is a blocking call, use this flag to make it non-blocking |
48 | - public const ITER_KEEP_OUTPUT = 2; // By default, outputs are cleared while iterating, use this flag to keep them in memory |
|
49 | - public const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating |
|
50 | - public const ITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating |
|
48 | + public const ITER_KEEP_OUTPUT = 2; // By default, outputs are cleared while iterating, use this flag to keep them in memory |
|
49 | + public const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating |
|
50 | + public const ITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating |
|
51 | 51 | |
52 | 52 | private $callback; |
53 | 53 | private $hasCallback = false; |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | |
198 | 198 | public function __sleep() |
199 | 199 | { |
200 | - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); |
|
200 | + throw new \BadMethodCallException('Cannot serialize ' . __CLASS__); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | public function __wakeup() |
204 | 204 | { |
205 | - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
|
205 | + throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | public function __destruct() |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | if ('\\' !== \DIRECTORY_SEPARATOR) { |
314 | 314 | // exec is mandatory to deal with sending a signal to the process |
315 | - $commandline = 'exec '.$commandline; |
|
315 | + $commandline = 'exec ' . $commandline; |
|
316 | 316 | } |
317 | 317 | } else { |
318 | 318 | $commandline = $this->replacePlaceholders($commandline, $env); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $descriptors[3] = ['pipe', 'w']; |
326 | 326 | |
327 | 327 | // See https://unix.stackexchange.com/questions/71205/background-process-pipe-input |
328 | - $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; |
|
328 | + $commandline = '{ (' . $commandline . ') <&3 3<&- 3>/dev/null & } 3<&0;'; |
|
329 | 329 | $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code'; |
330 | 330 | |
331 | 331 | // Workaround for the bug, when PTS functionality is enabled. |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $envPairs = []; |
337 | 337 | foreach ($env as $k => $v) { |
338 | 338 | if (false !== $v) { |
339 | - $envPairs[] = $k.'='.$v; |
|
339 | + $envPairs[] = $k . '=' . $v; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $this->status = self::STATUS_STARTED; |
353 | 353 | |
354 | 354 | if (isset($descriptors[3])) { |
355 | - $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]); |
|
355 | + $this->fallbackStatus['pid'] = (int)fgets($this->processPipes->pipes[3]); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | if ($this->tty) { |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | if (3 !== $type) { |
472 | 472 | $ready = $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data) || $ready; |
473 | 473 | } elseif (!isset($this->fallbackStatus['signaled'])) { |
474 | - $this->fallbackStatus['exitcode'] = (int) $data; |
|
474 | + $this->fallbackStatus['exitcode'] = (int)$data; |
|
475 | 475 | } |
476 | 476 | } |
477 | 477 | if ($ready) { |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | public function setEnv(array $env) |
1153 | 1153 | { |
1154 | 1154 | // Process can not handle env values that are arrays |
1155 | - $env = array_filter($env, function ($value) { |
|
1155 | + $env = array_filter($env, function($value) { |
|
1156 | 1156 | return !\is_array($value); |
1157 | 1157 | }); |
1158 | 1158 | |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | static $isTtySupported; |
1267 | 1267 | |
1268 | 1268 | if (null === $isTtySupported) { |
1269 | - $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes); |
|
1269 | + $isTtySupported = (bool)@proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes); |
|
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | return $isTtySupported; |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | return $result = false; |
1290 | 1290 | } |
1291 | 1291 | |
1292 | - return $result = (bool) @proc_open('echo 1 >/dev/null', [['pty'], ['pty'], ['pty']], $pipes); |
|
1292 | + return $result = (bool)@proc_open('echo 1 >/dev/null', [['pty'], ['pty'], ['pty']], $pipes); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | /** |
@@ -1322,14 +1322,14 @@ discard block |
||
1322 | 1322 | protected function buildCallback(callable $callback = null) |
1323 | 1323 | { |
1324 | 1324 | if ($this->outputDisabled) { |
1325 | - return function ($type, $data) use ($callback): bool { |
|
1325 | + return function($type, $data) use ($callback): bool { |
|
1326 | 1326 | return null !== $callback && $callback($type, $data); |
1327 | 1327 | }; |
1328 | 1328 | } |
1329 | 1329 | |
1330 | 1330 | $out = self::OUT; |
1331 | 1331 | |
1332 | - return function ($type, $data) use ($callback, $out): bool { |
|
1332 | + return function($type, $data) use ($callback, $out): bool { |
|
1333 | 1333 | if ($out == $type) { |
1334 | 1334 | $this->addOutput($data); |
1335 | 1335 | } else { |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | */ |
1413 | 1413 | private function validateTimeout(?float $timeout): ?float |
1414 | 1414 | { |
1415 | - $timeout = (float) $timeout; |
|
1415 | + $timeout = (float)$timeout; |
|
1416 | 1416 | |
1417 | 1417 | if (0.0 === $timeout) { |
1418 | 1418 | $timeout = null; |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | if (3 !== $type) { |
1439 | 1439 | $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data); |
1440 | 1440 | } elseif (!isset($this->fallbackStatus['signaled'])) { |
1441 | - $this->fallbackStatus['exitcode'] = (int) $data; |
|
1441 | + $this->fallbackStatus['exitcode'] = (int)$data; |
|
1442 | 1442 | } |
1443 | 1443 | } |
1444 | 1444 | } |
@@ -1485,8 +1485,8 @@ discard block |
||
1485 | 1485 | $this->exitcode = null; |
1486 | 1486 | $this->fallbackStatus = []; |
1487 | 1487 | $this->processInformation = null; |
1488 | - $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
|
1489 | - $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
|
1488 | + $this->stdout = fopen('php://temp/maxmemory:' . (1024 * 1024), 'w+'); |
|
1489 | + $this->stderr = fopen('php://temp/maxmemory:' . (1024 * 1024), 'w+'); |
|
1490 | 1490 | $this->process = null; |
1491 | 1491 | $this->latestSignal = null; |
1492 | 1492 | $this->status = self::STATUS_READY; |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | [^"%!^]*+ |
1564 | 1564 | )++ |
1565 | 1565 | ) | [^"]*+ )"/x', |
1566 | - function ($m) use (&$env, &$varCache, &$varCount, $uid) { |
|
1566 | + function($m) use (&$env, &$varCache, &$varCount, $uid) { |
|
1567 | 1567 | if (!isset($m[1])) { |
1568 | 1568 | return $m[0]; |
1569 | 1569 | } |
@@ -1574,23 +1574,23 @@ discard block |
||
1574 | 1574 | $value = str_replace("\0", '?', $value); |
1575 | 1575 | } |
1576 | 1576 | if (false === strpbrk($value, "\"%!\n")) { |
1577 | - return '"'.$value.'"'; |
|
1577 | + return '"' . $value . '"'; |
|
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | $value = str_replace(['!LF!', '"^!"', '"^%"', '"^^"', '""'], ["\n", '!', '%', '^', '"'], $value); |
1581 | - $value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"'; |
|
1582 | - $var = $uid.++$varCount; |
|
1581 | + $value = '"' . preg_replace('/(\\\\*)"/', '$1$1\\"', $value) . '"'; |
|
1582 | + $var = $uid . ++$varCount; |
|
1583 | 1583 | |
1584 | 1584 | $env[$var] = $value; |
1585 | 1585 | |
1586 | - return $varCache[$m[0]] = '!'.$var.'!'; |
|
1586 | + return $varCache[$m[0]] = '!' . $var . '!'; |
|
1587 | 1587 | }, |
1588 | 1588 | $cmd |
1589 | 1589 | ); |
1590 | 1590 | |
1591 | - $cmd = 'cmd /V:ON /E:ON /D /C ('.str_replace("\n", ' ', $cmd).')'; |
|
1591 | + $cmd = 'cmd /V:ON /E:ON /D /C (' . str_replace("\n", ' ', $cmd) . ')'; |
|
1592 | 1592 | foreach ($this->processPipes->getFiles() as $offset => $filename) { |
1593 | - $cmd .= ' '.$offset.'>"'.$filename.'"'; |
|
1593 | + $cmd .= ' ' . $offset . '>"' . $filename . '"'; |
|
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | return $cmd; |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | return '""'; |
1630 | 1630 | } |
1631 | 1631 | if ('\\' !== \DIRECTORY_SEPARATOR) { |
1632 | - return "'".str_replace("'", "'\\''", $argument)."'"; |
|
1632 | + return "'" . str_replace("'", "'\\''", $argument) . "'"; |
|
1633 | 1633 | } |
1634 | 1634 | if (false !== strpos($argument, "\0")) { |
1635 | 1635 | $argument = str_replace("\0", '?', $argument); |
@@ -1639,14 +1639,14 @@ discard block |
||
1639 | 1639 | } |
1640 | 1640 | $argument = preg_replace('/(\\\\+)$/', '$1$1', $argument); |
1641 | 1641 | |
1642 | - return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"'; |
|
1642 | + return '"' . str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument) . '"'; |
|
1643 | 1643 | } |
1644 | 1644 | |
1645 | 1645 | private function replacePlaceholders(string $commandline, array $env) |
1646 | 1646 | { |
1647 | - return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) { |
|
1647 | + return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function($matches) use ($commandline, $env) { |
|
1648 | 1648 | if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) { |
1649 | - throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline); |
|
1649 | + throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]) . $commandline); |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | return $this->escapeArgument($env[$matches[1]]); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | throw new InvalidArgumentException('Expected a failed process, but the given process was successful.'); |
29 | 29 | } |
30 | 30 | |
31 | - $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s", |
|
31 | + $error = sprintf('The command "%s" failed.' . "\n\nExit Code: %s(%s)\n\nWorking directory: %s", |
|
32 | 32 | $process->getCommandLine(), |
33 | 33 | $process->getExitCode(), |
34 | 34 | $process->getExitCodeText(), |
@@ -49,7 +49,7 @@ |
||
49 | 49 | return $input; |
50 | 50 | } |
51 | 51 | if (is_scalar($input)) { |
52 | - return (string) $input; |
|
52 | + return (string)$input; |
|
53 | 53 | } |
54 | 54 | if ($input instanceof Process) { |
55 | 55 | return $input->getIterator($input::ITER_SKIP_ERR); |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | |
38 | 38 | public function __sleep() |
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() |
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() |
@@ -158,6 +158,6 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function areOpen(): bool |
160 | 160 | { |
161 | - return (bool) $this->pipes; |
|
161 | + return (bool)$this->pipes; |
|
162 | 162 | } |
163 | 163 | } |
@@ -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() |
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() |
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() |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } elseif (\is_string($input)) { |
38 | 38 | $this->inputBuffer = $input; |
39 | 39 | } else { |
40 | - $this->inputBuffer = (string) $input; |
|
40 | + $this->inputBuffer = (string)$input; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | if (!is_scalar($input)) { |
106 | 106 | throw new InvalidArgumentException(sprintf('"%s" yielded a value of type "%s", but only scalars and stream resources are supported.', get_debug_type($this->input), get_debug_type($input))); |
107 | 107 | } |
108 | - $input = (string) $input; |
|
108 | + $input = (string)$input; |
|
109 | 109 | } |
110 | 110 | $this->inputBuffer = $input; |
111 | 111 | $this->input->next(); |