From b4b4bf3685ca343adb034274ff0519535f5dcf2c Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Fri, 17 Feb 2023 21:36:04 +0000 Subject: [PATCH] style: plugin actions improvements --- bin/worker.php | 2 +- src/Kernel.php | 9 +++++---- src/Plugins/Actions/CallsAddsOutput.php | 2 +- src/Plugins/Actions/CallsBoot.php | 4 ++-- src/Plugins/Actions/CallsHandleArguments.php | 2 +- src/Plugins/Actions/CallsShutdown.php | 2 +- src/Plugins/Parallel.php | 3 ++- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/bin/worker.php b/bin/worker.php index 19aa4790..9fa983c7 100644 --- a/bin/worker.php +++ b/bin/worker.php @@ -69,7 +69,7 @@ $bootPest = (static function (): void { $bootPest(); - $phpunitArgv = (new CallsHandleArguments())($phpunitArgv); + $phpunitArgv = CallsHandleArguments::execute($phpunitArgv); $application = new ApplicationForWrapperWorker( $phpunitArgv, diff --git a/src/Kernel.php b/src/Kernel.php index f8c9b45b..e9740eb3 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -8,6 +8,7 @@ use Pest\Contracts\Bootstrapper; use Pest\Exceptions\NoDirtyTestsFound; use Pest\Plugins\Actions\CallsAddsOutput; use Pest\Plugins\Actions\CallsBoot; +use Pest\Plugins\Actions\CallsHandleArguments; use Pest\Plugins\Actions\CallsShutdown; use Pest\Support\Container; use PHPUnit\TextUI\Application; @@ -68,7 +69,7 @@ final class Kernel $bootstrapper->boot(); } - (new CallsBoot())->__invoke(); + CallsBoot::execute(); return new self( new Application(), @@ -83,7 +84,7 @@ final class Kernel */ public function handle(array $args): int { - $args = (new Plugins\Actions\CallsHandleArguments())->__invoke($args); + $args = CallsHandleArguments::execute($args); try { $this->application->run($args); @@ -95,7 +96,7 @@ final class Kernel ]); } - return (new CallsAddsOutput())->__invoke( + return CallsAddsOutput::execute( Result::exitCode(), ); } @@ -105,6 +106,6 @@ final class Kernel */ public function shutdown(): void { - (new CallsShutdown())->__invoke(); + CallsShutdown::execute(); } } diff --git a/src/Plugins/Actions/CallsAddsOutput.php b/src/Plugins/Actions/CallsAddsOutput.php index a8b59f50..695e23cc 100644 --- a/src/Plugins/Actions/CallsAddsOutput.php +++ b/src/Plugins/Actions/CallsAddsOutput.php @@ -17,7 +17,7 @@ final class CallsAddsOutput * * Provides an opportunity for any plugins that want to provide additional output after test execution. */ - public function __invoke(int $exitCode): int + public static function execute(int $exitCode): int { $plugins = Loader::getPlugins(Plugins\AddsOutput::class); diff --git a/src/Plugins/Actions/CallsBoot.php b/src/Plugins/Actions/CallsBoot.php index e498d945..f2459b80 100644 --- a/src/Plugins/Actions/CallsBoot.php +++ b/src/Plugins/Actions/CallsBoot.php @@ -15,9 +15,9 @@ final class CallsBoot /** * Executes the Plugin action. * - * Provides an opportunity for any plugins to boot.. + * Provides an opportunity for any plugins to boot. */ - public function __invoke(): void + public static function execute(): void { $plugins = Loader::getPlugins(Plugins\Bootable::class); diff --git a/src/Plugins/Actions/CallsHandleArguments.php b/src/Plugins/Actions/CallsHandleArguments.php index 5d7326a7..660620f9 100644 --- a/src/Plugins/Actions/CallsHandleArguments.php +++ b/src/Plugins/Actions/CallsHandleArguments.php @@ -20,7 +20,7 @@ final class CallsHandleArguments * @param array $argv * @return array */ - public function __invoke(array $argv): array + public static function execute(array $argv): array { $plugins = Loader::getPlugins(Plugins\HandlesArguments::class); diff --git a/src/Plugins/Actions/CallsShutdown.php b/src/Plugins/Actions/CallsShutdown.php index 4bbb7d8e..d694e2b8 100644 --- a/src/Plugins/Actions/CallsShutdown.php +++ b/src/Plugins/Actions/CallsShutdown.php @@ -17,7 +17,7 @@ final class CallsShutdown * * Provides an opportunity for any plugins to shutdown. */ - public function __invoke(): void + public static function execute(): void { $plugins = Loader::getPlugins(Plugins\Shutdownable::class); diff --git a/src/Plugins/Parallel.php b/src/Plugins/Parallel.php index b7f59137..92c2e1c5 100644 --- a/src/Plugins/Parallel.php +++ b/src/Plugins/Parallel.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Pest\Plugins; use ParaTest\ParaTestCommand; +use Pest\Contracts\Plugins\AddsOutput; use Pest\Contracts\Plugins\HandlesArguments; use Pest\Plugins\Actions\CallsAddsOutput; use Pest\Plugins\Concerns\HandleArguments; @@ -105,7 +106,7 @@ final class Parallel implements HandlesArguments $exitCode = $this->paratestCommand()->run(new ArgvInput($filteredArguments), new CleanConsoleOutput()); - return (new CallsAddsOutput())($exitCode); + return CallsAddsOutput::execute($exitCode); } /**