1 | <?php |
||
31 | class Notifications extends Controller |
||
32 | { |
||
33 | /** |
||
34 | * Notifier. |
||
35 | * |
||
36 | * @var Notifier |
||
37 | */ |
||
38 | protected $notifier; |
||
39 | |||
40 | /** |
||
41 | * User. |
||
42 | * |
||
43 | * @var User |
||
44 | */ |
||
45 | protected $user; |
||
46 | |||
47 | /** |
||
48 | * Filesystem. |
||
49 | * |
||
50 | * @var Filesystem |
||
51 | */ |
||
52 | protected $fs; |
||
53 | |||
54 | /** |
||
55 | * Server. |
||
56 | * |
||
57 | * @var Server |
||
58 | */ |
||
59 | protected $server; |
||
60 | |||
61 | /** |
||
62 | * Async. |
||
63 | * |
||
64 | * @var Async |
||
65 | */ |
||
66 | protected $async; |
||
67 | |||
68 | /** |
||
69 | * Logger. |
||
70 | * |
||
71 | * @var LoggerInterface |
||
72 | */ |
||
73 | protected $logger; |
||
74 | |||
75 | /** |
||
76 | * Role attribute decorator. |
||
77 | * |
||
78 | * @var RoleAttributeDecorator |
||
79 | */ |
||
80 | protected $role_decorator; |
||
81 | |||
82 | /** |
||
83 | * Role attribute decorator. |
||
84 | * |
||
85 | * @var NodeAttributeDecorator |
||
86 | */ |
||
87 | protected $node_decorator; |
||
88 | |||
89 | /** |
||
90 | * Notification attribute decorator. |
||
91 | * |
||
92 | * @var NotificationAttributeDecorator |
||
93 | */ |
||
94 | protected $notification_decorator; |
||
95 | |||
96 | /** |
||
97 | * Constructor. |
||
98 | * |
||
99 | * @param Notifier $notifier |
||
100 | * @param Server $server |
||
101 | * @param Async $async |
||
102 | * @param LoggerInterface $logger |
||
103 | * @param RoleAttributeDecorator $role_decorator |
||
104 | * @param NodeAttributeDecorator $node_decorator |
||
105 | * @param NotificationAttributeDecorator $notification_decorator |
||
106 | */ |
||
107 | public function __construct(Notifier $notifier, Server $server, Async $async, LoggerInterface $logger, RoleAttributeDecorator $role_decorator, NodeAttributeDecorator $node_decorator, NotificationAttributeDecorator $notification_decorator) |
||
119 | |||
120 | /** |
||
121 | * @api {get} /api/v2/notifications Get notifications |
||
122 | * @apiVersion 2.0.0 |
||
123 | * @apiName get |
||
124 | * @apiGroup App\Notification |
||
125 | * @apiPermission none |
||
126 | * @apiDescription Fetch my nofitifications |
||
127 | * |
||
128 | * @apiExample (cURL) exmaple: |
||
129 | * curl -XGET "https://SERVER/api/v2/notification" |
||
130 | * |
||
131 | * @apiSuccessExample {string} Success-Response: |
||
132 | * HTTP/1.1 200 OK |
||
133 | * [ |
||
134 | * "id": "", |
||
135 | * "message": "Hi there, this is a notification", |
||
136 | * "subject": "Hi", |
||
137 | * "sender": { |
||
138 | * "id": "", |
||
139 | * "name": "" |
||
140 | * } |
||
141 | * ] |
||
142 | * |
||
143 | * @param ObjectId $id |
||
144 | * @param array $attributes |
||
145 | * @param int $offset |
||
146 | * @param int $limit |
||
147 | */ |
||
148 | public function get(?ObjectId $id = null, array $attributes = [], int $offset = 0, int $limit = 20): Response |
||
164 | |||
165 | /** |
||
166 | * @api {delete} /api/v2/notifications Delete notification |
||
167 | * @apiVersion 2.0.0 |
||
168 | * @apiName delete |
||
169 | * @apiGroup App\Notification |
||
170 | * @apiPermission none |
||
171 | * @apiDescription Fetch my nofitifications |
||
172 | * |
||
173 | * @apiExample (cURL) exmaple: |
||
174 | * curl -XGET "https://SERVER/api/v2/notification" |
||
175 | * |
||
176 | * @apiSuccessExample {string} Success-Response: |
||
177 | * HTTP/1.1 204 No Content |
||
178 | */ |
||
179 | public function delete(ObjectId $id): Response |
||
185 | |||
186 | /** |
||
187 | * @api {post} /api/v2/notifications Post a notification to a group of users |
||
188 | * @apiVersion 2.0.0 |
||
189 | * @apiName post |
||
190 | * @apiGroup App\Notification |
||
191 | * @apiPermission none |
||
192 | * @apiDescription Send notification |
||
193 | * |
||
194 | * @apiExample (cURL) exmaple: |
||
195 | * curl -XPOST "https://SERVER/api/v2/notification" |
||
196 | * |
||
197 | * @apiSuccessExample {string} Success-Response: |
||
198 | * HTTP/1.1 202 Accepted |
||
199 | */ |
||
200 | public function post(array $receiver, string $subject, string $body): Response |
||
207 | |||
208 | /** |
||
209 | * @api {post} /api/v2/notifications/broadcast Post a notification to all users (or to a bunch of users) |
||
210 | * @apiVersion 2.0.0 |
||
211 | * @apiName postBroadcast |
||
212 | * @apiGroup App\Notification |
||
213 | * @apiPermission admin |
||
214 | * @apiDescription Send notification |
||
215 | * |
||
216 | * @apiExample (cURL) exmaple: |
||
217 | * curl -XPOST "https://SERVER/api/v2/notifications/broadcast" |
||
218 | * |
||
219 | * @apiSuccessExample {string} Success-Response: |
||
220 | * HTTP/1.1 202 Accepted |
||
221 | */ |
||
222 | public function postBroadcast(string $subject, string $body): Response |
||
236 | |||
237 | /** |
||
238 | * @api {post} /api/v2/notifications/mail Send a mail |
||
239 | * @apiVersion 2.0.0 |
||
240 | * @apiName postMail |
||
241 | * @apiGroup App\Notification |
||
242 | * @apiPermission none |
||
243 | * @apiDescription Send mail |
||
244 | * |
||
245 | * @apiExample (cURL) exmaple: |
||
246 | * curl -XGET "https://SERVER/api/v2/notifications/mail" |
||
247 | * |
||
248 | * @apiSuccessExample {string} Success-Response: |
||
249 | * HTTP/1.1 202 Accepted |
||
250 | */ |
||
251 | public function postMail(array $receiver, string $subject, string $body) |
||
263 | |||
264 | /** |
||
265 | * @api {post} /api/v2/notifications/subscribe Subscribe for node update |
||
266 | * @apiVersion 2.0.0 |
||
267 | * @apiName postSubscribe |
||
268 | * @apiGroup App\Notification |
||
269 | * @apiPermission none |
||
270 | * @apiDescription Receive node updates |
||
271 | * @apiUse _getNodes |
||
272 | * @apiUse _multiError |
||
273 | * |
||
274 | * @apiExample (cURL) exmaple: |
||
275 | * curl -XPOST "https://SERVER/api/v2/notifications/subscribe" |
||
276 | * |
||
277 | * @apiSuccessExample {string} Success-Response: |
||
278 | * HTTP/1.1 200 OK |
||
279 | * { |
||
280 | * "id": "" |
||
281 | * } |
||
282 | * |
||
283 | * @param null|mixed $id |
||
284 | * @param null|mixed $p |
||
285 | */ |
||
286 | public function postSubscribtions($id = null, $p = null, bool $subscribe = true, bool $exclude_me = true, bool $recursive = false) |
||
321 | } |
||
322 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.