@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | if ($php = getenv('PHP_BINARY')) { |
37 | 37 | if (!is_executable($php)) { |
38 | 38 | $command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v --'; |
39 | - if (\function_exists('exec') && $php = strtok(exec($command.' '.escapeshellarg($php)), \PHP_EOL)) { |
|
39 | + if (\function_exists('exec') && $php = strtok(exec($command . ' ' . escapeshellarg($php)), \PHP_EOL)) { |
|
40 | 40 | if (!is_executable($php)) { |
41 | 41 | return false; |
42 | 42 | } |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | $args = $this->findArguments(); |
56 | - $args = $includeArgs && $args ? ' '.implode(' ', $args) : ''; |
|
56 | + $args = $includeArgs && $args ? ' ' . implode(' ', $args) : ''; |
|
57 | 57 | |
58 | 58 | // PHP_BINARY return the current sapi executable |
59 | 59 | if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) { |
60 | - return \PHP_BINARY.$args; |
|
60 | + return \PHP_BINARY . $args; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | if ($php = getenv('PHP_PATH')) { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) { |
|
77 | + if (@is_executable($php = \PHP_BINDIR . ('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) { |
|
78 | 78 | return $php; |
79 | 79 | } |
80 | 80 |
@@ -47,9 +47,9 @@ 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 $callback; |
55 | 55 | private $hasCallback = false; |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function __sleep() |
205 | 205 | { |
206 | - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); |
|
206 | + throw new \BadMethodCallException('Cannot serialize ' . __CLASS__); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | public function __wakeup() |
210 | 210 | { |
211 | - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); |
|
211 | + throw new \BadMethodCallException('Cannot unserialize ' . __CLASS__); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | public function __destruct() |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | |
319 | 319 | if ('\\' !== \DIRECTORY_SEPARATOR) { |
320 | 320 | // exec is mandatory to deal with sending a signal to the process |
321 | - $commandline = 'exec '.$commandline; |
|
321 | + $commandline = 'exec ' . $commandline; |
|
322 | 322 | } |
323 | 323 | } else { |
324 | 324 | $commandline = $this->replacePlaceholders($commandline, $env); |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $descriptors[3] = ['pipe', 'w']; |
332 | 332 | |
333 | 333 | // See https://unix.stackexchange.com/questions/71205/background-process-pipe-input |
334 | - $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; |
|
334 | + $commandline = '{ (' . $commandline . ') <&3 3<&- 3>/dev/null & } 3<&0;'; |
|
335 | 335 | $commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code'; |
336 | 336 | |
337 | 337 | // Workaround for the bug, when PTS functionality is enabled. |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $envPairs = []; |
343 | 343 | foreach ($env as $k => $v) { |
344 | 344 | if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) { |
345 | - $envPairs[] = $k.'='.$v; |
|
345 | + $envPairs[] = $k . '=' . $v; |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
@@ -1314,14 +1314,14 @@ discard block |
||
1314 | 1314 | protected function buildCallback(?callable $callback = null) |
1315 | 1315 | { |
1316 | 1316 | if ($this->outputDisabled) { |
1317 | - return function ($type, $data) use ($callback): bool { |
|
1317 | + return function($type, $data) use ($callback): bool { |
|
1318 | 1318 | return null !== $callback && $callback($type, $data); |
1319 | 1319 | }; |
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | $out = self::OUT; |
1323 | 1323 | |
1324 | - return function ($type, $data) use ($callback, $out): bool { |
|
1324 | + return function($type, $data) use ($callback, $out): bool { |
|
1325 | 1325 | if ($out == $type) { |
1326 | 1326 | $this->addOutput($data); |
1327 | 1327 | } else { |
@@ -1491,8 +1491,8 @@ discard block |
||
1491 | 1491 | $this->exitcode = null; |
1492 | 1492 | $this->fallbackStatus = []; |
1493 | 1493 | $this->processInformation = null; |
1494 | - $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
|
1495 | - $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
|
1494 | + $this->stdout = fopen('php://temp/maxmemory:' . (1024 * 1024), 'w+'); |
|
1495 | + $this->stderr = fopen('php://temp/maxmemory:' . (1024 * 1024), 'w+'); |
|
1496 | 1496 | $this->process = null; |
1497 | 1497 | $this->latestSignal = null; |
1498 | 1498 | $this->status = self::STATUS_READY; |
@@ -1567,7 +1567,7 @@ discard block |
||
1567 | 1567 | [^"%!^]*+ |
1568 | 1568 | )++ |
1569 | 1569 | ) | [^"]*+ )"/x', |
1570 | - function ($m) use (&$env, &$varCache, &$varCount, $uid) { |
|
1570 | + function($m) use (&$env, &$varCache, &$varCount, $uid) { |
|
1571 | 1571 | if (!isset($m[1])) { |
1572 | 1572 | return $m[0]; |
1573 | 1573 | } |
@@ -1578,23 +1578,23 @@ discard block |
||
1578 | 1578 | $value = str_replace("\0", '?', $value); |
1579 | 1579 | } |
1580 | 1580 | if (false === strpbrk($value, "\"%!\n")) { |
1581 | - return '"'.$value.'"'; |
|
1581 | + return '"' . $value . '"'; |
|
1582 | 1582 | } |
1583 | 1583 | |
1584 | 1584 | $value = str_replace(['!LF!', '"^!"', '"^%"', '"^^"', '""'], ["\n", '!', '%', '^', '"'], $value); |
1585 | - $value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"'; |
|
1586 | - $var = $uid.++$varCount; |
|
1585 | + $value = '"' . preg_replace('/(\\\\*)"/', '$1$1\\"', $value) . '"'; |
|
1586 | + $var = $uid . ++$varCount; |
|
1587 | 1587 | |
1588 | 1588 | $env[$var] = $value; |
1589 | 1589 | |
1590 | - return $varCache[$m[0]] = '!'.$var.'!'; |
|
1590 | + return $varCache[$m[0]] = '!' . $var . '!'; |
|
1591 | 1591 | }, |
1592 | 1592 | $cmd |
1593 | 1593 | ); |
1594 | 1594 | |
1595 | - $cmd = 'cmd /V:ON /E:ON /D /C ('.str_replace("\n", ' ', $cmd).')'; |
|
1595 | + $cmd = 'cmd /V:ON /E:ON /D /C (' . str_replace("\n", ' ', $cmd) . ')'; |
|
1596 | 1596 | foreach ($this->processPipes->getFiles() as $offset => $filename) { |
1597 | - $cmd .= ' '.$offset.'>"'.$filename.'"'; |
|
1597 | + $cmd .= ' ' . $offset . '>"' . $filename . '"'; |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | return $cmd; |
@@ -1633,7 +1633,7 @@ discard block |
||
1633 | 1633 | return '""'; |
1634 | 1634 | } |
1635 | 1635 | if ('\\' !== \DIRECTORY_SEPARATOR) { |
1636 | - return "'".str_replace("'", "'\\''", $argument)."'"; |
|
1636 | + return "'" . str_replace("'", "'\\''", $argument) . "'"; |
|
1637 | 1637 | } |
1638 | 1638 | if (str_contains($argument, "\0")) { |
1639 | 1639 | $argument = str_replace("\0", '?', $argument); |
@@ -1643,14 +1643,14 @@ discard block |
||
1643 | 1643 | } |
1644 | 1644 | $argument = preg_replace('/(\\\\+)$/', '$1$1', $argument); |
1645 | 1645 | |
1646 | - return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"'; |
|
1646 | + return '"' . str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument) . '"'; |
|
1647 | 1647 | } |
1648 | 1648 | |
1649 | 1649 | private function replacePlaceholders(string $commandline, array $env) |
1650 | 1650 | { |
1651 | - return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) { |
|
1651 | + return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function($matches) use ($commandline, $env) { |
|
1652 | 1652 | if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) { |
1653 | - throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline); |
|
1653 | + throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]) . $commandline); |
|
1654 | 1654 | } |
1655 | 1655 | |
1656 | 1656 | 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(), |
@@ -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() |
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() |
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() |
@@ -40,7 +40,7 @@ |
||
40 | 40 | public ?string $key = null, |
41 | 41 | public ?string $type = null, |
42 | 42 | public bool $nullable = false, |
43 | - array|object $attributes = [], |
|
43 | + array | object $attributes = [], |
|
44 | 44 | ) { |
45 | 45 | $this->attributes = \is_array($attributes) ? $attributes : [$attributes]; |
46 | 46 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | { |
55 | 55 | $i = 0; |
56 | 56 | $locator = $this->getServiceLocator([ |
57 | - 'foo' => function () use (&$i) { |
|
57 | + 'foo' => function() use (&$i) { |
|
58 | 58 | ++$i; |
59 | 59 | |
60 | 60 | return 'bar'; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function testThrowsOnUndefinedInternalService() |
70 | 70 | { |
71 | 71 | $locator = $this->getServiceLocator([ |
72 | - 'foo' => function () use (&$locator) { return $locator->get('bar'); }, |
|
72 | + 'foo' => function() use (&$locator) { return $locator->get('bar'); }, |
|
73 | 73 | ]); |
74 | 74 | |
75 | 75 | if (!$this->getExpectedException()) { |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | public function testThrowsOnCircularReference() |
84 | 84 | { |
85 | 85 | $locator = $this->getServiceLocator([ |
86 | - 'foo' => function () use (&$locator) { return $locator->get('bar'); }, |
|
87 | - 'bar' => function () use (&$locator) { return $locator->get('baz'); }, |
|
88 | - 'baz' => function () use (&$locator) { return $locator->get('bar'); }, |
|
86 | + 'foo' => function() use (&$locator) { return $locator->get('bar'); }, |
|
87 | + 'bar' => function() use (&$locator) { return $locator->get('baz'); }, |
|
88 | + 'baz' => function() use (&$locator) { return $locator->get('bar'); }, |
|
89 | 89 | ]); |
90 | 90 | |
91 | 91 | $this->expectException(ContainerExceptionInterface::class); |
@@ -76,7 +76,7 @@ |
||
76 | 76 | } else { |
77 | 77 | $type = (new \ReflectionFunction($factory))->getReturnType(); |
78 | 78 | |
79 | - $this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').($type instanceof \ReflectionNamedType ? $type->getName() : $type) : '?'; |
|
79 | + $this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '') . ($type instanceof \ReflectionNamedType ? $type->getName() : $type) : '?'; |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -51,14 +51,14 @@ |
||
51 | 51 | |
52 | 52 | /* @var SubscribedService $attribute */ |
53 | 53 | $attribute = $attribute->newInstance(); |
54 | - $attribute->key ??= self::class.'::'.$method->name; |
|
54 | + $attribute->key ??= self::class . '::' . $method->name; |
|
55 | 55 | $attribute->type ??= $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType; |
56 | 56 | $attribute->nullable = $returnType->allowsNull(); |
57 | 57 | |
58 | 58 | if ($attribute->attributes) { |
59 | 59 | $services[] = $attribute; |
60 | 60 | } else { |
61 | - $services[$attribute->key] = ($attribute->nullable ? '?' : '').$attribute->type; |
|
61 | + $services[$attribute->key] = ($attribute->nullable ? '?' : '') . $attribute->type; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 |