|
17 | 17 | use Symfony\Component\Process\Exception\ProcessSignaledException; |
18 | 18 | use Symfony\Component\Process\Exception\ProcessTimedOutException; |
19 | 19 | use Symfony\Component\Process\Exception\RuntimeException; |
20 | | -use Symfony\Component\Process\Pipes\PipesInterface; |
21 | 20 | use Symfony\Component\Process\Pipes\UnixPipes; |
22 | 21 | use Symfony\Component\Process\Pipes\WindowsPipes; |
23 | 22 |
|
@@ -51,37 +50,35 @@ class Process implements \IteratorAggregate |
51 | 50 | public const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating |
52 | 51 | public const ITER_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 | + private array|string $commandline; |
| 55 | + private ?string $cwd; |
| 56 | + private array $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 | + private array $fallbackStatus = []; |
| 64 | + private array $processInformation; |
| 65 | + private bool $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 | + private string $status = self::STATUS_READY; |
| 70 | + private int $incrementalOutputOffset = 0; |
| 71 | + private int $incrementalErrorOutputOffset = 0; |
| 72 | + private bool $tty = false; |
| 73 | + private bool $pty; |
| 74 | + private array $options = ['suppress_errors' => true, 'bypass_shell' => true]; |
77 | 75 |
|
78 | | - private $useFileHandles = false; |
79 | | - /** @var PipesInterface */ |
80 | | - private $processPipes; |
| 76 | + private bool $useFileHandles; |
| 77 | + private WindowsPipes|UnixPipes $processPipes; |
81 | 78 |
|
82 | | - private $latestSignal; |
| 79 | + private ?int $latestSignal = null; |
83 | 80 |
|
84 | | - private static $sigchild; |
| 81 | + private static ?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 = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback); |
| 1244 | + $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->callback); |
1249 | 1245 | } else { |
1250 | | - $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback); |
| 1246 | + $this->processPipes = new UnixPipes($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