From b1ed3648390e22bebd9f29229cf68c3519c7c24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baptiste=20Clavi=C3=A9?= Date: Sat, 23 Nov 2019 11:17:08 +0100 Subject: [PATCH 1/3] Add compatibility layer for Symfony Console 5.0 --- composer.json | 2 +- src/Command/BufferCommand.php | 2 ++ src/Command/ClearCommand.php | 2 ++ src/Command/DocCommand.php | 2 ++ src/Command/DumpCommand.php | 2 ++ src/Command/EditCommand.php | 2 ++ src/Command/HelpCommand.php | 2 ++ src/Command/HistoryCommand.php | 4 +++- src/Command/ListCommand.php | 2 ++ src/Command/ParseCommand.php | 2 ++ src/Command/PsyVersionCommand.php | 2 ++ src/Command/ShowCommand.php | 13 ++++++++----- src/Command/SudoCommand.php | 2 ++ src/Command/ThrowUpCommand.php | 2 ++ src/Command/TimeitCommand.php | 2 ++ src/Command/TraceCommand.php | 2 ++ src/Command/WhereamiCommand.php | 5 +++-- src/Command/WtfCommand.php | 2 ++ src/Configuration.php | 4 ++-- src/Shell.php | 3 +-- 20 files changed, 46 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 4588ba60a..283e4eca3 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=5.4.0", "ext-json": "*", "ext-tokenizer": "*", - "symfony/console": "~2.3.10|^2.4.2|~3.0|~4.0", + "symfony/console": "~2.3.10|^2.4.2|~3.0|~4.0|~5.0", "symfony/var-dumper": "~2.7|~3.0|~4.0", "nikic/php-parser": "~1.3|~2.0|~3.0|~4.0", "dnoegel/php-xdg-base-dir": "0.1", diff --git a/src/Command/BufferCommand.php b/src/Command/BufferCommand.php index 83ba34a8a..169ea7a40 100644 --- a/src/Command/BufferCommand.php +++ b/src/Command/BufferCommand.php @@ -56,6 +56,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln($this->formatLines($buf), ShellOutput::NUMBER_LINES); } + + return 0; } /** diff --git a/src/Command/ClearCommand.php b/src/Command/ClearCommand.php index 6b12048a9..eb138576d 100644 --- a/src/Command/ClearCommand.php +++ b/src/Command/ClearCommand.php @@ -45,5 +45,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $output->write(\sprintf('%c[2J%c[0;0f', 27, 27)); + + return 0; } } diff --git a/src/Command/DocCommand.php b/src/Command/DocCommand.php index 913634a0a..605917ae5 100644 --- a/src/Command/DocCommand.php +++ b/src/Command/DocCommand.php @@ -82,6 +82,8 @@ protected function execute(InputInterface $input, OutputInterface $output) // Set some magic local variables $this->setCommandScopeVariables($reflector); + + return 0; } private function getManualDoc($reflector) diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index 9a8aad826..da7e9deee 100644 --- a/src/Command/DumpCommand.php +++ b/src/Command/DumpCommand.php @@ -76,6 +76,8 @@ protected function execute(InputInterface $input, OutputInterface $output) if (\is_object($target)) { $this->setCommandScopeVariables(new \ReflectionObject($target)); } + + return 0; } /** diff --git a/src/Command/EditCommand.php b/src/Command/EditCommand.php index 057141494..7bd2007de 100644 --- a/src/Command/EditCommand.php +++ b/src/Command/EditCommand.php @@ -104,6 +104,8 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($execute) { $this->getApplication()->addInput($editedContent); } + + return 0; } /** diff --git a/src/Command/HelpCommand.php b/src/Command/HelpCommand.php index 82ec3a835..8ad3e8275 100644 --- a/src/Command/HelpCommand.php +++ b/src/Command/HelpCommand.php @@ -94,5 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $output->stopPaging(); } + + return 0; } } diff --git a/src/Command/HistoryCommand.php b/src/Command/HistoryCommand.php index 23f6899e3..bd6d245c4 100644 --- a/src/Command/HistoryCommand.php +++ b/src/Command/HistoryCommand.php @@ -140,11 +140,13 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $type = $input->getOption('no-numbers') ? 0 : ShellOutput::NUMBER_LINES; if (!$highlighted) { - $type = $type | ShellOutput::OUTPUT_RAW; + $type = $type | OutputInterface::OUTPUT_RAW; } $output->page($highlighted ?: $history, $type); } + + return 0; } /** diff --git a/src/Command/ListCommand.php b/src/Command/ListCommand.php index 67f4e041e..fd938a126 100644 --- a/src/Command/ListCommand.php +++ b/src/Command/ListCommand.php @@ -142,6 +142,8 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($reflector !== null) { $this->setCommandScopeVariables($reflector); } + + return 0; } /** diff --git a/src/Command/ParseCommand.php b/src/Command/ParseCommand.php index 3f3286e8a..8de79736a 100644 --- a/src/Command/ParseCommand.php +++ b/src/Command/ParseCommand.php @@ -138,6 +138,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->page($this->presenter->present($nodes, $depth)); $this->context->setReturnValue($nodes); + + return 0; } /** diff --git a/src/Command/PsyVersionCommand.php b/src/Command/PsyVersionCommand.php index 7d0846c1b..737475b48 100644 --- a/src/Command/PsyVersionCommand.php +++ b/src/Command/PsyVersionCommand.php @@ -37,5 +37,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln($this->getApplication()->getVersion()); + + return 0; } } diff --git a/src/Command/ShowCommand.php b/src/Command/ShowCommand.php index 47d186548..c0934ab2c 100644 --- a/src/Command/ShowCommand.php +++ b/src/Command/ShowCommand.php @@ -18,7 +18,6 @@ use Psy\Formatter\CodeFormatter; use Psy\Formatter\SignatureFormatter; use Psy\Input\CodeArgument; -use Psy\Output\ShellOutput; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -99,11 +98,15 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new \InvalidArgumentException('Too many arguments (supply either "target" or "--ex")'); } - return $this->writeExceptionContext($input, $output); + $this->writeExceptionContext($input, $output); + + return 0; } if ($input->getArgument('target')) { - return $this->writeCodeContext($input, $output); + $this->writeCodeContext($input, $output); + + return 0; } throw new RuntimeException('Not enough arguments (missing: "target")'); @@ -117,7 +120,7 @@ private function writeCodeContext(InputInterface $input, OutputInterface $output $this->setCommandScopeVariables($reflector); try { - $output->page(CodeFormatter::format($reflector, $this->colorMode), ShellOutput::OUTPUT_RAW); + $output->page(CodeFormatter::format($reflector, $this->colorMode), OutputInterface::OUTPUT_RAW); } catch (RuntimeException $e) { $output->writeln(SignatureFormatter::format($reflector)); throw $e; @@ -216,7 +219,7 @@ private function writeTraceCodeSnippet(OutputInterface $output, array $trace, $i return; } - $output->write($this->getHighlighter()->getCodeSnippet($code, $line, 5, 5), ShellOutput::OUTPUT_RAW); + $output->write($this->getHighlighter()->getCodeSnippet($code, $line, 5, 5), false, OutputInterface::OUTPUT_RAW); } private function getHighlighter() diff --git a/src/Command/SudoCommand.php b/src/Command/SudoCommand.php index 9d5afbf04..95b2146a7 100644 --- a/src/Command/SudoCommand.php +++ b/src/Command/SudoCommand.php @@ -118,6 +118,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $sudoCode = $this->printer->prettyPrint($nodes); $shell = $this->getApplication(); $shell->addCode($sudoCode, !$shell->hasCode()); + + return 0; } /** diff --git a/src/Command/ThrowUpCommand.php b/src/Command/ThrowUpCommand.php index b37f7573c..201cd926d 100644 --- a/src/Command/ThrowUpCommand.php +++ b/src/Command/ThrowUpCommand.php @@ -105,6 +105,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $shell = $this->getApplication(); $shell->addCode($throwCode, !$shell->hasCode()); + + return 0; } /** diff --git a/src/Command/TimeitCommand.php b/src/Command/TimeitCommand.php index c59663131..2bbc26ca1 100644 --- a/src/Command/TimeitCommand.php +++ b/src/Command/TimeitCommand.php @@ -106,6 +106,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(\sprintf(self::AVG_RESULT_MSG, $total / $num, $median, $total)); } + + return 0; } /** diff --git a/src/Command/TraceCommand.php b/src/Command/TraceCommand.php index c28b0e728..b85a07f8f 100644 --- a/src/Command/TraceCommand.php +++ b/src/Command/TraceCommand.php @@ -74,6 +74,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->filter->bind($input); $trace = $this->getBacktrace(new \Exception(), $input->getOption('num'), $input->getOption('include-psy')); $output->page($trace, ShellOutput::NUMBER_LINES); + + return 0; } /** diff --git a/src/Command/WhereamiCommand.php b/src/Command/WhereamiCommand.php index 98593d13a..ccc451079 100644 --- a/src/Command/WhereamiCommand.php +++ b/src/Command/WhereamiCommand.php @@ -14,7 +14,6 @@ use JakubOnderka\PhpConsoleHighlighter\Highlighter; use Psy\Configuration; use Psy\ConsoleColorFactory; -use Psy\Output\ShellOutput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -123,8 +122,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(''); $output->writeln(\sprintf('From %s:%s:', $this->replaceCwd($info['file']), $info['line'])); $output->writeln(''); - $output->write($highlighter->getCodeSnippet($contents, $info['line'], $num, $num), ShellOutput::OUTPUT_RAW); + $output->write($highlighter->getCodeSnippet($contents, $info['line'], $num, $num), false, OutputInterface::OUTPUT_RAW); $output->stopPaging(); + + return 0; } /** diff --git a/src/Command/WtfCommand.php b/src/Command/WtfCommand.php index c6d53000e..a937af0ea 100644 --- a/src/Command/WtfCommand.php +++ b/src/Command/WtfCommand.php @@ -121,5 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } } while ($exception = $exception->getPrevious()); $output->stopPaging(); + + return 0; } } diff --git a/src/Configuration.php b/src/Configuration.php index 67c76e7b3..00ddbc173 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -19,13 +19,13 @@ use Psy\Readline\HoaConsole; use Psy\Readline\Libedit; use Psy\Readline\Readline; -use Psy\Readline\Transient; use Psy\TabCompletion\AutoCompleter; use Psy\VarDumper\Presenter; use Psy\VersionUpdater\Checker; use Psy\VersionUpdater\GitHubChecker; use Psy\VersionUpdater\IntervalChecker; use Psy\VersionUpdater\NoopChecker; +use Symfony\Component\Console\Output\OutputInterface; /** * The Psy Shell configuration. @@ -823,7 +823,7 @@ public function getOutput() { if (!isset($this->output)) { $this->output = new ShellOutput( - ShellOutput::VERBOSITY_NORMAL, + OutputInterface::VERBOSITY_NORMAL, $this->getOutputDecorated(), null, $this->getPager() diff --git a/src/Shell.php b/src/Shell.php index 7a0fbac28..7add42dc8 100644 --- a/src/Shell.php +++ b/src/Shell.php @@ -21,7 +21,6 @@ use Psy\ExecutionLoop\RunkitReloader; use Psy\Input\ShellInput; use Psy\Input\SilentInput; -use Psy\Output\ShellOutput; use Psy\TabCompletion\Matcher; use Psy\VarDumper\PresenterAware; use Symfony\Component\Console\Application; @@ -931,7 +930,7 @@ public function writeStdout($out, $phase = PHP_OUTPUT_HANDLER_END) // Incremental flush if ($out !== '' && !$isCleaning) { - $this->output->write($out, false, ShellOutput::OUTPUT_RAW); + $this->output->write($out, false, OutputInterface::OUTPUT_RAW); $this->outputWantsNewline = (\substr($out, -1) !== "\n"); $this->stdoutBuffer .= $out; } From 6402caeb00e7d64edf733fa9490f9147fc21cc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baptiste=20Clavi=C3=A9?= Date: Sat, 23 Nov 2019 11:29:10 +0100 Subject: [PATCH 2/3] Add compatibility layer for Symfony VarDumper 5.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 283e4eca3..1b20b5065 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "ext-json": "*", "ext-tokenizer": "*", "symfony/console": "~2.3.10|^2.4.2|~3.0|~4.0|~5.0", - "symfony/var-dumper": "~2.7|~3.0|~4.0", + "symfony/var-dumper": "~2.7|~3.0|~4.0|~5.0", "nikic/php-parser": "~1.3|~2.0|~3.0|~4.0", "dnoegel/php-xdg-base-dir": "0.1", "jakub-onderka/php-console-highlighter": "0.3.*|0.4.*" From 3c46dfc2ca7bacf3d0bf1d67481d00a6fea08d21 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Wed, 27 Nov 2019 11:51:07 -0800 Subject: [PATCH 3/3] Bump to v0.9.10 --- src/Shell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shell.php b/src/Shell.php index 7add42dc8..919f6eff4 100644 --- a/src/Shell.php +++ b/src/Shell.php @@ -46,7 +46,7 @@ */ class Shell extends Application { - const VERSION = 'v0.9.9'; + const VERSION = 'v0.9.10'; const PROMPT = '>>> '; const BUFF_PROMPT = '... ';