4343 */
4444class WorkerCommand extends Command
4545{
46- /**
47- * @var \Cake\Core\ContainerInterface|null
48- */
49- protected ?ContainerInterface $ container = null ;
50-
5146 /**
5247 * @param \Cake\Core\ContainerInterface|null $container DI container instance
5348 */
54- public function __construct (? ContainerInterface $ container = null )
55- {
56- $ this -> container = $ container ;
49+ public function __construct (
50+ protected readonly ? ContainerInterface $ container = null ,
51+ ) {
5752 }
5853
5954 /**
6055 * Get the command name.
61- *
62- * @return string
6356 */
6457 public static function defaultName (): string
6558 {
@@ -68,8 +61,6 @@ public static function defaultName(): string
6861
6962 /**
7063 * Gets the option parser instance and configures it.
71- *
72- * @return \Cake\Console\ConsoleOptionParser
7364 */
7465 public function getOptionParser (): ConsoleOptionParser
7566 {
@@ -122,7 +113,6 @@ public function getOptionParser(): ConsoleOptionParser
122113 *
123114 * @param \Cake\Console\Arguments $args Arguments
124115 * @param \Psr\Log\LoggerInterface $logger Logger instance.
125- * @return \Enqueue\Consumption\ExtensionInterface
126116 */
127117 protected function getQueueExtension (Arguments $ args , LoggerInterface $ logger ): ExtensionInterface
128118 {
@@ -138,12 +128,12 @@ protected function getQueueExtension(Arguments $args, LoggerInterface $logger):
138128 $ limitAttempsExtension ,
139129 ];
140130
141- if (! is_null ( $ args ->getOption ('max-jobs ' )) ) {
131+ if ($ args ->getOption ('max-jobs ' ) !== null ) {
142132 $ maxJobs = (int )$ args ->getOption ('max-jobs ' );
143133 $ extensions [] = new LimitConsumedMessagesExtension ($ maxJobs );
144134 }
145135
146- if (! is_null ( $ args ->getOption ('max-runtime ' )) ) {
136+ if ($ args ->getOption ('max-runtime ' ) !== null ) {
147137 $ endTime = new DateTime (sprintf ('+%d seconds ' , (int )$ args ->getOption ('max-runtime ' )));
148138 $ extensions [] = new LimitConsumptionTimeExtension ($ endTime );
149139 }
@@ -159,7 +149,6 @@ protected function getQueueExtension(Arguments $args, LoggerInterface $logger):
159149 * Creates and returns a LoggerInterface object
160150 *
161151 * @param \Cake\Console\Arguments $args Arguments
162- * @return \Psr\Log\LoggerInterface
163152 */
164153 protected function getLogger (Arguments $ args ): LoggerInterface
165154 {
@@ -177,7 +166,6 @@ protected function getLogger(Arguments $args): LoggerInterface
177166 * @param \Cake\Console\Arguments $args Arguments
178167 * @param \Cake\Console\ConsoleIo $io ConsoleIo
179168 * @param \Psr\Log\LoggerInterface $logger Logger instance
180- * @return \Interop\Queue\Processor
181169 */
182170 protected function getProcessor (Arguments $ args , ConsoleIo $ io , LoggerInterface $ logger ): InteropProcessor
183171 {
@@ -187,12 +175,12 @@ protected function getProcessor(Arguments $args, ConsoleIo $io, LoggerInterface
187175 $ processorClass = $ config ['processor ' ] ?? Processor::class;
188176
189177 if (!class_exists ($ processorClass )) {
190- $ io ->error (sprintf (sprintf ( 'Processor class %s not found ' , $ processorClass) ));
178+ $ io ->error (sprintf ('Processor class %s not found ' , $ processorClass ));
191179 $ this ->abort ();
192180 }
193181
194182 if (!is_subclass_of ($ processorClass , InteropProcessor::class)) {
195- $ io ->error (sprintf (sprintf ( 'Processor class %s must implement Interop\Queue\Processor ' , $ processorClass) ));
183+ $ io ->error (sprintf ('Processor class %s must implement Interop\Queue\Processor ' , $ processorClass ));
196184 $ this ->abort ();
197185 }
198186
@@ -202,7 +190,6 @@ protected function getProcessor(Arguments $args, ConsoleIo $io, LoggerInterface
202190 /**
203191 * @param \Cake\Console\Arguments $args Arguments
204192 * @param \Cake\Console\ConsoleIo $io ConsoleIo
205- * @return int
206193 */
207194 public function execute (Arguments $ args , ConsoleIo $ io ): int
208195 {
@@ -231,10 +218,11 @@ public function execute(Arguments $args, ConsoleIo $io): int
231218 $ processor ->getEventManager ()->on ($ listener );
232219 }
233220 }
221+
234222 $ client = QueueManager::engine ($ config );
235223 $ queue = $ args ->getOption ('queue ' )
236224 ? (string )$ args ->getOption ('queue ' )
237- : Configure::read (" Queue. { $ config } .queue " , 'default ' );
225+ : Configure::read (sprintf ( ' Queue.%s .queue ' , $ config ) , 'default ' );
238226 $ processorName = $ args ->getOption ('processor ' ) ? (string )$ args ->getOption ('processor ' ) : 'default ' ;
239227
240228 $ client ->bindTopic ($ queue , $ processor , $ processorName );
0 commit comments