diff --git a/src/Console/ParallelCommand.php b/src/Console/ParallelCommand.php index b7335ac..3009e8f 100644 --- a/src/Console/ParallelCommand.php +++ b/src/Console/ParallelCommand.php @@ -11,6 +11,7 @@ use Illuminate\Queue\SerializesAndRestoresModelIdentifiers; use Illuminate\Support\Facades\Auth; use Recca0120\LaravelParallel\ResponseIdentifier; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -18,6 +19,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpFoundation\Response; +#[AsCommand(self::COMMAND_NAME)] class ParallelCommand extends Command { use MakesHttpRequests; @@ -35,7 +37,7 @@ class ParallelCommand extends Command */ protected $app; - public function __construct(Application $app = null) + public function __construct(?Application $app = null) { parent::__construct(); $this->setLaravel($app); @@ -44,7 +46,7 @@ public function __construct(Application $app = null) /** * @return $this */ - public function setLaravel(Application $app = null): self + public function setLaravel(?Application $app = null): self { $this->app = $app; diff --git a/src/ParallelArtisan.php b/src/ParallelArtisan.php index fca1ca3..d74a1a0 100644 --- a/src/ParallelArtisan.php +++ b/src/ParallelArtisan.php @@ -35,7 +35,7 @@ class ParallelArtisan */ private $process; - public function __construct(Request $request = null, array $env = []) + public function __construct(?Request $request = null, array $env = []) { $this->request = $request ?? Request::capture(); $this->setEnv($env); @@ -90,14 +90,14 @@ private function parseParameters(array $parameters): array $params = []; foreach ($parameters as $param => $val) { - if ($param && is_string($param) && '-' === $param[0]) { - $glue = ('-' === $param[1]) ? '=' : ' '; + if ($param && is_string($param) && $param[0] === '-') { + $glue = ($param[1] === '-') ? '=' : ' '; if (is_array($val)) { foreach ($val as $v) { - $params[] = $param.('' !== $v ? $glue.$v : ''); + $params[] = $param.($v !== '' ? $glue.$v : ''); } } else { - $params[] = $param.('' !== $val ? $glue.$val : ''); + $params[] = $param.($val !== '' ? $glue.$val : ''); } } else { $params[] = is_array($val) ? implode(' ', $val) : $val; diff --git a/src/ParallelRequest.php b/src/ParallelRequest.php index ffe859c..9c28af4 100644 --- a/src/ParallelRequest.php +++ b/src/ParallelRequest.php @@ -12,8 +12,8 @@ class ParallelRequest { - use MakesHttpRequests; use InteractsWithAuthentication; + use MakesHttpRequests; /** * @var Request|null @@ -23,7 +23,7 @@ class ParallelRequest /** * AsyncRequest constructor. */ - public function __construct(Request $request = null) + public function __construct(?Request $request = null) { $this->request = $request ?? Request::capture(); } @@ -36,7 +36,7 @@ public static function setBinary(string $binary): void /** * @return $this */ - public static function create(Request $request = null): self + public static function create(?Request $request = null): self { return new static($request); } diff --git a/src/ResponseIdentifier.php b/src/ResponseIdentifier.php index 0a4c41b..8602882 100644 --- a/src/ResponseIdentifier.php +++ b/src/ResponseIdentifier.php @@ -79,7 +79,7 @@ public function toResponse(): Response * * @license https://github.com/guzzle/psr7/blob/2.4.0/LICENSE * - * @param string $message HTTP request or response to parse. + * @param string $message HTTP request or response to parse. */ private static function parseMessage(string $message): array { diff --git a/src/Tests/Concerns/WithParallelPhyiscalDatabase.php b/src/Tests/Concerns/WithParallelPhyiscalDatabase.php index d90bc2b..5bfac43 100644 --- a/src/Tests/Concerns/WithParallelPhyiscalDatabase.php +++ b/src/Tests/Concerns/WithParallelPhyiscalDatabase.php @@ -74,9 +74,6 @@ protected function refreshParallelPhyiscalDatabase(): void } } - /** - * @return void - */ private function bindParallelRequest(): void { $this->app->bind(ParallelRequest::class, function () { diff --git a/tests/Fixtures/artisan b/tests/Fixtures/artisan index 9bf9421..7d3f094 100644 --- a/tests/Fixtures/artisan +++ b/tests/Fixtures/artisan @@ -9,6 +9,7 @@ use Orchestra\Testbench\Concerns\HandlesRoutes; use Recca0120\LaravelParallel\Console\ParallelCommand; use Recca0120\LaravelParallel\Tests\Fixtures\SetupDatabase; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -118,6 +119,7 @@ $laravel = new class() { } }; +#[AsCommand('echo')] class EchoCommand extends Command { protected static $defaultName = 'echo';