diff --git a/lib/Push.php b/lib/Push.php index 2ddb0e0f8..5fbbbdca8 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -66,7 +66,7 @@ class Push { */ protected array $userStatuses = []; /** - * @psalm-var array> + * @psalm-var array> */ protected array $userWebPushDevices = []; /** @@ -175,11 +175,8 @@ public function flushPayloads(): void { } /** - * @param array $devices - * @psalm-param $devices list - * @param string $app - * @return array - * @psalm-return list + * @psalm-param list $devices + * @psalm-return list */ public function filterWebPushDeviceList(array $devices, string $app): array { // Consider all 3 options as 'talk' @@ -187,11 +184,11 @@ public function filterWebPushDeviceList(array $devices, string $app): array { $app = 'talk'; } - return array_filter($devices, function ($device) use ($app) { + return array_values(array_filter($devices, function ($device) use ($app) { $appTypes = explode(',', $device['app_types']); return $device['activated'] && (\in_array($app, $appTypes) || (\in_array('all', $appTypes) && !\in_array('-' . $app, $appTypes))); - }); + })); } @@ -299,6 +296,9 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf $this->proxyPushToDevice($id, $user, $proxyDevices, $notification, $output); } + /** + * @param list $devices + */ public function webPushToDevice(int $id, IUser $user, array $devices, INotification $notification, ?OutputInterface $output = null): void { if (empty($devices)) { $this->printInfo('No web push devices found for user'); @@ -1042,7 +1042,7 @@ protected function getProxyDevicesForUsers(array $userIds): array { /** * @param string $uid - * @return list + * @return list */ protected function getWebPushDevicesForUser(string $uid): array { $query = $this->db->getQueryBuilder(); @@ -1051,6 +1051,7 @@ protected function getWebPushDevicesForUser(string $uid): array { ->where($query->expr()->eq('uid', $query->createNamedParameter($uid))); $result = $query->executeQuery(); + /** @var list $devices */ $devices = $result->fetchAll(); $result->closeCursor(); @@ -1059,7 +1060,7 @@ protected function getWebPushDevicesForUser(string $uid): array { /** * @param string[] $userIds - * @return array> + * @return array> */ protected function getWebPushDevicesForUsers(array $userIds): array { $query = $this->db->getQueryBuilder(); @@ -1070,6 +1071,7 @@ protected function getWebPushDevicesForUsers(array $userIds): array { $devices = []; $result = $query->executeQuery(); while ($row = $result->fetch()) { + /** @psalm-var array{id: int, uid: string, token: int, endpoint: string, ua_public: string, auth: string, app_types: string, activated: bool, activation_token: string} $row */ if (!isset($devices[$row['uid']])) { $devices[$row['uid']] = []; } diff --git a/lib/WebPushClient.php b/lib/WebPushClient.php index e3549413e..ce9870e7c 100644 --- a/lib/WebPushClient.php +++ b/lib/WebPushClient.php @@ -118,7 +118,7 @@ public function notify(string $endpoint, string $uaPublicKey, string $auth, stri // the callback could be defined by the caller // For the moment, it is used during registration only - no need to catch 404 &co // as the registration isn't activated - $callback = function ($r) { + $callback = function ($r): void { }; $c->flushPooled($callback); } diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 3ffa25ccb..bde038bda 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -1,5 +1,5 @@ - + identityProof]]> @@ -21,26 +21,16 @@ - - - >]]> - >]]> ]]> ]]> - ]]> - ]]>