|
17 | 17 | useSymfony\Component\Process\Exception\ProcessSignaledException; |
18 | 18 | useSymfony\Component\Process\Exception\ProcessTimedOutException; |
19 | 19 | useSymfony\Component\Process\Exception\RuntimeException; |
20 | | -useSymfony\Component\Process\Pipes\PipesInterface; |
21 | 20 | useSymfony\Component\Process\Pipes\UnixPipes; |
22 | 21 | useSymfony\Component\Process\Pipes\WindowsPipes; |
23 | 22 |
|
@@ -51,37 +50,35 @@ class Process implements \IteratorAggregate |
51 | 50 | publicconstITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating |
52 | 51 | publicconstITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating |
53 | 52 |
|
54 | | -private$callback; |
55 | | -private$hasCallback = false; |
56 | | -private$commandline; |
57 | | -private$cwd; |
58 | | -private$env = []; |
| 53 | +private ?\Closure$callback = null; |
| 54 | +privatearray|string$commandline; |
| 55 | +private ?string$cwd; |
| 56 | +privatearray$env = []; |
59 | 57 | private$input; |
60 | | -private$starttime; |
61 | | -private$lastOutputTime; |
62 | | -private$timeout; |
63 | | -private$idleTimeout; |
64 | | -private$exitcode; |
65 | | -private$fallbackStatus = []; |
66 | | -private$processInformation; |
67 | | -private$outputDisabled = false; |
| 58 | +private?float$starttime = null; |
| 59 | +private?float$lastOutputTime = null; |
| 60 | +private?float$timeout = null; |
| 61 | +private?float$idleTimeout = null; |
| 62 | +private?int$exitcode = null; |
| 63 | +privatearray$fallbackStatus = []; |
| 64 | +privatearray$processInformation; |
| 65 | +privatebool$outputDisabled = false; |
68 | 66 | private$stdout; |
69 | 67 | private$stderr; |
70 | 68 | private$process; |
71 | | -private$status = self::STATUS_READY; |
72 | | -private$incrementalOutputOffset = 0; |
73 | | -private$incrementalErrorOutputOffset = 0; |
74 | | -private$tty = false; |
75 | | -private$pty; |
76 | | -private$options = ['suppress_errors' => true, 'bypass_shell' => true]; |
| 69 | +privatestring$status = self::STATUS_READY; |
| 70 | +privateint$incrementalOutputOffset = 0; |
| 71 | +privateint$incrementalErrorOutputOffset = 0; |
| 72 | +privatebool$tty = false; |
| 73 | +privatebool$pty; |
| 74 | +privatearray$options = ['suppress_errors' => true, 'bypass_shell' => true]; |
77 | 75 |
|
78 | | -private$useFileHandles = false; |
79 | | -/** @var PipesInterface */ |
80 | | -private$processPipes; |
| 76 | +privatebool$useFileHandles; |
| 77 | +privateWindowsPipes|UnixPipes$processPipes; |
81 | 78 |
|
82 | | -private$latestSignal; |
| 79 | +private?int$latestSignal = null; |
83 | 80 |
|
84 | | -privatestatic$sigchild; |
| 81 | +privatestatic?bool$sigchild = null; |
85 | 82 |
|
86 | 83 | /** |
87 | 84 | * Exit codes translation table. |
@@ -303,7 +300,6 @@ public function start(callable $callback = null, array $env = []) |
303 | 300 | $this->resetProcessData(); |
304 | 301 | $this->starttime = $this->lastOutputTime = microtime(true); |
305 | 302 | $this->callback = $this->buildCallback($callback); |
306 | | -$this->hasCallback = null !== $callback; |
307 | 303 | $descriptors = $this->getDescriptors(); |
308 | 304 |
|
309 | 305 | if ($this->env) { |
@@ -1245,9 +1241,9 @@ private function getDescriptors(): array |
1245 | 1241 | $this->input->rewind(); |
1246 | 1242 | } |
1247 | 1243 | if ('\\' === \DIRECTORY_SEPARATOR) { |
1248 | | -$this->processPipes = newWindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback); |
| 1244 | +$this->processPipes = newWindowsPipes($this->input, !$this->outputDisabled || $this->callback); |
1249 | 1245 | } else { |
1250 | | -$this->processPipes = newUnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback); |
| 1246 | +$this->processPipes = newUnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->callback); |
1251 | 1247 | } |
1252 | 1248 |
|
1253 | 1249 | return$this->processPipes->getDescriptors(); |
@@ -1424,7 +1420,7 @@ private function resetProcessData(): void |
1424 | 1420 | $this->callback = null; |
1425 | 1421 | $this->exitcode = null; |
1426 | 1422 | $this->fallbackStatus = []; |
1427 | | -$this->processInformation = null; |
| 1423 | +$this->processInformation = []; |
1428 | 1424 | $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
1429 | 1425 | $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); |
1430 | 1426 | $this->process = null; |
|
0 commit comments