Skip to content

Commit 157b734

Browse files
Upgrade phpstan level (#27)
* Upgrade phpstan to level 5
1 parent 5c96bd1 commit 157b734

14 files changed

+92
-146
lines changed

DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public function __construct($name)
3131
public function getConfigTreeBuilder()
3232
{
3333
$tree = new TreeBuilder($this->name);
34-
$rootNode = \method_exists('Symfony\Component\Config\Definition\Builder\TreeBuilder', 'getRootNode') ? $tree->getRootNode() : $tree->root($this->name);
34+
/** @var ArrayNodeDefinition $rootNode */
35+
$rootNode = $tree->getRootNode();
3536

3637
$rootNode
3738
->children()

RabbitMq/AMQPConnectionFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
use OldSound\RabbitMqBundle\Provider\ConnectionParametersProviderInterface;
66
use PhpAmqpLib\Connection\AbstractConnection;
7-
use PhpAmqpLib\Connection\AMQPSocketConnection;
87
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
98

109
class AMQPConnectionFactory
1110
{
12-
/** @var \ReflectionClass */
11+
/** @var string */
1312
private $class;
1413

1514
/** @var array */

RabbitMq/BaseAmqp.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ abstract class BaseAmqp
5050
);
5151

5252
/**
53-
* @var EventDispatcherInterface
53+
* @var EventDispatcherInterface|null
5454
*/
55-
protected $eventDispatcher;
55+
protected $eventDispatcher = null;
5656

5757
/**
5858
* @param AbstractConnection $conn
@@ -268,23 +268,16 @@ public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
268268
*/
269269
protected function dispatchEvent($eventName, AMQPEvent $event)
270270
{
271-
if ($this->getEventDispatcher()) {
272-
if ($this->getEventDispatcher() instanceof ContractsEventDispatcherInterface) {
273-
$this->getEventDispatcher()->dispatch(
274-
$event,
275-
$eventName
276-
);
277-
} else {
278-
$this->getEventDispatcher()->dispatch(
279-
$eventName,
280-
$event
281-
);
282-
}
271+
if ($this->getEventDispatcher() instanceof ContractsEventDispatcherInterface) {
272+
$this->getEventDispatcher()->dispatch(
273+
$event,
274+
$eventName
275+
);
283276
}
284277
}
285278

286279
/**
287-
* @return EventDispatcherInterface
280+
* @return EventDispatcherInterface|null
288281
*/
289282
public function getEventDispatcher()
290283
{

RabbitMq/BaseConsumer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ abstract class BaseConsumer extends BaseAmqp implements DequeuerInterface
2424
/** @var int */
2525
protected $idleTimeoutExitCode;
2626

27-
/**
28-
* @param $callback
29-
*/
3027
public function setCallback($callback)
3128
{
3229
$this->callback = $callback;
@@ -42,6 +39,7 @@ public function getCallback()
4239

4340
/**
4441
* @param int $msgAmount
42+
* @throws \ErrorException
4543
*/
4644
public function start($msgAmount = 0)
4745
{

RabbitMq/BatchConsumer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ protected function handleProcessMessages($processFlags = null)
191191
}
192192

193193
/**
194-
* @param int $deliveryTag
195-
* @param mixed $processFlag
194+
* @param string|int $deliveryTag
195+
* @param mixed $processFlag
196196
*
197197
* @return void
198198
*/
@@ -293,7 +293,7 @@ private function addMessage(AMQPMessage $message)
293293
/**
294294
* @param int $deliveryTag
295295
*
296-
* @return AMQPMessage
296+
* @return AMQPMessage|null
297297
*/
298298
private function getMessage($deliveryTag)
299299
{
@@ -313,7 +313,7 @@ private function getMessage($deliveryTag)
313313
private function getMessageChannel($deliveryTag)
314314
{
315315
$message = $this->getMessage($deliveryTag);
316-
if (!$message) {
316+
if ($message === null) {
317317
throw new AMQPRuntimeException(sprintf('Unknown delivery_tag %d!', $deliveryTag));
318318
}
319319

RabbitMq/Binding.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getDestination()
5959
}
6060

6161
/**
62-
* @param bool $destination
62+
* @param string $destination
6363
*/
6464
public function setDestination($destination)
6565
{
@@ -75,7 +75,7 @@ public function getDestinationIsExchange()
7575
}
7676

7777
/**
78-
* @param string $destinationIsExchange
78+
* @param bool $destinationIsExchange
7979
*/
8080
public function setDestinationIsExchange($destinationIsExchange)
8181
{

RabbitMq/Consumer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Consumer extends BaseConsumer
1717
const TIMEOUT_TYPE_GRACEFUL_MAX_EXECUTION = 'graceful-max-execution';
1818

1919
/**
20-
* @var int $memoryLimit
20+
* @var int|null $memoryLimit
2121
*/
2222
protected $memoryLimit = null;
2323

@@ -45,7 +45,7 @@ public function setMemoryLimit($memoryLimit)
4545
/**
4646
* Get the memory limit
4747
*
48-
* @return int
48+
* @return int|null
4949
*/
5050
public function getMemoryLimit()
5151
{

RabbitMq/DequeuerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function forceStopConsumer();
1414
/**
1515
* Set idle timeout
1616
*
17-
* @param $idleTimeout
17+
* @param int $idleTimeout
1818
*
1919
* @return void
2020
*/

RabbitMq/MultipleConsumer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MultipleConsumer extends Consumer
1313
/**
1414
* Queues provider
1515
*
16-
* @var QueuesProviderInterface
16+
* @var QueuesProviderInterface|null
1717
*/
1818
protected $queuesProvider = null;
1919

Tests/RabbitMq/AMQPConnectionFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function testConnectionsParametersProvider()
336336
/**
337337
* Preparing ConnectionParametersProviderInterface instance
338338
*
339-
* @return MockObject
339+
* @return ConnectionParametersProviderInterface|MockObject
340340
*/
341341
private function prepareConnectionParametersProvider()
342342
{

0 commit comments

Comments
 (0)