diff --git a/composer.json b/composer.json index 4cddbf17..eb394633 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ "php": "^8.0 || ^7.4", "ext-json": "*", "ext-tokenizer": "*", - "symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4", - "symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4", + "symfony/console": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4", + "symfony/var-dumper": "^7.0 || ^6.0 || ^5.0 || ^4.0 || ^3.4", "nikic/php-parser": "^4.0" }, "require-dev": { diff --git a/src/Command/BufferCommand.php b/src/Command/BufferCommand.php index 81d8ff91..8348aee6 100644 --- a/src/Command/BufferCommand.php +++ b/src/Command/BufferCommand.php @@ -50,7 +50,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $app = $this->getApplication(); if (!$app instanceof \Psy\Shell) { diff --git a/src/Command/ClearCommand.php b/src/Command/ClearCommand.php index baca9af0..42a66b0f 100644 --- a/src/Command/ClearCommand.php +++ b/src/Command/ClearCommand.php @@ -44,7 +44,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $output->write(\sprintf('%c[2J%c[0;0f', 27, 27)); diff --git a/src/Command/Command.php b/src/Command/Command.php index 09750884..0d18d2c6 100644 --- a/src/Command/Command.php +++ b/src/Command/Command.php @@ -30,13 +30,13 @@ abstract class Command extends BaseCommand * * @api */ - public function setApplication(Application $application = null) + public function setApplication(Application $application = null): void { if ($application !== null && !$application instanceof Shell) { throw new \InvalidArgumentException('PsySH Commands require an instance of Psy\Shell'); } - return parent::setApplication($application); + parent::setApplication($application); } /** diff --git a/src/Command/DocCommand.php b/src/Command/DocCommand.php index 2eb715fc..1650ccf6 100644 --- a/src/Command/DocCommand.php +++ b/src/Command/DocCommand.php @@ -62,7 +62,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $value = $input->getArgument('target'); if (ReflectionLanguageConstruct::isLanguageConstruct($value)) { diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index c3bc604d..88ddbe26 100644 --- a/src/Command/DumpCommand.php +++ b/src/Command/DumpCommand.php @@ -69,7 +69,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $depth = $input->getOption('depth'); $target = $this->resolveCode($input->getArgument('target')); diff --git a/src/Command/EditCommand.php b/src/Command/EditCommand.php index af2914d5..7612b3de 100644 --- a/src/Command/EditCommand.php +++ b/src/Command/EditCommand.php @@ -79,7 +79,7 @@ protected function configure() * @throws \InvalidArgumentException when both exec and no-exec flags are given or if a given variable is not found in the current context * @throws \UnexpectedValueException if file_get_contents on the edited file returns false instead of a string */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if ($input->getOption('exec') && $input->getOption('no-exec')) { diff --git a/src/Command/ExitCommand.php b/src/Command/ExitCommand.php index 01f72d9f..6552e288 100644 --- a/src/Command/ExitCommand.php +++ b/src/Command/ExitCommand.php @@ -47,7 +47,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { throw new BreakException('Goodbye'); } diff --git a/src/Command/HelpCommand.php b/src/Command/HelpCommand.php index 9443c550..13ea3483 100644 --- a/src/Command/HelpCommand.php +++ b/src/Command/HelpCommand.php @@ -55,7 +55,7 @@ public function setCommand(Command $command) * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { if ($this->command !== null) { // help for an individual command diff --git a/src/Command/HistoryCommand.php b/src/Command/HistoryCommand.php index 94306e40..cf5f29b9 100644 --- a/src/Command/HistoryCommand.php +++ b/src/Command/HistoryCommand.php @@ -93,7 +93,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->validateOnlyOne($input, ['show', 'head', 'tail']); $this->validateOnlyOne($input, ['save', 'replay', 'clear']); diff --git a/src/Command/ListCommand.php b/src/Command/ListCommand.php index 6910d903..1982aa4c 100644 --- a/src/Command/ListCommand.php +++ b/src/Command/ListCommand.php @@ -114,7 +114,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->validateInput($input); $this->initEnumerators(); diff --git a/src/Command/ParseCommand.php b/src/Command/ParseCommand.php index a62be67f..205cc362 100644 --- a/src/Command/ParseCommand.php +++ b/src/Command/ParseCommand.php @@ -119,7 +119,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $code = $input->getArgument('code'); $parserKind = $input->getOption('kind'); diff --git a/src/Command/PsyVersionCommand.php b/src/Command/PsyVersionCommand.php index 44e75283..959a9a78 100644 --- a/src/Command/PsyVersionCommand.php +++ b/src/Command/PsyVersionCommand.php @@ -34,7 +34,7 @@ protected function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $output->writeln($this->getApplication()->getVersion()); diff --git a/src/Command/ShowCommand.php b/src/Command/ShowCommand.php index d8a93c0c..4d721d72 100644 --- a/src/Command/ShowCommand.php +++ b/src/Command/ShowCommand.php @@ -64,7 +64,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { // n.b. As far as I can tell, InputInterface doesn't want to tell me // whether an option with an optional value was actually passed. If you diff --git a/src/Command/SudoCommand.php b/src/Command/SudoCommand.php index b398bd89..bd08d14b 100644 --- a/src/Command/SudoCommand.php +++ b/src/Command/SudoCommand.php @@ -96,7 +96,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $code = $input->getArgument('code'); diff --git a/src/Command/ThrowUpCommand.php b/src/Command/ThrowUpCommand.php index 5653b81e..bb5bf5dd 100644 --- a/src/Command/ThrowUpCommand.php +++ b/src/Command/ThrowUpCommand.php @@ -75,7 +75,7 @@ protected function configure() * * @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)); diff --git a/src/Command/TimeitCommand.php b/src/Command/TimeitCommand.php index 3236bf01..3a2efee1 100644 --- a/src/Command/TimeitCommand.php +++ b/src/Command/TimeitCommand.php @@ -78,7 +78,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $code = $input->getArgument('code'); $num = (int) ($input->getOption('num') ?: 1); diff --git a/src/Command/TraceCommand.php b/src/Command/TraceCommand.php index 8ba1ad86..411237e1 100644 --- a/src/Command/TraceCommand.php +++ b/src/Command/TraceCommand.php @@ -71,7 +71,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->filter->bind($input); $trace = $this->getBacktrace(new \Exception(), $input->getOption('num'), $input->getOption('include-psy')); diff --git a/src/Command/WhereamiCommand.php b/src/Command/WhereamiCommand.php index 2b0280ea..b7d569be 100644 --- a/src/Command/WhereamiCommand.php +++ b/src/Command/WhereamiCommand.php @@ -109,7 +109,7 @@ protected function fileInfo(): array * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $info = $this->fileInfo(); $num = $input->getOption('num'); diff --git a/src/Command/WtfCommand.php b/src/Command/WtfCommand.php index 3d967fc5..6e2472c0 100644 --- a/src/Command/WtfCommand.php +++ b/src/Command/WtfCommand.php @@ -84,7 +84,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->filter->bind($input); diff --git a/src/Input/ShellInput.php b/src/Input/ShellInput.php index a185c6fd..9b8bf81d 100644 --- a/src/Input/ShellInput.php +++ b/src/Input/ShellInput.php @@ -47,7 +47,7 @@ public function __construct(string $input) * * @throws \InvalidArgumentException if $definition has CodeArgument before the final argument position */ - public function bind(InputDefinition $definition) + public function bind(InputDefinition $definition): void { $hasCodeArgument = false; @@ -68,7 +68,7 @@ public function bind(InputDefinition $definition) $this->hasCodeArgument = $hasCodeArgument; - return parent::bind($definition); + parent::bind($definition); } /** @@ -121,7 +121,7 @@ private function tokenize(string $input): array /** * Same as parent, but with some bonus handling for code arguments. */ - protected function parse() + protected function parse(): void { $parseOptions = true; $this->parsed = $this->tokenPairs; diff --git a/src/Output/ProcOutputPager.php b/src/Output/ProcOutputPager.php index aeaff368..42e40db5 100644 --- a/src/Output/ProcOutputPager.php +++ b/src/Output/ProcOutputPager.php @@ -48,7 +48,7 @@ public function __construct(StreamOutput $output, string $cmd = 'less -R -F -X') * * @throws \RuntimeException When unable to write output (should never happen) */ - public function doWrite($message, $newline) + public function doWrite($message, $newline): void { $pipe = $this->getPipe(); if (false === @\fwrite($pipe, $message.($newline ? \PHP_EOL : ''))) { diff --git a/src/Output/ShellOutput.php b/src/Output/ShellOutput.php index 543baccb..2ef575dc 100644 --- a/src/Output/ShellOutput.php +++ b/src/Output/ShellOutput.php @@ -119,7 +119,7 @@ public function stopPaging() * @param bool $newline Whether to add a newline or not * @param int $type The type of output */ - public function write($messages, $newline = false, $type = 0) + public function write($messages, $newline = false, $type = 0): void { if ($this->getVerbosity() === self::VERBOSITY_QUIET) { return; @@ -154,7 +154,7 @@ public function write($messages, $newline = false, $type = 0) * @param string $message A message to write to the output * @param bool $newline Whether to add a newline or not */ - public function doWrite($message, $newline) + public function doWrite($message, $newline): void { if ($this->paging > 0) { $this->pager->doWrite($message, $newline); diff --git a/src/Shell.php b/src/Shell.php index f3cfde9b..ad5dc2a2 100644 --- a/src/Shell.php +++ b/src/Shell.php @@ -436,7 +436,7 @@ private function doNonInteractiveRun(bool $rawOutput): int /** * Configures the input and output instances based on the user arguments and options. */ - protected function configureIO(InputInterface $input, OutputInterface $output) + protected function configureIO(InputInterface $input, OutputInterface $output): void { // @todo overrides via environment variables (or should these happen in config? ... probably config) $input->setInteractive($this->config->getInputInteractive()); diff --git a/src/VarDumper/Dumper.php b/src/VarDumper/Dumper.php index 0eacbc93..def61d4a 100644 --- a/src/VarDumper/Dumper.php +++ b/src/VarDumper/Dumper.php @@ -23,9 +23,9 @@ class Dumper extends CliDumper private $formatter; private $forceArrayIndexes; - const ONLY_CONTROL_CHARS = '/^[\x00-\x1F\x7F]+$/'; - const CONTROL_CHARS = '/([\x00-\x1F\x7F]+)/'; - const CONTROL_CHARS_MAP = [ + private const ONLY_CONTROL_CHARS = '/^[\x00-\x1F\x7F]+$/'; + private const CONTROL_CHARS = '/([\x00-\x1F\x7F]+)/'; + private const CONTROL_CHARS_MAP = [ "\0" => '\0', "\t" => '\t', "\n" => '\n', @@ -46,7 +46,7 @@ public function __construct(OutputFormatter $formatter, $forceArrayIndexes = fal /** * {@inheritdoc} */ - public function enterHash(Cursor $cursor, $type, $class, $hasChild) + public function enterHash(Cursor $cursor, $type, $class, $hasChild): void { if (Cursor::HASH_INDEXED === $type || Cursor::HASH_ASSOC === $type) { $class = 0; @@ -57,7 +57,7 @@ public function enterHash(Cursor $cursor, $type, $class, $hasChild) /** * {@inheritdoc} */ - protected function dumpKey(Cursor $cursor) + protected function dumpKey(Cursor $cursor): void { if ($this->forceArrayIndexes || Cursor::HASH_INDEXED !== $cursor->hashType) { parent::dumpKey($cursor); @@ -97,7 +97,7 @@ protected function style($style, $value, $attr = []): string /** * {@inheritdoc} */ - protected function dumpLine($depth, $endOfValue = false) + protected function dumpLine($depth, $endOfValue = false): void { if ($endOfValue && 0 < $depth) { $this->line .= ',';