🔧
This commit is contained in:
25
vendor/psy/psysh/src/Command/ThrowUpCommand.php
vendored
25
vendor/psy/psysh/src/Command/ThrowUpCommand.php
vendored
@@ -13,13 +13,12 @@ namespace Psy\Command;
|
||||
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\Throw_;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Name\FullyQualified as FullyQualifiedName;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Throw_;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\PrettyPrinter\Standard as Printer;
|
||||
use Psy\Context;
|
||||
use Psy\ContextAware;
|
||||
use Psy\Exception\ThrowUpException;
|
||||
use Psy\Input\CodeArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@@ -28,7 +27,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
/**
|
||||
* Throw an exception or error out of the Psy Shell.
|
||||
*/
|
||||
class ThrowUpCommand extends Command implements ContextAware
|
||||
class ThrowUpCommand extends Command
|
||||
{
|
||||
private $parser;
|
||||
private $printer;
|
||||
@@ -44,16 +43,6 @@ class ThrowUpCommand extends Command implements ContextAware
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated throwUp no longer needs to be ContextAware
|
||||
*
|
||||
* @param Context $context
|
||||
*/
|
||||
public function setContext(Context $context)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -87,10 +76,10 @@ HELP
|
||||
*
|
||||
* @throws \InvalidArgumentException if there is no exception to throw
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$args = $this->prepareArgs($input->getArgument('exception'));
|
||||
$throwStmt = new Throw_(new New_(new FullyQualifiedName(ThrowUpException::class), $args));
|
||||
$throwStmt = new Expression(new Throw_(new New_(new FullyQualifiedName(ThrowUpException::class), $args)));
|
||||
$throwCode = $this->printer->prettyPrint([$throwStmt]);
|
||||
|
||||
$shell = $this->getApplication();
|
||||
@@ -123,9 +112,7 @@ HELP
|
||||
}
|
||||
|
||||
$node = $nodes[0];
|
||||
|
||||
// Make this work for PHP Parser v3.x
|
||||
$expr = isset($node->expr) ? $node->expr : $node;
|
||||
$expr = $node->expr;
|
||||
|
||||
$args = [new Arg($expr, false, false, $node->getAttributes())];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user