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
8 changes: 4 additions & 4 deletions src/Lunr/Vortex/APNS/APNSLiveActivityPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* @phpstan-import-type APNSBasePayloadElements from APNSPayload
* @phpstan-type APNSLiveActivityPayloadElements APNSBasePayloadElements|array{
* event?: LiveActivityEvent,
* contentState?: array|object,
* contentState?: array<string, mixed>|object,
* attributesType?: string,
* attributes?: array|object,
* attributes?: array<string, mixed>|object,
* staleTime?: int,
* dismissTime?: int,
* }
Expand Down Expand Up @@ -70,7 +70,7 @@ public function set_event(LiveActivityEvent $event): self
/**
* Sets the payload key contentState.
*
* @param array|object $state The current content state for the live activity
* @param array<string, mixed>|object $state The current content state for the live activity
*
* @return self Self Reference
*/
Expand All @@ -84,7 +84,7 @@ public function set_content_state(array|object $state): self
/**
* Sets the payload key attributes.
*
* @param array|object $attributes The starting attributes for the live activity
* @param array<string, mixed>|object $attributes The starting attributes for the live activity
*
* @return self Self Reference
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Lunr/Vortex/APNS/APNSPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
* badge?: int,
* content_available?: bool,
* mutable_content?: bool,
* custom_data?: array,
* custom_data?: array<string, mixed>,
* }
*/
abstract class APNSPayload implements PushNotificationPayloadInterface
{

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

Expand All @@ -46,9 +46,9 @@ abstract class APNSPayload implements PushNotificationPayloadInterface
*/
public function __construct()
{
$this->elements = [];

$this->elements['priority'] = Priority::Immediately;
$this->elements = [
'priority' => Priority::Immediately,
];
}

/**
Expand All @@ -72,7 +72,7 @@ public function is_broadcast(): bool
/**
* Construct the payload for the push notification.
*
* @return array APNSPayload elements
* @return APNSBasePayloadElements APNSPayload elements
*/
protected function get_payload(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Lunr/Vortex/APNS/ApnsPHP/APNSDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ protected function get_new_apns_message(): Message
/**
* Push the notification.
*
* @param object $payload Payload object
* @param array $endpoints Endpoints to send to in this batch
* @param object $payload Payload object
* @param string[] $endpoints Endpoints to send to in this batch
*
* @return APNSResponse Response object
*/
Expand Down
27 changes: 18 additions & 9 deletions src/Lunr/Vortex/APNS/ApnsPHP/APNSResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@

namespace Lunr\Vortex\APNS\ApnsPHP;

use ApnsPHP\Message;
use Lunr\Vortex\PushNotificationResponseInterface;
use Lunr\Vortex\PushNotificationStatus;
use Psr\Log\LoggerInterface;

/**
* Apple Push Notification Service response wrapper.
*
* @phpstan-type APNSError array{
* MESSAGE: Message,
* ERRORS: array{
* statusCode: int,
* statusMessage: string,
* }[],
* }
Comment on lines +20 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

This should reuse the types from ApnsPHP (that's why I added them there)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I didn't see them because we use a tag that does not have the types yet. Can I point to the ApnsPHP release branch instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's fine. We can switch back to a tag on the next release

*/
class APNSResponse implements PushNotificationResponseInterface
{
Expand All @@ -42,11 +51,11 @@ class APNSResponse implements PushNotificationResponseInterface
/**
* Constructor.
*
* @param LoggerInterface $logger Shared instance of a Logger.
* @param array $endpoints The endpoints the message was sent to
* @param array $invalid_endpoints List of invalid endpoints detected before the push.
* @param array|null $errors The errors response from the APNS Push.
* @param string $payload Raw payload that was sent to APNS.
* @param LoggerInterface $logger Shared instance of a Logger.
* @param string[] $endpoints The endpoints the message was sent to
* @param string[] $invalid_endpoints List of invalid endpoints detected before the push.
* @param array<int, APNSError>|null $errors The errors response from the APNS Push.
* @param string $payload Raw payload that was sent to APNS.
*/
public function __construct(LoggerInterface $logger, array $endpoints, array $invalid_endpoints, ?array $errors, string $payload)
{
Expand Down Expand Up @@ -79,8 +88,8 @@ public function __destruct()
/**
* Define the status result for each endpoint.
*
* @param array $endpoints The endpoints the message was sent to
* @param array $errors The errors response from the APNS Push.
* @param string[] $endpoints The endpoints the message was sent to
* @param array<int, APNSError> $errors The errors response from the APNS Push.
*
* @return void
*/
Expand Down Expand Up @@ -162,7 +171,7 @@ protected function set_statuses(array $endpoints, array $errors): void
/**
* Report invalid endpoints.
*
* @param array $invalid_endpoints The invalid endpoints
* @param string[] $invalid_endpoints The invalid endpoints
*
* @return void
*/
Expand All @@ -177,7 +186,7 @@ protected function report_invalid_endpoints(array &$invalid_endpoints): void
/**
* Report an error with the push notification.
*
* @param array $endpoints The endpoints the message was sent to
* @param string[] $endpoints The endpoints the message was sent to
*
* @return void
*/
Expand Down