From 33fe9c86333d788520e597eda1862508e3f49354 Mon Sep 17 00:00:00 2001 From: spiralbot Date: Fri, 6 Sep 2024 09:01:52 +0000 Subject: [PATCH] Apply php8.0 in Rector preset (#1139) --- src/Attribute/Queueable.php | 5 +---- src/Interceptor/Push/Core.php | 2 +- src/JobHandler.php | 2 +- src/QueueableDetector.php | 5 +---- tests/Job/ObjectJobTest.php | 10 ++-------- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Attribute/Queueable.php b/src/Attribute/Queueable.php index 7dd7e3c..6d5f29b 100644 --- a/src/Attribute/Queueable.php +++ b/src/Attribute/Queueable.php @@ -20,10 +20,7 @@ #[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor] final class Queueable { - public ?string $queue = null; - - public function __construct(string $queue = null) + public function __construct(public ?string $queue = null) { - $this->queue = $queue; } } diff --git a/src/Interceptor/Push/Core.php b/src/Interceptor/Push/Core.php index dabab6b..23af455 100644 --- a/src/Interceptor/Push/Core.php +++ b/src/Interceptor/Push/Core.php @@ -72,7 +72,7 @@ private function getTracer(): TracerInterface { try { return ContainerScope::getContainer()->get(TracerInterface::class); - } catch (\Throwable $e) { + } catch (\Throwable) { return new NullTracer(); } } diff --git a/src/JobHandler.php b/src/JobHandler.php index a89bced..6540a4f 100644 --- a/src/JobHandler.php +++ b/src/JobHandler.php @@ -34,7 +34,7 @@ public function handle(string $name, string $id, mixed $payload, array $headers $this->invoker->invoke([$this, $this->getHandlerMethod()], $params); } catch (\Throwable $e) { - $message = \sprintf('[%s] %s', $this::class, $e->getMessage()); + $message = \sprintf('[%s] %s', static::class, $e->getMessage()); throw new JobException($message, (int)$e->getCode(), $e); } } diff --git a/src/QueueableDetector.php b/src/QueueableDetector.php index 52a3b60..a35cc5b 100644 --- a/src/QueueableDetector.php +++ b/src/QueueableDetector.php @@ -9,11 +9,8 @@ final class QueueableDetector { - private ReaderInterface $reader; - - public function __construct(ReaderInterface $reader) + public function __construct(private ReaderInterface $reader) { - $this->reader = $reader; } /** diff --git a/tests/Job/ObjectJobTest.php b/tests/Job/ObjectJobTest.php index 956d092..5dbcc6f 100644 --- a/tests/Job/ObjectJobTest.php +++ b/tests/Job/ObjectJobTest.php @@ -42,11 +42,8 @@ public function testPayloadObjectValueShouldBeObject(): void public function testHandleWithHandleMethod(): void { $object = new class($this) { - private $testCase; - - public function __construct($testCase) + public function __construct(private $testCase) { - $this->testCase = $testCase; } public function handle(string $name, string $id, ContainerInterface $container): void @@ -65,11 +62,8 @@ public function handle(string $name, string $id, ContainerInterface $container): public function testHandleWithInvokeMethod(): void { $object = new class($this) { - private $testCase; - - public function __construct($testCase) + public function __construct(private $testCase) { - $this->testCase = $testCase; } public function __invoke(string $name, string $id, ContainerInterface $container): void