Skip to content

Commit 89898e0

Browse files
committed
Fix errors reported by static analysers.
1 parent 5b1319e commit 89898e0

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ script:
2828
- if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION != 7.3 ]]; then vendor/bin/phpunit; fi
2929
- if [[ $DEFAULT == 1 && $TRAVIS_PHP_VERSION == 7.3 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi
3030

31-
- if [[ $STATIC_ANALYSIS == 1 ]]; then composer stan; fi
31+
- |
32+
if [[ $STATIC_ANALYSIS == 1 ]]; then
33+
phpstan analyse src/
34+
psalm.phar
35+
fi
3236
- if [[ $PHPCS == 1 ]]; then composer cs-check; fi
3337

3438
after_success:

src/Command/WorkerCommand.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ protected function getQueueExtension(Arguments $args, LoggerInterface $logger):
8585
{
8686
$maxIterations = (int)$args->getOption('max-iterations');
8787
$maxRuntime = (int)$args->getOption('max-runtime');
88-
if ($maxIterations === null) {
89-
$maxIterations = 0;
90-
}
91-
92-
if ($maxRuntime === null) {
93-
$maxRuntime = 0;
94-
}
9588

9689
return new QueueExtension($maxIterations, $maxRuntime, $logger);
9790
}
@@ -104,12 +97,12 @@ protected function getQueueExtension(Arguments $args, LoggerInterface $logger):
10497
*/
10598
protected function getLogger(Arguments $args): LoggerInterface
10699
{
107-
$logger = new NullLogger();
100+
$logger = null;
108101
if (!empty($args->getOption('verbose'))) {
109-
$logger = Log::engine($args->getOption('logger'));
102+
$logger = Log::engine((string)$args->getOption('logger'));
110103
}
111104

112-
return $logger;
105+
return $logger ?? new NullLogger();
113106
}
114107

115108
/**
@@ -123,7 +116,7 @@ public function execute(Arguments $args, ConsoleIo $io)
123116
$processor = new Processor($logger);
124117
$extension = $this->getQueueExtension($args, $logger);
125118

126-
$config = $args->getOption('config');
119+
$config = (string)$args->getOption('config');
127120
if (!Configure::check(sprintf('Queue.%s', $config))) {
128121
$io->error(sprintf('Configuration key "%s" was not found', $config));
129122
$this->abort();
@@ -137,13 +130,14 @@ public function execute(Arguments $args, ConsoleIo $io)
137130
$this->abort();
138131
}
139132

133+
/** @var \Cake\Event\EventListenerInterface $listener */
140134
$listener = new $listenerClassName();
141135
$processor->getEventManager()->on($listener);
142136
$extension->getEventManager()->on($listener);
143137
}
144138
$url = Configure::read(sprintf('Queue.%s.url', $config));
145139
$client = new SimpleClient($url, $logger);
146-
$client->bindTopic($args->getOption('queue'), $processor);
140+
$client->bindTopic((string)$args->getOption('queue'), $processor);
147141
$client->consume($extension);
148142
}
149143
}

0 commit comments

Comments
 (0)