2121
2222class WebPush
2323{
24- /**
25- * @var Client
26- */
27- protected $ client ;
28-
29- /**
30- * @var array
31- */
32- protected $ auth ;
24+ protected Client $ client ;
25+ protected array $ auth ;
3326
3427 /**
3528 * @var null|array Array of array of Notifications
3629 */
37- protected $ notifications ;
30+ protected ? array $ notifications = null ;
3831
3932 /**
40- * @var array Default options : TTL, urgency, topic, batchSize
33+ * @var array Default options: TTL, urgency, topic, batchSize
4134 */
42- protected $ defaultOptions ;
35+ protected array $ defaultOptions ;
4336
4437 /**
4538 * @var int Automatic padding of payloads, if disabled, trade security for bandwidth
4639 */
47- protected $ automaticPadding = Encryption::MAX_COMPATIBILITY_PAYLOAD_LENGTH ;
40+ protected int $ automaticPadding = Encryption::MAX_COMPATIBILITY_PAYLOAD_LENGTH ;
4841
4942 /**
5043 * @var bool Reuse VAPID headers in the same flush session to improve performance
5144 */
52- protected $ reuseVAPIDHeaders = false ;
45+ protected bool $ reuseVAPIDHeaders = false ;
5346
5447 /**
5548 * @var array Dictionary for VAPID headers cache
5649 */
57- protected $ vapidHeaders = [];
50+ protected array $ vapidHeaders = [];
5851
5952 /**
6053 * WebPush constructor.
6154 *
62- * @param array $auth Some servers needs authentication
55+ * @param array $auth Some servers need authentication
6356 * @param array $defaultOptions TTL, urgency, topic, batchSize
6457 * @param int|null $timeout Timeout of POST request
6558 *
@@ -281,20 +274,17 @@ public function isAutomaticPadding(): bool
281274 return $ this ->automaticPadding !== 0 ;
282275 }
283276
284- /**
285- * @return int
286- */
287- public function getAutomaticPadding ()
277+ public function getAutomaticPadding (): int
288278 {
289279 return $ this ->automaticPadding ;
290280 }
291281
292282 /**
293- * @param int| bool $automaticPadding Max padding length
283+ * @param bool|int $automaticPadding Max padding length
294284 *
295285 * @throws \Exception
296286 */
297- public function setAutomaticPadding ($ automaticPadding ): WebPush
287+ public function setAutomaticPadding (bool | int $ automaticPadding ): WebPush
298288 {
299289 if ($ automaticPadding > Encryption::MAX_PAYLOAD_LENGTH ) {
300290 throw new \Exception ('Automatic padding is too large. Max is ' .Encryption::MAX_PAYLOAD_LENGTH .'. Recommended max is ' .Encryption::MAX_COMPATIBILITY_PAYLOAD_LENGTH .' for compatibility reasons (see README). ' );
@@ -311,20 +301,15 @@ public function setAutomaticPadding($automaticPadding): WebPush
311301 return $ this ;
312302 }
313303
314- /**
315- * @return bool
316- */
317- public function getReuseVAPIDHeaders ()
304+ public function getReuseVAPIDHeaders (): bool
318305 {
319306 return $ this ->reuseVAPIDHeaders ;
320307 }
321308
322309 /**
323310 * Reuse VAPID headers in the same flush session to improve performance
324- *
325- * @return WebPush
326311 */
327- public function setReuseVAPIDHeaders (bool $ enabled )
312+ public function setReuseVAPIDHeaders (bool $ enabled ): WebPush
328313 {
329314 $ this ->reuseVAPIDHeaders = $ enabled ;
330315
@@ -338,10 +323,8 @@ public function getDefaultOptions(): array
338323
339324 /**
340325 * @param array $defaultOptions Keys 'TTL' (Time To Live, defaults 4 weeks), 'urgency', 'topic', 'batchSize'
341- *
342- * @return WebPush
343326 */
344- public function setDefaultOptions (array $ defaultOptions )
327+ public function setDefaultOptions (array $ defaultOptions ): WebPush
345328 {
346329 $ this ->defaultOptions ['TTL ' ] = $ defaultOptions ['TTL ' ] ?? 2419200 ;
347330 $ this ->defaultOptions ['urgency ' ] = $ defaultOptions ['urgency ' ] ?? null ;
@@ -357,10 +340,9 @@ public function countPendingNotifications(): int
357340 }
358341
359342 /**
360- * @return array
361343 * @throws \ErrorException
362344 */
363- protected function getVAPIDHeaders (string $ audience , string $ contentEncoding , array $ vapid )
345+ protected function getVAPIDHeaders (string $ audience , string $ contentEncoding , array $ vapid ): ? array
364346 {
365347 $ vapidHeaders = null ;
366348
0 commit comments