1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Portiny\RabbitMQ\Queue; |
4
|
|
|
|
5
|
|
|
use Bunny\Channel; |
6
|
|
|
use Bunny\Exception\BunnyException; |
7
|
|
|
use Bunny\Protocol\MethodQueueBindOkFrame; |
8
|
|
|
use Bunny\Protocol\MethodQueueDeclareOkFrame; |
9
|
|
|
|
10
|
|
|
abstract class AbstractQueue |
11
|
|
|
{ |
12
|
|
|
final public function declare(Channel $channel): void |
13
|
|
|
{ |
14
|
|
|
$frame = $channel->queueDeclare( |
15
|
|
|
$this->getName(), |
16
|
|
|
$this->isPassive(), |
17
|
|
|
$this->isDurable(), |
18
|
|
|
$this->isExclusive(), |
19
|
|
|
$this->isAutoDelete(), |
20
|
|
|
FALSE, |
21
|
|
|
$this->getArguments() |
22
|
|
|
); |
23
|
|
|
if (! $frame instanceof MethodQueueDeclareOkFrame) { |
|
|
|
|
24
|
|
|
throw new BunnyException(sprintf('Could not declare queue "%s".', $this->getName())); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
foreach ($this->getBindings() as $queueBind) { |
28
|
|
|
$frame = $channel->queueBind( |
29
|
|
|
$this->getName(), |
30
|
|
|
$queueBind->getExchange(), |
31
|
|
|
$queueBind->getRoutingKey(), |
32
|
|
|
FALSE, |
33
|
|
|
$queueBind->getArguments() |
34
|
|
|
); |
35
|
|
|
if (! $frame instanceof MethodQueueBindOkFrame) { |
|
|
|
|
36
|
|
|
throw new BunnyException( |
37
|
|
|
sprintf( |
38
|
|
|
'Could not bind queue "%s" to "%s" with routing key "%s".', |
39
|
|
|
$this->getName(), |
40
|
|
|
$queueBind->getExchange(), |
41
|
|
|
$queueBind->getRoutingKey() |
42
|
|
|
) |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
abstract protected function getName(): string; |
49
|
|
|
|
50
|
|
|
protected function isPassive(): bool |
51
|
|
|
{ |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
protected function isDurable(): bool |
56
|
|
|
{ |
57
|
|
|
return false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
protected function isExclusive(): bool |
61
|
|
|
{ |
62
|
|
|
return false; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
protected function isAutoDelete(): bool |
66
|
|
|
{ |
67
|
|
|
return false; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function isNoWait(): bool |
71
|
|
|
{ |
72
|
|
|
return false; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
protected function getArguments(): array |
76
|
|
|
{ |
77
|
|
|
return []; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return QueueBind[] |
82
|
|
|
*/ |
83
|
|
|
protected function getBindings(): array |
84
|
|
|
{ |
85
|
|
|
return []; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.