From fc521fa2a88ee0c56355fe4517cf6eed251db7a6 Mon Sep 17 00:00:00 2001 From: Heinz Wiesinger Date: Sat, 10 Feb 2024 15:17:53 +0100 Subject: [PATCH] JPush: Use 'static' return type instead of 'self' for payload methods Reviewed at https://reviews.lunr.nl/r/1117/ --- .github/workflows/php-tests.yml | 2 +- build.xml | 4 +- .../JPush/JPushNotification3rdPayload.php | 4 +- .../Vortex/JPush/JPushNotificationPayload.php | 16 +++---- src/Lunr/Vortex/JPush/JPushPayload.php | 44 +++++++++---------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index bada61b..ecf34c5 100644 --- a/.github/workflows/php-tests.yml +++ b/.github/workflows/php-tests.yml @@ -9,7 +9,7 @@ jobs: php-tests: uses: lunr-php/actions-templates/.github/workflows/php-composer.yml@master with: - phpstan-level: 2 + phpstan-level: 3 allow-style-failures: false allow-phpstan-failures: false phpcs-whitelist: tests/phan.config.php tests/phpstan.autoload.inc.php tests/test.bootstrap.inc.php diff --git a/build.xml b/build.xml index 0fb0b19..e988712 100644 --- a/build.xml +++ b/build.xml @@ -112,7 +112,7 @@ - + @@ -127,7 +127,7 @@ - + diff --git a/src/Lunr/Vortex/JPush/JPushNotification3rdPayload.php b/src/Lunr/Vortex/JPush/JPushNotification3rdPayload.php index a8e38f5..36f9607 100644 --- a/src/Lunr/Vortex/JPush/JPushNotification3rdPayload.php +++ b/src/Lunr/Vortex/JPush/JPushNotification3rdPayload.php @@ -52,9 +52,9 @@ public function get_payload(): array * * @param string $sound The notification sound * - * @return JPushNotification3rdPayload Self Reference + * @return $this Self Reference */ - public function set_sound(string $sound): self + public function set_sound(string $sound): static { return $this->set_notification_3rd_data('sound', $sound); } diff --git a/src/Lunr/Vortex/JPush/JPushNotificationPayload.php b/src/Lunr/Vortex/JPush/JPushNotificationPayload.php index bab944a..e8e1396 100644 --- a/src/Lunr/Vortex/JPush/JPushNotificationPayload.php +++ b/src/Lunr/Vortex/JPush/JPushNotificationPayload.php @@ -56,9 +56,9 @@ public function get_payload(): array * * @param string $sound The notification sound * - * @return JPushNotificationPayload Self Reference + * @return $this Self Reference */ - public function set_sound(string $sound): self + public function set_sound(string $sound): static { return $this->set_notification_data('sound', $sound); } @@ -68,9 +68,9 @@ public function set_sound(string $sound): self * * @param bool $val Value for the "content_available" field. * - * @return JPushNotificationPayload Self Reference + * @return $this Self Reference */ - public function set_content_available(bool $val): self + public function set_content_available(bool $val): static { return $this->set_notification_data('content-available', $val, [ 'ios' ]); } @@ -80,9 +80,9 @@ public function set_content_available(bool $val): self * * @param bool $mutable Notification mutable_content value. * - * @return JPushNotificationPayload Self Reference + * @return $this Self Reference */ - public function set_mutable_content(bool $mutable): self + public function set_mutable_content(bool $mutable): static { return $this->set_notification_data('mutable-content', $mutable, [ 'ios' ]); } @@ -92,9 +92,9 @@ public function set_mutable_content(bool $mutable): self * * @param int $priority Notification priority value. * - * @return JPushNotificationPayload Self Reference + * @return $this Self Reference */ - public function set_priority(int $priority): self + public function set_priority(int $priority): static { $priority_class = new ReflectionClass('\Lunr\Vortex\JPush\JPushPriority'); $priorities = array_values($priority_class->getConstants()); diff --git a/src/Lunr/Vortex/JPush/JPushPayload.php b/src/Lunr/Vortex/JPush/JPushPayload.php index 9ca8453..169f184 100644 --- a/src/Lunr/Vortex/JPush/JPushPayload.php +++ b/src/Lunr/Vortex/JPush/JPushPayload.php @@ -62,9 +62,9 @@ abstract public function get_payload(): array; * * @param string $identifier The notification identifier * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_notification_identifier(string $identifier): self + public function set_notification_identifier(string $identifier): static { $this->elements['cid'] = $identifier; @@ -76,9 +76,9 @@ public function set_notification_identifier(string $identifier): self * * @param string $message The notification body * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_body(string $message): self + public function set_body(string $message): static { return $this->set_message_data('msg_content', $message) ->set_notification_3rd_data('content', $message) @@ -90,9 +90,9 @@ public function set_body(string $message): self * * @param string $message The notification title * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_title(string $message): self + public function set_title(string $message): static { return $this->set_message_data('title', $message) ->set_notification_3rd_data('title', $message) @@ -106,9 +106,9 @@ public function set_title(string $message): self * * @param array $data The actual notification information * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_data(array $data): self + public function set_data(array $data): static { return $this->set_message_data('extras', $data) ->set_notification_3rd_data('extras', $data) @@ -120,9 +120,9 @@ public function set_data(array $data): self * * @param string $category The notification category * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_category(string $category): self + public function set_category(string $category): static { return $this->set_message_data('content_type', $category) ->set_notification_data('category', $category); @@ -136,9 +136,9 @@ public function set_category(string $category): self * * @param int $ttl The time in seconds for the notification to stay alive * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_time_to_live(int $ttl): self + public function set_time_to_live(int $ttl): static { $this->set_options('time_to_live', $ttl); @@ -153,9 +153,9 @@ public function set_time_to_live(int $ttl): self * * @param string $key The notification collapse key identifier * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_collapse_key(string $key): self + public function set_collapse_key(string $key): static { $this->set_options('apns_collapse_id', $key); @@ -168,9 +168,9 @@ public function set_collapse_key(string $key): self * @param string $key Options key. * @param string|int|float|bool $value Options value. * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - public function set_options(string $key, $value): self + public function set_options(string $key, $value): static { if (!isset($this->elements['options'])) { @@ -189,9 +189,9 @@ public function set_options(string $key, $value): self * @param mixed $value The value accompanying that key. * @param string[] $platforms The platforms to apply this to. * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - protected function set_notification_data(string $key, $value, array $platforms = self::PLATFORMS): self + protected function set_notification_data(string $key, $value, array $platforms = self::PLATFORMS): static { foreach ($platforms as $platform) { @@ -207,9 +207,9 @@ protected function set_notification_data(string $key, $value, array $platforms = * @param string $key The key in the notification->platform object. * @param mixed $value The value accompanying that key. * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - protected function set_message_data(string $key, $value): self + protected function set_message_data(string $key, $value): static { $this->elements['message'][$key] = $value; @@ -222,9 +222,9 @@ protected function set_message_data(string $key, $value): self * @param string $key The key in the notification->platform object. * @param mixed $value The value accompanying that key. * - * @return JPushPayload Self Reference + * @return $this Self Reference */ - protected function set_notification_3rd_data(string $key, $value): self + protected function set_notification_3rd_data(string $key, $value): static { $this->elements['notification_3rd'][$key] = $value;