Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
Fix Psysh command execution (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Dec 29, 2021
1 parent eb3e246 commit cc48781
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Command/PsyshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@

namespace Fidry\PsyshBundle\Command;

use Psy\Output\ShellOutput;
use Psy\Shell;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand All @@ -22,9 +26,9 @@
*/
final class PsyshCommand extends Command
{
private Application $psysh;
private Shell $psysh;

public function __construct(Application $psysh)
public function __construct(Shell $psysh)
{
parent::__construct();

Expand All @@ -38,6 +42,19 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
// Reset input & output if they are the default ones used. Indeed
// We call Psysh Application here which will do the necessary
// bootstrapping.
// If we don't we would force the regular Symfony Application
// bootstrapping instead not allowing the Psysh one to kick in at all.
if ($input instanceof ArgvInput) {
$input = null;
}

if ($output instanceof ConsoleOutput) {
$output = null;
}

return $this->psysh->run($input, $output);
}
}

0 comments on commit cc48781

Please sign in to comment.