Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add method return value #6565

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/async-queue/src/Command/FlushFailedMessageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(ContainerInterface $container)
parent::__construct('queue:flush');
}

public function handle()
public function handle(): void
{
$name = $this->input->getArgument('name');
$queue = $this->input->getOption('queue');
Expand All @@ -40,7 +40,7 @@ public function handle()
$this->output->writeln('<fg=red>Flush all message from failed queue.</>');
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Delete all message from failed queue.');
$this->addArgument('name', InputArgument::OPTIONAL, 'The name of queue.', 'default');
Expand Down
4 changes: 2 additions & 2 deletions src/async-queue/src/Command/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(ContainerInterface $container)
parent::__construct('queue:info');
}

public function handle()
public function handle(): void
{
$name = $this->input->getArgument('name');
$factory = $this->container->get(DriverFactory::class);
Expand All @@ -38,7 +38,7 @@ public function handle()
}
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Get all messages from the queue.');
$this->addArgument('name', InputArgument::OPTIONAL, 'The name of queue.', 'default');
Expand Down
4 changes: 2 additions & 2 deletions src/async-queue/src/Command/ReloadFailedMessageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(ContainerInterface $container)
parent::__construct('queue:reload');
}

public function handle()
public function handle(): void
{
$name = $this->input->getArgument('name');
$queue = $this->input->getOption('queue');
Expand All @@ -40,7 +40,7 @@ public function handle()
$this->output->writeln(sprintf('<fg=green>Reload %d failed message into waiting queue.</>', $num));
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Reload all failed message into waiting queue.');
$this->addArgument('name', InputArgument::OPTIONAL, 'The name of queue.', 'default');
Expand Down
4 changes: 2 additions & 2 deletions src/command/src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ protected function context(): array
/**
* Configure the console command using a fluent definition.
*/
protected function configureUsingFluentDefinition()
protected function configureUsingFluentDefinition(): void
{
[$name, $arguments, $options] = Parser::parse($this->signature);

Expand All @@ -156,7 +156,7 @@ protected function configureUsingFluentDefinition()
$this->getDefinition()->addOptions($options);
}

protected function configure()
protected function configure(): void
{
parent::configure();
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/src/Concerns/DisableEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function addDisableDispatcherOption(): void
$this->addOption('disable-event-dispatcher', null, InputOption::VALUE_NONE, 'Whether disable event dispatcher.');
}

public function disableDispatcher(InputInterface $input)
public function disableDispatcher(InputInterface $input): void
{
if (! $input->getOption('disable-event-dispatcher')) {
if (! ApplicationContext::hasContainer()) {
Expand Down
10 changes: 3 additions & 7 deletions src/command/src/Concerns/HasParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait HasParameters
/**
* Specify the arguments and options on the command.
*/
protected function specifyParameters()
protected function specifyParameters(): void
{
// We will loop through all of the arguments and options for the command and
// set them all on the base command instance. This specifies what can get
Expand All @@ -43,20 +43,16 @@ protected function specifyParameters()

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
protected function getArguments(): array
{
return [];
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
protected function getOptions(): array
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/src/Concerns/NullDisableEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function addDisableDispatcherOption(): void
{
}

public function disableDispatcher(InputInterface $input)
public function disableDispatcher(InputInterface $input): void
{
}
}
2 changes: 1 addition & 1 deletion src/command/src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Console
/**
* @var ClosureCommand[]
*/
protected static $commands = [];
protected static array $commands = [];

public static function command(string $signature, Closure $command): ClosureCommand
{
Expand Down
6 changes: 2 additions & 4 deletions src/database/src/Commands/Migrations/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(protected MigrationRepositoryInterface $repository)
/**
* Handle the current command.
*/
public function handle()
public function handle(): void
{
$this->repository->setSource($this->input->getOption('database'));

Expand All @@ -39,10 +39,8 @@ public function handle()

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
protected function getOptions(): array
{
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
Expand Down
4 changes: 1 addition & 3 deletions src/database/src/Commands/Migrations/RefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ protected function runSeeder(string $database): void

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
protected function getOptions(): array
{
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
Expand Down
4 changes: 1 addition & 3 deletions src/database/src/Commands/Migrations/ResetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ public function handle()

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
protected function getOptions(): array
{
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
Expand Down
4 changes: 1 addition & 3 deletions src/database/src/Commands/Migrations/RollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ public function handle()

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
protected function getOptions(): array
{
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
Expand Down
4 changes: 1 addition & 3 deletions src/database/src/Commands/Migrations/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ protected function getAllMigrationFiles()

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
protected function getOptions(): array
{
return [
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
Expand Down
10 changes: 5 additions & 5 deletions src/database/src/Commands/ModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function run(InputInterface $input, OutputInterface $output): int
return parent::run($input, $output);
}

public function handle()
public function handle(): void
{
$table = $this->input->getArgument('table');
$pool = $this->input->getOption('pool');
Expand All @@ -99,7 +99,7 @@ public function handle()
}
}

protected function configure()
protected function configure(): void
{
$this->addArgument('table', InputArgument::OPTIONAL, 'Which table you want to associated with the Model.');

Expand All @@ -124,7 +124,7 @@ protected function getSchemaBuilder(string $poolName): Builder
return $connection->getSchemaBuilder();
}

protected function createModels(ModelOption $option)
protected function createModels(ModelOption $option): void
{
$builder = $this->getSchemaBuilder($option->getPool());
$tables = [];
Expand All @@ -151,7 +151,7 @@ protected function isIgnoreTable(string $table, ModelOption $option): bool
return $table === $this->config->get('databases.migrations', 'migrations');
}

protected function createModel(string $table, ModelOption $option)
protected function createModel(string $table, ModelOption $option): void
{
$builder = $this->getSchemaBuilder($option->getPool());
$table = Str::replaceFirst($option->getPrefix(), '', $table);
Expand Down Expand Up @@ -196,7 +196,7 @@ protected function createModel(string $table, ModelOption $option)
}
}

protected function generateIDE(string $code, ModelOption $option, ModelData $data)
protected function generateIDE(string $code, ModelOption $option, ModelData $data): void
{
$stmts = $this->astParser->parse($code);
$traverser = new NodeTraverser();
Expand Down
4 changes: 1 addition & 3 deletions src/database/src/Commands/Seeders/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ public function handle()

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
protected function getOptions(): array
{
return [
['path', null, InputOption::VALUE_OPTIONAL, 'The location where the seeders file stored'],
Expand Down
4 changes: 2 additions & 2 deletions src/devtool/src/Describe/AspectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct()
parent::__construct('describe:aspects');
}

public function handle()
public function handle(): void
{
$classes = $this->input->getOption('classes');
$classes = $classes ? explode(',', $classes) : null;
Expand All @@ -39,7 +39,7 @@ public function handle()
$this->show('Annotations', $this->handleData($collector['annotations'], $classes, $aspects), $this->output);
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Describe the aspects.')
->addOption('classes', 'e', InputOption::VALUE_OPTIONAL, 'Get the detail of the specified information by classes.')
Expand Down
8 changes: 4 additions & 4 deletions src/devtool/src/Describe/ListenersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(private ContainerInterface $container)
parent::__construct('describe:listeners');
}

public function handle()
public function handle(): void
{
$events = $this->input->getOption('events');
$events = $events ? explode(',', $events) : null;
Expand All @@ -41,7 +41,7 @@ public function handle()
$this->show($this->handleData($provider, $events, $listeners), $this->output);
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Describe the events and listeners.')
->addOption('events', 'e', InputOption::VALUE_OPTIONAL, 'Get the detail of the specified information by events.')
Expand Down Expand Up @@ -80,7 +80,7 @@ protected function handleData(ListenerProviderInterface $provider, ?array $event
return $data;
}

protected function isMatch(string $target, array $keywords = [])
protected function isMatch(string $target, array $keywords = []): bool
{
foreach ($keywords as $keyword) {
if (str_contains($target, $keyword)) {
Expand All @@ -90,7 +90,7 @@ protected function isMatch(string $target, array $keywords = [])
return false;
}

protected function show(array $data, OutputInterface $output)
protected function show(array $data, OutputInterface $output): void
{
$rows = [];
foreach ($data as $route) {
Expand Down
10 changes: 5 additions & 5 deletions src/devtool/src/Describe/RoutesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(private ContainerInterface $container, private Confi
parent::__construct('describe:routes');
}

public function handle()
public function handle(): void
{
$path = $this->input->getOption('path');
$server = $this->input->getOption('server');
Expand All @@ -46,14 +46,14 @@ public function handle()
);
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Describe the routes information.')
->addOption('path', 'p', InputOption::VALUE_OPTIONAL, 'Get the detail of the specified route information by path')
->addOption('server', 'S', InputOption::VALUE_OPTIONAL, 'Which server you want to describe routes.', 'http');
}

protected function analyzeRouter(string $server, RouteCollector $router, ?string $path)
protected function analyzeRouter(string $server, RouteCollector $router, ?string $path): array
{
$data = [];
[$staticRouters, $variableRouters] = $router->getData();
Expand All @@ -74,7 +74,7 @@ protected function analyzeRouter(string $server, RouteCollector $router, ?string
return $data;
}

protected function analyzeHandler(array &$data, string $serverName, string $method, ?string $path, Handler $handler)
protected function analyzeHandler(array &$data, string $serverName, string $method, ?string $path, Handler $handler): void
{
$uri = $handler->route;
if (! is_null($path) && ! Str::contains($uri, $path)) {
Expand Down Expand Up @@ -108,7 +108,7 @@ protected function analyzeHandler(array &$data, string $serverName, string $meth
}
}

private function show(array $data, OutputInterface $output)
private function show(array $data, OutputInterface $output): void
{
$rows = [];
foreach ($data as $route) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(protected ContainerInterface $container)
parent::__construct('gen:migration-from-database');
}

public function configure()
public function configure(): void
{
parent::configure();
$this->setDescription('Generate migrations from an existing table structure');
Expand All @@ -46,7 +46,7 @@ public function configure()
$this->addOption('path', null, InputOption::VALUE_OPTIONAL, 'The path that you want the migration to be generated.', 'migrations');
}

public function handle()
public function handle(): void
{
$table = $this->input->getArgument('table');
$pool = $this->input->getOption('pool');
Expand Down
6 changes: 3 additions & 3 deletions src/phar/src/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(protected ContainerInterface $container)
parent::__construct('phar:build');
}

public function configure()
public function configure(): void
{
$this->setDescription('Pack your project into a Phar package.')
->addOption('name', '', InputOption::VALUE_OPTIONAL, 'This is the name of the Phar package, and if it is not passed in, the project name is used by default')
Expand All @@ -35,7 +35,7 @@ public function configure()
->addOption('mount', 'M', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The mount path or dir.');
}

public function handle()
public function handle(): void
{
$this->assertWritable();
$name = $this->input->getOption('name');
Expand Down Expand Up @@ -67,7 +67,7 @@ public function handle()
/**
* check readonly.
*/
public function assertWritable()
public function assertWritable(): void
{
if (ini_get('phar.readonly') === '1') {
throw new UnexpectedValueException('Your configuration disabled writing phar files (phar.readonly = On), please update your configuration');
Expand Down