Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Lunr/Vortex/JPush/JPushBatchResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JPushBatchResponse

/**
* The statuses per endpoint.
* @var array
* @var array<string, PushNotificationStatus>
*/
private array $statuses;

Expand All @@ -53,7 +53,7 @@ class JPushBatchResponse

/**
* Notification endpoints.
* @var array
* @var string[]
*/
protected array $endpoints;

Expand Down
9 changes: 8 additions & 1 deletion src/Lunr/Vortex/JPush/JPushMessagePayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

/**
* JPush Message Payload Generator.
*
* @phpstan-type JPushMessagePayloadElements array{
* platform: string[],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform is something like "all"|array<"android","ios","quickapp","hmos">

* audience: array<string, mixed>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"all" or array{"tag":?string[], "tag_and"?:string[], "tag_not"?:string[], "alias"?:string[], "registration_id"?:string[], "segment"?:string[], "abtest"?:string[]} or array{"live_activity_id":string}

* message?: array<string, mixed>,
* options?: array<string, string|int|float|bool>
* }
*/
class JPushMessagePayload extends JPushPayload
{
Expand All @@ -35,7 +42,7 @@ public function __destruct()
/**
* Construct the payload for the push notification.
*
* @return array JPushPayload
* @return JPushMessagePayloadElements JPushPayload
*/
public function get_payload(): array
{
Expand Down
10 changes: 9 additions & 1 deletion src/Lunr/Vortex/JPush/JPushNotification3rdPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@

/**
* JPush Notification_3rd Payload Generator.
*
* @phpstan-type JPushNotification3rdPayloadElements array{
* platform: string[],
* audience: array<string, mixed>,
* notification_3rd?: array<string, mixed>,
* message?: array<string, mixed>,
* options?: array<string, string|int|float|bool>
* }
*/
class JPushNotification3rdPayload extends JPushPayload
{
Expand All @@ -34,7 +42,7 @@ public function __destruct()
/**
* Construct the payload for the push notification.
*
* @return array JPushPayload
* @return JPushNotification3rdPayloadElements JPushPayload
*/
public function get_payload(): array
{
Expand Down
9 changes: 8 additions & 1 deletion src/Lunr/Vortex/JPush/JPushNotificationPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

/**
* JPush Notification Payload Generator.
*
* @phpstan-type JPushNotificationPayloadElements array{
* platform: string[],
* audience: array<string, mixed>,
* notification?: array<string, mixed>,
* options?: array<string, string|int|float|bool>
* }
*/
class JPushNotificationPayload extends JPushPayload
{
Expand All @@ -39,7 +46,7 @@ public function __destruct()
/**
* Construct the payload for the push notification.
*
* @return array JPushPayload
* @return JPushNotificationPayloadElements JPushPayload
*/
public function get_payload(): array
{
Expand Down
33 changes: 21 additions & 12 deletions src/Lunr/Vortex/JPush/JPushPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,28 @@

/**
* JPush Payload Generator.
*
* @phpstan-type JPushPayloadElements array{
* platform: string[],
* audience: array<string, mixed>,
* notification?: array<string, mixed>,
* notification_3rd?: array<string, mixed>,
* message?: array<string, mixed>,
* options?: array<string, string|int|float|bool>
* }
*/
abstract class JPushPayload implements PushNotificationPayloadInterface
{

/**
* Array of Push Notification elements.
* @var array
* @var JPushPayloadElements
*/
protected array $elements;

/**
* Supported push platforms
* @var array
* @var string[]
*/
private const PLATFORMS = [ 'ios', 'android' ];

Expand All @@ -35,13 +44,13 @@ abstract class JPushPayload implements PushNotificationPayloadInterface
*/
public function __construct()
{
$this->elements = [];

$this->elements['platform'] = self::PLATFORMS;
$this->elements['audience'] = [];
$this->elements['notification'] = [];
$this->elements['notification_3rd'] = [];
$this->elements['message'] = [];
$this->elements = [
'platform' => self::PLATFORMS,
'audience' => [],
'notification' => [],
'notification_3rd' => [],
'message' => [],
];
}

/**
Expand All @@ -65,7 +74,7 @@ public function is_broadcast(): bool
/**
* Construct the payload for the push notification.
*
* @return array JPushPayload
* @return JPushPayloadElements JPushPayload
*/
abstract public function get_payload(): array;

Expand Down Expand Up @@ -116,7 +125,7 @@ public function set_title(string $message): static
*
* The fields of data represent the key-value pairs of the message's payload data.
*
* @param array $data The actual notification information
* @param array<string,mixed> $data The actual notification information
*
* @return $this Self Reference
*/
Expand Down Expand Up @@ -182,7 +191,7 @@ public function set_collapse_key(string $key): static
*
* @return $this Self Reference
*/
public function set_options(string $key, $value): static
public function set_options(string $key, string|int|float|bool $value): static
{
if (!isset($this->elements['options']))
{
Expand Down