Skip to content

Commit

Permalink
Update return types for Symfony 7 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobthecow committed Oct 13, 2023
1 parent 7e24aa1 commit 91b803b
Show file tree
Hide file tree
Showing 25 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BufferCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
4 changes: 2 additions & 2 deletions src/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DocCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion src/Command/EditCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ExitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Command/HistoryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/ParseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/PsyVersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion src/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Command/SudoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion src/Command/ThrowUpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Command/TimeitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/TraceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion src/Command/WhereamiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Command/WtfCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/Input/ShellInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -68,7 +68,7 @@ public function bind(InputDefinition $definition)

$this->hasCodeArgument = $hasCodeArgument;

return parent::bind($definition);
parent::bind($definition);
}

/**
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Output/ProcOutputPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 : ''))) {
Expand Down
4 changes: 2 additions & 2 deletions src/Output/ShellOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions src/VarDumper/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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 .= ',';
Expand Down

0 comments on commit 91b803b

Please sign in to comment.