Skip to content

[12.x] add type declarations for Console Events #53947

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

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Illuminate/Console/Events/ArtisanStarting.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Illuminate\Console\Events;

use Illuminate\Console\Application;

class ArtisanStarting
{
/**
Expand All @@ -11,7 +13,7 @@ class ArtisanStarting
* @return void
*/
public function __construct(
public $artisan,
public Application $artisan,
) {
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Events/CommandFinished.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class CommandFinished
* @return void
*/
public function __construct(
public $command,
public string $command,
public InputInterface $input,
public OutputInterface $output,
public $exitCode,
public int $exitCode,
) {
}
}
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Events/CommandStarting.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CommandStarting
* @return void
*/
public function __construct(
public $command,
public string $command,
public InputInterface $input,
public OutputInterface $output,
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Events/ScheduledTaskFinished.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ScheduledTaskFinished
*/
public function __construct(
public Event $task,
public $runtime,
public float $runtime,
) {
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ public function rerouteSymfonyCommandEvents()

$this->symfonyDispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
$this->events->dispatch(
new CommandStarting($event->getCommand()->getName(), $event->getInput(), $event->getOutput())
new CommandStarting($event->getCommand()?->getName() ?? '', $event->getInput(), $event->getOutput())
);
});

$this->symfonyDispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) {
$this->events->dispatch(
new CommandFinished($event->getCommand()->getName(), $event->getInput(), $event->getOutput(), $event->getExitCode())
new CommandFinished($event->getCommand()?->getName() ?? '', $event->getInput(), $event->getOutput(), $event->getExitCode())
);
});
}
Expand Down