1 | <?php |
||
11 | class Consumer extends Stomp implements ConsumerInterface, SignalHandlingConsumerInterface |
||
12 | { |
||
13 | protected $callback; |
||
14 | protected $routingKey; |
||
15 | protected $logger; |
||
16 | protected $subscribed = false; |
||
17 | protected $queueName; |
||
18 | protected $subscriptionName; |
||
19 | protected $label; |
||
20 | protected $forceStop = false; |
||
21 | protected $forceStopReason; |
||
22 | protected $dispatchSignals = false; |
||
23 | protected $memoryLimit = null; |
||
24 | |||
25 | public function setLogger(LoggerInterface $logger = null) |
||
31 | |||
32 | /** |
||
33 | * @param int $limit MB |
||
34 | * @return $this |
||
35 | */ |
||
36 | public function setMemoryLimit($limit) |
||
42 | |||
43 | /** |
||
44 | * @param string $name |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function setSubscriptionName($name) |
||
54 | |||
55 | public function setLabel($label) |
||
62 | |||
63 | protected function setClientId() |
||
71 | |||
72 | /** |
||
73 | * NB: when changing this, you should change the subscription name as well, otherwise you will get an error for |
||
74 | * trying to create a double subscription |
||
75 | * |
||
76 | * @param string $key |
||
77 | * @return $this |
||
78 | */ |
||
79 | public function setRoutingKey($key) |
||
86 | |||
87 | /** |
||
88 | * @param MessageConsumerInterface $callback |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function setCallback($callback) |
||
100 | |||
101 | /** |
||
102 | * @param string $queueName |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function setQueueName($queueName) |
||
111 | |||
112 | /** |
||
113 | * @param int $amount |
||
114 | * @param int $timeout seconds |
||
115 | * @return nothing |
||
116 | */ |
||
117 | public function consume($amount, $timeout=0) |
||
165 | |||
166 | protected function getClientProperties(array $additionalProperties = array(), $command='') |
||
179 | |||
180 | protected function subscribe() |
||
193 | |||
194 | public function setHandleSignals($doHandle) |
||
199 | |||
200 | |||
201 | public function forceStop($reason = '') |
||
207 | |||
208 | /** |
||
209 | * Dispatches signals and throws an exception if user wants to stop. To be called at execution points when there is no data loss |
||
210 | * |
||
211 | * @throws ForcedStopException |
||
212 | */ |
||
213 | protected function maybeStopConsumer() |
||
227 | } |
||
228 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: