We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
12 | class CentrifugoBroadcaster extends Broadcaster |
||
13 | { |
||
14 | /** |
||
15 | * The Centrifugo SDK instance. |
||
16 | * |
||
17 | * @var Contracts\CentrifugoInterface |
||
18 | */ |
||
19 | protected $centrifugo; |
||
20 | |||
21 | /** |
||
22 | * Create a new broadcaster instance. |
||
23 | * |
||
24 | * @param Centrifugo $centrifugo |
||
25 | */ |
||
26 | public function __construct(Centrifugo $centrifugo) |
||
30 | |||
31 | /** |
||
32 | * Authenticate the incoming request for a given channel. |
||
33 | * |
||
34 | * @param \Illuminate\Http\Request $request |
||
35 | * @return mixed |
||
36 | */ |
||
37 | public function auth($request) |
||
66 | |||
67 | /** |
||
68 | * Return the valid authentication response. |
||
69 | * |
||
70 | * @param \Illuminate\Http\Request $request |
||
71 | * @param mixed $result |
||
72 | * @return mixed |
||
73 | */ |
||
74 | public function validAuthenticationResponse($request, $result) |
||
78 | |||
79 | /** |
||
80 | * Broadcast the given event. |
||
81 | * |
||
82 | * @param array $channels |
||
83 | * @param string $event |
||
84 | * @param array $payload |
||
85 | * @return void |
||
86 | */ |
||
87 | public function broadcast(array $channels, $event, array $payload = []) |
||
104 | |||
105 | /** |
||
106 | * Get client from request. |
||
107 | * |
||
108 | * @param \Illuminate\Http\Request $request |
||
109 | * @return string |
||
110 | */ |
||
111 | private function getClientFromRequest($request) |
||
115 | |||
116 | /** |
||
117 | * Get channels from request. |
||
118 | * |
||
119 | * @param \Illuminate\Http\Request $request |
||
120 | * @return array |
||
121 | */ |
||
122 | private function getChannelsFromRequest($request) |
||
128 | |||
129 | /** |
||
130 | * Get channel name without $ symbol (if present). |
||
131 | * |
||
132 | * @param string $channel |
||
133 | * @return string |
||
134 | */ |
||
135 | private function getChannelName(string $channel) |
||
139 | |||
140 | /** |
||
141 | * Check channel name by $ symbol. |
||
142 | * |
||
143 | * @param string $channel |
||
144 | * @return bool |
||
145 | */ |
||
146 | private function isPrivateChannel(string $channel): bool |
||
150 | |||
151 | /** |
||
152 | * Make response for client, based on access rights. |
||
153 | * |
||
154 | * @param bool $access_granted |
||
155 | * @param string $client |
||
156 | * @return array |
||
157 | */ |
||
158 | private function makeResponseForClient(bool $access_granted, string $client) |
||
169 | |||
170 | /** |
||
171 | * Make response for client, based on access rights of private channel. |
||
172 | * |
||
173 | * @param bool $access_granted |
||
174 | * @param string $channel |
||
175 | * @param string $client |
||
176 | * @return array |
||
177 | */ |
||
178 | private function makeResponseForPrivateClient(bool $access_granted, string $channel, string $client) |
||
192 | } |
||
193 |
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: