Skip to content

Commit cc5f606

Browse files
committed
minor symfony#10484 [Process] fix some typos and refactor some code (Tobion)
This PR was merged into the 2.3 branch. Discussion ---------- [Process] fix some typos and refactor some code | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT Commits ------- b422613 [Process] fix some typos and refactor some code
2 parents 1e9e8af + b422613 commit cc5f606

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class Process
5656
private $enhanceSigchildCompatibility;
5757
private $process;
5858
private $status = self::STATUS_READY;
59-
private $incrementalOutputOffset;
60-
private $incrementalErrorOutputOffset;
59+
private $incrementalOutputOffset = 0;
60+
private $incrementalErrorOutputOffset = 0;
6161
private $tty;
6262

6363
private $useFileHandles = false;
@@ -186,7 +186,8 @@ public function __clone()
186186
*
187187
* @return integer The exit status code
188188
*
189-
* @throws RuntimeException When process can't be launch or is stopped
189+
* @throws RuntimeException When process can't be launched
190+
* @throws RuntimeException When process stopped after receiving signal
190191
*
191192
* @api
192193
*/
@@ -215,7 +216,7 @@ public function run($callback = null)
215216
* @param callback|null $callback A PHP callback to run whenever there is some
216217
* output available on STDOUT or STDERR
217218
*
218-
* @throws RuntimeException When process can't be launch or is stopped
219+
* @throws RuntimeException When process can't be launched
219220
* @throws RuntimeException When process is already running
220221
*/
221222
public function start($callback = null)
@@ -270,7 +271,7 @@ public function start($callback = null)
270271
*
271272
* @return Process The new process
272273
*
273-
* @throws RuntimeException When process can't be launch or is stopped
274+
* @throws RuntimeException When process can't be launched
274275
* @throws RuntimeException When process is already running
275276
*
276277
* @see start()
@@ -355,6 +356,7 @@ public function getPid()
355356
* Sends a POSIX signal to the process.
356357
*
357358
* @param integer $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
359+
*
358360
* @return Process
359361
*
360362
* @throws LogicException In case the process is not running
@@ -511,7 +513,7 @@ public function isSuccessful()
511513
* @return Boolean
512514
*
513515
* @throws RuntimeException In case --enable-sigchild is activated
514-
* @throws LogicException In case the process is not terminated.
516+
* @throws LogicException In case the process is not terminated
515517
*
516518
* @api
517519
*/
@@ -536,7 +538,7 @@ public function hasBeenSignaled()
536538
* @return integer
537539
*
538540
* @throws RuntimeException In case --enable-sigchild is activated
539-
* @throws LogicException In case the process is not terminated.
541+
* @throws LogicException In case the process is not terminated
540542
*
541543
* @api
542544
*/
@@ -560,7 +562,7 @@ public function getTermSignal()
560562
*
561563
* @return Boolean
562564
*
563-
* @throws LogicException In case the process is not terminated.
565+
* @throws LogicException In case the process is not terminated
564566
*
565567
* @api
566568
*/
@@ -580,7 +582,7 @@ public function hasBeenStopped()
580582
*
581583
* @return integer
582584
*
583-
* @throws LogicException In case the process is not terminated.
585+
* @throws LogicException In case the process is not terminated
584586
*
585587
* @api
586588
*/
@@ -686,8 +688,6 @@ public function stop($timeout = 10, $signal = null)
686688
$this->close();
687689
}
688690

689-
$this->status = self::STATUS_TERMINATED;
690-
691691
return $this->exitcode;
692692
}
693693

@@ -1039,7 +1039,7 @@ protected function buildCallback($callback)
10391039
/**
10401040
* Updates the status of the process, reads pipes.
10411041
*
1042-
* @param Boolean $blocking Whether to use a clocking read call.
1042+
* @param Boolean $blocking Whether to use a blocking read call.
10431043
*/
10441044
protected function updateStatus($blocking)
10451045
{
@@ -1054,7 +1054,6 @@ protected function updateStatus($blocking)
10541054

10551055
if (!$this->processInformation['running']) {
10561056
$this->close();
1057-
$this->status = self::STATUS_TERMINATED;
10581057
}
10591058
}
10601059

@@ -1119,17 +1118,17 @@ private function captureExitCode()
11191118
*/
11201119
private function close()
11211120
{
1122-
$exitcode = -1;
1123-
11241121
$this->processPipes->close();
11251122
if (is_resource($this->process)) {
11261123
$exitcode = proc_close($this->process);
1124+
} else {
1125+
$exitcode = -1;
11271126
}
11281127

1129-
$this->exitcode = $this->exitcode !== null ? $this->exitcode : -1;
1130-
$this->exitcode = -1 != $exitcode ? $exitcode : $this->exitcode;
1128+
$this->exitcode = -1 !== $exitcode ? $exitcode : (null !== $this->exitcode ? $this->exitcode : -1);
1129+
$this->status = self::STATUS_TERMINATED;
11311130

1132-
if (-1 == $this->exitcode && null !== $this->fallbackExitcode) {
1131+
if (-1 === $this->exitcode && null !== $this->fallbackExitcode) {
11331132
$this->exitcode = $this->fallbackExitcode;
11341133
} elseif (-1 === $this->exitcode && $this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
11351134
// if process has been signaled, no exitcode but a valid termsig, apply Unix convention
@@ -1161,7 +1160,8 @@ private function resetProcessData()
11611160
* Sends a POSIX signal to the process.
11621161
*
11631162
* @param integer $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
1164-
* @param Boolean $throwException True to throw exception in case signal failed, false otherwise
1163+
* @param Boolean $throwException Whether to throw exception in case signal failed
1164+
*
11651165
* @return Boolean True if the signal was sent successfully, false otherwise
11661166
*
11671167
* @throws LogicException In case the process is not running

0 commit comments

Comments
 (0)