Skip to content

Commit

Permalink
Add missing return types
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Apr 28, 2023
1 parent 39cbf15 commit 89ac295
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Exception/ProcessFailedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function __construct(Process $process)
$this->process = $process;
}

/**
* @return Process
*/
public function getProcess()
{
return $this->process;
Expand Down
5 changes: 4 additions & 1 deletion Exception/ProcessTimedOutException.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function __construct(Process $process, int $timeoutType)
));
}

/**
* @return Process
*/
public function getProcess()
{
return $this->process;
Expand All @@ -59,7 +62,7 @@ public function isIdleTimeout()
return self::TYPE_IDLE === $this->timeoutType;
}

public function getExceededTimeout()
public function getExceededTimeout(): ?float
{
return match ($this->timeoutType) {
self::TYPE_GENERAL => $this->process->getTimeout(),
Expand Down
18 changes: 13 additions & 5 deletions Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ public function mustRun(callable $callback = null, array $env = []): static
* @param callable|null $callback A PHP callback to run whenever there is some
* output available on STDOUT or STDERR
*
* @return void
*
* @throws RuntimeException When process can't be launched
* @throws RuntimeException When process is already running
* @throws LogicException In case a callback is provided and output has been disabled
Expand Down Expand Up @@ -1140,6 +1142,8 @@ public function setInput(mixed $input): static
* In case you run a background process (with the start method), you should
* trigger this method regularly to ensure the process timeout
*
* @return void
*
* @throws ProcessTimedOutException In case the timeout was reached
*/
public function checkTimeout()
Expand Down Expand Up @@ -1180,6 +1184,8 @@ public function getStartTime(): float
*
* Enabling the "create_new_console" option allows a subprocess to continue
* to run after the main process exited, on both Windows and *nix
*
* @return void
*/
public function setOptions(array $options)
{
Expand Down Expand Up @@ -1275,6 +1281,8 @@ protected function buildCallback(callable $callback = null): \Closure
* Updates the status of the process, reads pipes.
*
* @param bool $blocking Whether to use a blocking read call
*
* @return void
*/
protected function updateStatus(bool $blocking)
{
Expand Down Expand Up @@ -1323,7 +1331,7 @@ protected function isSigchildEnabled(): bool
*
* @throws LogicException in case output has been disabled or process is not started
*/
private function readPipesForOutput(string $caller, bool $blocking = false)
private function readPipesForOutput(string $caller, bool $blocking = false): void
{
if ($this->outputDisabled) {
throw new LogicException('Output has been disabled.');
Expand Down Expand Up @@ -1358,7 +1366,7 @@ private function validateTimeout(?float $timeout): ?float
* @param bool $blocking Whether to use blocking calls or not
* @param bool $close Whether to close file handles or not
*/
private function readPipes(bool $blocking, bool $close)
private function readPipes(bool $blocking, bool $close): void
{
$result = $this->processPipes->readAndWrite($blocking, $close);

Expand Down Expand Up @@ -1407,7 +1415,7 @@ private function close(): int
/**
* Resets data related to the latest run of the process.
*/
private function resetProcessData()
private function resetProcessData(): void
{
$this->starttime = null;
$this->callback = null;
Expand Down Expand Up @@ -1528,7 +1536,7 @@ function ($m) use (&$env, $uid) {
*
* @throws LogicException if the process has not run
*/
private function requireProcessIsStarted(string $functionName)
private function requireProcessIsStarted(string $functionName): void
{
if (!$this->isStarted()) {
throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName));
Expand All @@ -1540,7 +1548,7 @@ private function requireProcessIsStarted(string $functionName)
*
* @throws LogicException if the process is not yet terminated
*/
private function requireProcessIsTerminated(string $functionName)
private function requireProcessIsTerminated(string $functionName): void
{
if (!$this->isTerminated()) {
throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName));
Expand Down

0 comments on commit 89ac295

Please sign in to comment.