From ee98bd57ed2680c8fb3ac9f86aa7598d0d6542b2 Mon Sep 17 00:00:00 2001 From: Kinane Date: Fri, 11 Dec 2020 21:54:45 +0200 Subject: [PATCH] Fix message handler generator for Laravel > v5.7 --- src/Console/Commands/QueueCommand.php | 3 ++- src/Console/Commands/SubscriberCommand.php | 3 ++- src/Generators/stubs/handler.stub | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Console/Commands/QueueCommand.php b/src/Console/Commands/QueueCommand.php index 944c2d9..bdb2f88 100644 --- a/src/Console/Commands/QueueCommand.php +++ b/src/Console/Commands/QueueCommand.php @@ -3,6 +3,7 @@ namespace Vinelab\Bowler\Console\Commands; use Exception; +use Illuminate\Support\Str; use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputArgument; use Vinelab\Bowler\Generators\HandlerGenerator; @@ -43,7 +44,7 @@ public function handle() $handlerGenerator = new HandlerGenerator(); $queue = $this->argument('queueName'); - $handler = studly_case(preg_replace('/Handler(\.php)?$/', '', $this->argument('handler')).'Handler'); + $handler = Str::studly(preg_replace('/Handler(\.php)?$/', '', $this->argument('handler')).'Handler'); try { $handlerGenerator->generate($queue, $handler, self::TYPE); diff --git a/src/Console/Commands/SubscriberCommand.php b/src/Console/Commands/SubscriberCommand.php index 13a27ef..d8fefab 100644 --- a/src/Console/Commands/SubscriberCommand.php +++ b/src/Console/Commands/SubscriberCommand.php @@ -3,6 +3,7 @@ namespace Vinelab\Bowler\Console\Commands; use Exception; +use Illuminate\Support\Str; use Illuminate\Console\Command; use Vinelab\Bowler\Generators\HandlerGenerator; @@ -43,7 +44,7 @@ public function handle() $queue = $queue.'-pub-sub'; } - $handler = studly_case(preg_replace('/Handler(\.php)?$/', '', $this->argument('handler')).'Handler'); + $handler = Str::studly(preg_replace('/Handler(\.php)?$/', '', $this->argument('handler')).'Handler'); try { $handlerGenerator->generate($queue, $handler, self::TYPE); diff --git a/src/Generators/stubs/handler.stub b/src/Generators/stubs/handler.stub index 9a3eeea..ab95e20 100644 --- a/src/Generators/stubs/handler.stub +++ b/src/Generators/stubs/handler.stub @@ -15,7 +15,7 @@ class {{handler}} * * @return void */ - public function handle($msg) + public function handle(AMQPMessage $msg) { // } @@ -23,7 +23,7 @@ class {{handler}} /** * Handle error * - * @param Exception $e + * @param Exception|Throwable $e * @param MessageBroker $broker * * @return void