Skip to content

Commit

Permalink
minor #10484 [Process] fix some typos and refactor some code (Tobion)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fabpot committed Mar 19, 2014
2 parents 1e9e8af + b422613 commit cc5f606
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/Symfony/Component/Process/Process.php
Expand Up @@ -56,8 +56,8 @@ class Process
private $enhanceSigchildCompatibility;
private $process;
private $status = self::STATUS_READY;
private $incrementalOutputOffset;
private $incrementalErrorOutputOffset;
private $incrementalOutputOffset = 0;
private $incrementalErrorOutputOffset = 0;
private $tty;

private $useFileHandles = false;
Expand Down Expand Up @@ -186,7 +186,8 @@ public function __clone()
*
* @return integer The exit status code
*
* @throws RuntimeException When process can't be launch or is stopped
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process stopped after receiving signal
*
* @api
*/
Expand Down Expand Up @@ -215,7 +216,7 @@ public function run($callback = null)
* @param callback|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
*
* @throws RuntimeException When process can't be launch or is stopped
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running
*/
public function start($callback = null)
Expand Down Expand Up @@ -270,7 +271,7 @@ public function start($callback = null)
*
* @return Process The new process
*
* @throws RuntimeException When process can't be launch or is stopped
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running
*
* @see start()
Expand Down Expand Up @@ -355,6 +356,7 @@ public function getPid()
* Sends a POSIX signal to the process.
*
* @param integer $signal A valid POSIX signal (see http://www.php.net/manual/en/pcntl.constants.php)
*
* @return Process
*
* @throws LogicException In case the process is not running
Expand Down Expand Up @@ -511,7 +513,7 @@ public function isSuccessful()
* @return Boolean
*
* @throws RuntimeException In case --enable-sigchild is activated
* @throws LogicException In case the process is not terminated.
* @throws LogicException In case the process is not terminated
*
* @api
*/
Expand All @@ -536,7 +538,7 @@ public function hasBeenSignaled()
* @return integer
*
* @throws RuntimeException In case --enable-sigchild is activated
* @throws LogicException In case the process is not terminated.
* @throws LogicException In case the process is not terminated
*
* @api
*/
Expand All @@ -560,7 +562,7 @@ public function getTermSignal()
*
* @return Boolean
*
* @throws LogicException In case the process is not terminated.
* @throws LogicException In case the process is not terminated
*
* @api
*/
Expand All @@ -580,7 +582,7 @@ public function hasBeenStopped()
*
* @return integer
*
* @throws LogicException In case the process is not terminated.
* @throws LogicException In case the process is not terminated
*
* @api
*/
Expand Down Expand Up @@ -686,8 +688,6 @@ public function stop($timeout = 10, $signal = null)
$this->close();
}

$this->status = self::STATUS_TERMINATED;

return $this->exitcode;
}

Expand Down Expand Up @@ -1039,7 +1039,7 @@ protected function buildCallback($callback)
/**
* Updates the status of the process, reads pipes.
*
* @param Boolean $blocking Whether to use a clocking read call.
* @param Boolean $blocking Whether to use a blocking read call.
*/
protected function updateStatus($blocking)
{
Expand All @@ -1054,7 +1054,6 @@ protected function updateStatus($blocking)

if (!$this->processInformation['running']) {
$this->close();
$this->status = self::STATUS_TERMINATED;
}
}

Expand Down Expand Up @@ -1119,17 +1118,17 @@ private function captureExitCode()
*/
private function close()
{
$exitcode = -1;

$this->processPipes->close();
if (is_resource($this->process)) {
$exitcode = proc_close($this->process);
} else {
$exitcode = -1;
}

$this->exitcode = $this->exitcode !== null ? $this->exitcode : -1;
$this->exitcode = -1 != $exitcode ? $exitcode : $this->exitcode;
$this->exitcode = -1 !== $exitcode ? $exitcode : (null !== $this->exitcode ? $this->exitcode : -1);
$this->status = self::STATUS_TERMINATED;

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

0 comments on commit cc5f606

Please sign in to comment.