1 | <?php |
||
8 | class EngageSparkChannel |
||
9 | { |
||
10 | /** @var string */ |
||
11 | private $mode; |
||
12 | |||
13 | /** @var string */ |
||
14 | private $clientRef; |
||
15 | |||
16 | /** @var EngageSpark */ |
||
17 | protected $smsc; |
||
18 | |||
19 | public function __construct(EngageSpark $smsc) |
||
23 | |||
24 | /** |
||
25 | * Send the given notification. |
||
26 | * |
||
27 | * @param mixed $notifiable |
||
28 | * @param Notification $notification |
||
29 | * |
||
30 | * @return void |
||
31 | */ |
||
32 | public function send($notifiable, Notification $notification) |
||
46 | |||
47 | /** |
||
48 | * Gets a list of phones from the given notifiable. |
||
49 | * |
||
50 | * @param mixed $notifiable |
||
51 | * @param Notification $notification |
||
52 | * |
||
53 | * @return string[] |
||
54 | */ |
||
55 | protected function getRecipients($notifiable, Notification $notification) |
||
65 | |||
66 | protected function sendMessage($recipients, EngageSparkMessage $message) |
||
101 | |||
102 | protected function getWebHook(EngageSparkMessage $message) |
||
106 | |||
107 | protected function getOrgId() |
||
111 | |||
112 | public function getClientRef() |
||
116 | |||
117 | protected function getSenderId(EngageSparkMessage $message) |
||
121 | |||
122 | protected function setClientRef(Notification $notification) |
||
128 | |||
129 | protected function getMode() |
||
133 | |||
134 | protected function setMode(EngageSparkMessage $message) |
||
140 | } |
||
141 |
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: