|
43 | 43 | */ |
44 | 44 | class WorkerCommand extends Command |
45 | 45 | { |
46 | | - /** |
47 | | - * @var \Cake\Core\ContainerInterface|null |
48 | | - */ |
49 | | - protected ?ContainerInterface $container = null; |
50 | | - |
51 | 46 | /** |
52 | 47 | * @param \Cake\Core\ContainerInterface|null $container DI container instance |
53 | 48 | */ |
54 | | - public function __construct(?ContainerInterface $container = null) |
55 | | - { |
56 | | - $this->container = $container; |
| 49 | + public function __construct( |
| 50 | + protected readonly ?ContainerInterface $container = null, |
| 51 | + ) { |
57 | 52 | } |
58 | 53 |
|
59 | 54 | /** |
@@ -138,12 +133,12 @@ protected function getQueueExtension(Arguments $args, LoggerInterface $logger): |
138 | 133 | $limitAttempsExtension, |
139 | 134 | ]; |
140 | 135 |
|
141 | | - if (!is_null($args->getOption('max-jobs'))) { |
| 136 | + if ($args->getOption('max-jobs') !== null) { |
142 | 137 | $maxJobs = (int)$args->getOption('max-jobs'); |
143 | 138 | $extensions[] = new LimitConsumedMessagesExtension($maxJobs); |
144 | 139 | } |
145 | 140 |
|
146 | | - if (!is_null($args->getOption('max-runtime'))) { |
| 141 | + if ($args->getOption('max-runtime') !== null) { |
147 | 142 | $endTime = new DateTime(sprintf('+%d seconds', (int)$args->getOption('max-runtime'))); |
148 | 143 | $extensions[] = new LimitConsumptionTimeExtension($endTime); |
149 | 144 | } |
@@ -187,12 +182,12 @@ protected function getProcessor(Arguments $args, ConsoleIo $io, LoggerInterface |
187 | 182 | $processorClass = $config['processor'] ?? Processor::class; |
188 | 183 |
|
189 | 184 | if (!class_exists($processorClass)) { |
190 | | - $io->error(sprintf(sprintf('Processor class %s not found', $processorClass))); |
| 185 | + $io->error(sprintf('Processor class %s not found', $processorClass)); |
191 | 186 | $this->abort(); |
192 | 187 | } |
193 | 188 |
|
194 | 189 | if (!is_subclass_of($processorClass, InteropProcessor::class)) { |
195 | | - $io->error(sprintf(sprintf('Processor class %s must implement Interop\Queue\Processor', $processorClass))); |
| 190 | + $io->error(sprintf('Processor class %s must implement Interop\Queue\Processor', $processorClass)); |
196 | 191 | $this->abort(); |
197 | 192 | } |
198 | 193 |
|
@@ -231,10 +226,11 @@ public function execute(Arguments $args, ConsoleIo $io): int |
231 | 226 | $processor->getEventManager()->on($listener); |
232 | 227 | } |
233 | 228 | } |
| 229 | + |
234 | 230 | $client = QueueManager::engine($config); |
235 | 231 | $queue = $args->getOption('queue') |
236 | 232 | ? (string)$args->getOption('queue') |
237 | | - : Configure::read("Queue.{$config}.queue", 'default'); |
| 233 | + : Configure::read(sprintf('Queue.%s.queue', $config), 'default'); |
238 | 234 | $processorName = $args->getOption('processor') ? (string)$args->getOption('processor') : 'default'; |
239 | 235 |
|
240 | 236 | $client->bindTopic($queue, $processor, $processorName); |
|
0 commit comments