Skip to content

Commit

Permalink
Refactor ProcessRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 27, 2024
1 parent 85b4d8d commit 8489340
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/Deployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
use Deployer\Component\PharUpdate\Console\Command as PharUpdateCommand;
use Deployer\Component\PharUpdate\Console\Helper as PharUpdateHelper;
use Deployer\Component\Pimple\Container;
use Deployer\Component\ProcessRunner\Printer;
use Deployer\Component\ProcessRunner\ProcessRunner;
use Deployer\ProcessRunner\Printer;
use Deployer\ProcessRunner\ProcessRunner;
use Deployer\Ssh\SshClient;
use Deployer\Configuration\Configuration;
use Deployer\Executor\Master;
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Deployer\Logger;

use Deployer\Component\ProcessRunner\Printer;
use Deployer\ProcessRunner\Printer;
use Deployer\Host\Host;
use Deployer\Logger\Handler\HandlerInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
* file that was distributed with this source code.
*/

namespace Deployer\Component\ProcessRunner;
namespace Deployer\ProcessRunner;

use Deployer\Host\Host;
use Symfony\Component\Console\Output\OutputInterface;

class Printer
{
/**
* @var OutputInterface
*/
private $output;
private OutputInterface $output;

public function __construct(OutputInterface $output)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,28 @@
* file that was distributed with this source code.
*/

namespace Deployer\Component\ProcessRunner;
namespace Deployer\ProcessRunner;

use Deployer\Exception\RunException;
use Deployer\Exception\TimeoutException;
use Deployer\Host\Host;
use Deployer\Logger\Logger;
use Deployer\ProcessRunner\Printer;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
use Symfony\Component\Process\Process;

class ProcessRunner
{
/**
* @var Printer
*/
private $pop;
/**
* @var Logger
*/
private $logger;
private Printer $pop;
private Logger $logger;

public function __construct(Printer $pop, Logger $logger)
{
$this->pop = $pop;
$this->logger = $logger;
}

/**
* Runs a command, consider deployer global configs (timeout,...)
*
* @throws RunException
*/
public function run(Host $host, string $command, array $config = []): string
{
$defaults = [
Expand Down Expand Up @@ -82,7 +72,7 @@ public function run(Host $host, string $command, array $config = []): string
$process->getOutput(),
$process->getErrorOutput(),
);
} catch (ProcessTimedOutException $exception) { // @phpstan-ignore-line can be thrown but is absent from the phpdoc
} catch (ProcessTimedOutException $exception) {

Check failure on line 75 in src/ProcessRunner/ProcessRunner.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Symfony\Component\Process\Exception\ProcessTimedOutException is never thrown in the try block.
throw new TimeoutException(
$command,
$exception->getExceededTimeout(),
Expand Down
2 changes: 1 addition & 1 deletion src/Ssh/SshClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Deployer\Ssh;

use Deployer\Component\ProcessRunner\Printer;
use Deployer\ProcessRunner\Printer;
use Deployer\Exception\RunException;
use Deployer\Exception\TimeoutException;
use Deployer\Host\Host;
Expand Down
2 changes: 1 addition & 1 deletion src/Utility/Rsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Deployer\Utility;

use Deployer\Component\ProcessRunner\Printer;
use Deployer\ProcessRunner\Printer;
use Deployer\Exception\RunException;
use Deployer\Host\Host;
use Symfony\Component\Console\Helper\ProgressBar;
Expand Down

0 comments on commit 8489340

Please sign in to comment.