diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index fa9530c..df73dac 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -11,7 +11,7 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -28,10 +28,32 @@ jobs:
run: bin/phpcs --config-set show_warnings 0
- name: Check style on sources
- run: bin/phpcs --standard=vendor/escapestudios/symfony2-coding-standard/Symfony/ src/
+ run: bin/phpcs --standard=src/phpcs.xml src/
- name: Check style on tests
- run: bin/phpcs --standard=tests/phpcs-ruleset.xml tests/
+ run: bin/phpcs --standard=src/phpcs.xml tests/
+
+ phpstan:
+ name: Run PHPStan
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ coverage: "none"
+ extensions: "json"
+ php-version: "8.4"
+ tools: "composer"
+
+ - name: Install vendors
+ run: composer install --prefer-dist
+
+ - name: Run phpstan
+ run: bin/phpstan
tests:
name: Run tests
@@ -39,11 +61,11 @@ jobs:
strategy:
matrix:
- php: [ '7.2', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
+ php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -58,9 +80,3 @@ jobs:
- name: Run tests
run: bin/phpunit
-
- - name: Install vendors (lowest)
- run: composer update --prefer-lowest
-
- - name: Run tests
- run: bin/phpunit
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 7f897c2..fe1eecf 100644
--- a/composer.json
+++ b/composer.json
@@ -13,17 +13,18 @@
],
"require": {
- "php": "^7.1 | ^8.0",
+ "php": "^7.4 | ^8.0",
"ext-curl": "*",
"ext-json": "*"
},
"require-dev": {
- "phpunit/phpunit": "^8.0 | ^9.0 | ^10.0",
+ "phpunit/phpunit": "^9.0 | ^10.0",
"web-token/jwt-key-mgmt": "~2.0",
"web-token/jwt-signature": "~2.0",
"web-token/jwt-signature-algorithm-ecdsa": "~2.0",
- "phpmetrics/phpmetrics": "^2.0",
+ "phpmetrics/phpmetrics": "~2.0",
+ "phpstan/phpstan": "~2.1",
"escapestudios/symfony2-coding-standard": "~3.0",
"psr/simple-cache": "~1.0"
},
diff --git a/phpstan.neon b/phpstan.neon
new file mode 100644
index 0000000..422371b
--- /dev/null
+++ b/phpstan.neon
@@ -0,0 +1,25 @@
+parameters:
+ level: 8
+ paths:
+ - src
+
+ checkUninitializedProperties: true
+
+ ignoreErrors:
+ -
+ identifier: missingType.iterableValue
+
+ -
+ message: '/Parameter #1 \$handle of function curl_([^\s]+) expects CurlHandle, CurlHandle\|resource(\|null)? given\./'
+ path: src
+
+ -
+ message: '/Parameter #3 \$value of function curl_setopt expects (bool, int given|non-empty-string, string given)\./'
+
+ -
+ identifier: class.notFound
+ path: src/Jwt/SignatureGenerator/SignatureGeneratorFactory.php
+
+ -
+ identifier: class.notFound
+ path: src/Jwt/SignatureGenerator/SpomkyLabsJoseSignatureGenerator.php
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 2c5e295..1398d8a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,14 +1,12 @@
-
@@ -16,9 +14,9 @@
-
-
+
+
src
-
-
+
+
diff --git a/src/Certificate/Certificate.php b/src/Certificate/Certificate.php
index 7469407..4b89d9b 100644
--- a/src/Certificate/Certificate.php
+++ b/src/Certificate/Certificate.php
@@ -15,29 +15,11 @@
use Apple\ApnPush\Exception\CertificateFileNotFoundException;
-/**
- * Base certificate
- */
class Certificate implements CertificateInterface
{
- /**
- * @var string
- */
- private $path;
-
- /**
- * @var string
- */
- private $passPhrase;
+ private string $path;
+ private string $passPhrase;
- /**
- * Construct
- *
- * @param string $path
- * @param string $passPhrase
- *
- * @throws CertificateFileNotFoundException
- */
public function __construct(string $path, string $passPhrase)
{
if (!\file_exists($path) || !\is_file($path)) {
@@ -51,21 +33,11 @@ public function __construct(string $path, string $passPhrase)
$this->passPhrase = $passPhrase;
}
- /**
- * Get path
- *
- * @return string
- */
public function getPath(): string
{
return $this->path;
}
- /**
- * Get pass phrase
- *
- * @return string
- */
public function getPassPhrase(): string
{
return $this->passPhrase;
diff --git a/src/Certificate/CertificateInterface.php b/src/Certificate/CertificateInterface.php
index b88eb77..07817e1 100644
--- a/src/Certificate/CertificateInterface.php
+++ b/src/Certificate/CertificateInterface.php
@@ -13,22 +13,8 @@
namespace Apple\ApnPush\Certificate;
-/**
- * All certificate should implement this interface
- */
interface CertificateInterface
{
- /**
- * Get path
- *
- * @return string
- */
public function getPath(): string;
-
- /**
- * Get pass phrase
- *
- * @return string
- */
public function getPassPhrase(): string;
}
diff --git a/src/Certificate/ContentCertificate.php b/src/Certificate/ContentCertificate.php
index f4c4b2a..13b9f12 100644
--- a/src/Certificate/ContentCertificate.php
+++ b/src/Certificate/ContentCertificate.php
@@ -21,33 +21,11 @@
*/
class ContentCertificate implements CertificateInterface
{
- /**
- * @var string
- */
- private $content;
-
- /**
- * @var string
- */
- private $passPhrase;
-
- /**
- * @var string
- */
- private $tmpDir;
-
- /**
- * @var string
- */
- private $certificateFilePath;
-
- /**
- * Construct
- *
- * @param string $content
- * @param string $passPhrase
- * @param string $tmpDir
- */
+ private string $content;
+ private string $passPhrase;
+ private string $tmpDir;
+ private ?string $certificateFilePath = null;
+
public function __construct(string $content, string $passPhrase, string $tmpDir)
{
$this->content = $content;
@@ -55,9 +33,6 @@ public function __construct(string $content, string $passPhrase, string $tmpDir)
$this->tmpDir = $tmpDir;
}
- /**
- * {@inheritdoc}
- */
public function getPath(): string
{
if ($this->certificateFilePath) {
@@ -65,23 +40,16 @@ public function getPath(): string
}
$this->certificateFilePath = $this->createTemporaryFile();
- file_put_contents($this->certificateFilePath, $this->content);
+ \file_put_contents($this->certificateFilePath, $this->content);
return $this->certificateFilePath;
}
- /**
- * {@inheritdoc}
- */
public function getPassPhrase(): string
{
return $this->passPhrase;
}
- /**
- * Implement __destruct
- * Remove temporary file
- */
public function __destruct()
{
if ($this->certificateFilePath) {
@@ -89,13 +57,6 @@ public function __destruct()
}
}
- /**
- * Create a temporary file
- *
- * @return string Path to temporary file
- *
- * @throws \RuntimeException
- */
private function createTemporaryFile(): string
{
$tmpDir = $this->tmpDir;
@@ -106,9 +67,11 @@ private function createTemporaryFile(): string
$errorCode = $errorMessage = null;
- \set_error_handler(function ($errCode, $errMessage) use (&$errorCode, &$errorMessage) {
+ \set_error_handler(static function (int $errCode, string $errMessage) use (&$errorCode, &$errorMessage) {
$errorCode = $errCode;
$errorMessage = $errMessage;
+
+ return true;
});
if (!\file_exists($tmpDir)) {
@@ -146,15 +109,11 @@ private function createTemporaryFile(): string
return $tmpFilePath;
}
- /**
- * Remove temporary file
- *
- * @param string $filePath
- */
- private function removeTemporaryFile($filePath): void
+ private function removeTemporaryFile(string $filePath): void
{
// Set custom error handler for suppress error
- \set_error_handler(function () {
+ \set_error_handler(static function () {
+ return true;
});
\unlink($filePath);
diff --git a/src/Encoder/PayloadEncoder.php b/src/Encoder/PayloadEncoder.php
index a306781..6c10c81 100644
--- a/src/Encoder/PayloadEncoder.php
+++ b/src/Encoder/PayloadEncoder.php
@@ -18,14 +18,8 @@
use Apple\ApnPush\Model\Payload;
use Apple\ApnPush\Model\Sound;
-/**
- * The encoder for encode notification payload to string for next send to Apple Push Notification Service
- */
class PayloadEncoder implements PayloadEncoderInterface
{
- /**
- * {@inheritdoc}
- */
public function encode(Payload $payload): string
{
$data = [
@@ -34,16 +28,9 @@ public function encode(Payload $payload): string
$data = \array_merge($payload->getCustomData(), $data);
- return \json_encode($data);
+ return \json_encode($data, JSON_THROW_ON_ERROR);
}
- /**
- * Convert APS data to array
- *
- * @param Aps $aps
- *
- * @return array
- */
private function convertApsToArray(Aps $aps): array
{
$data = [];
@@ -94,13 +81,6 @@ private function convertApsToArray(Aps $aps): array
return \array_merge($aps->getCustomData(), $data);
}
- /**
- * Convert alert object to array
- *
- * @param Alert $alert
- *
- * @return array
- */
private function convertAlertToArray(Alert $alert): array
{
$data = [];
diff --git a/src/Encoder/PayloadEncoderInterface.php b/src/Encoder/PayloadEncoderInterface.php
index b9bfb3d..39233e2 100644
--- a/src/Encoder/PayloadEncoderInterface.php
+++ b/src/Encoder/PayloadEncoderInterface.php
@@ -15,9 +15,6 @@
use Apple\ApnPush\Model\Payload;
-/**
- * All payload encoder should implement this interface
- */
interface PayloadEncoderInterface
{
/**
diff --git a/src/Exception/SendNotification/BadCertificateEnvironmentException.php b/src/Exception/SendNotification/BadCertificateEnvironmentException.php
index ff8c5d5..a06359c 100644
--- a/src/Exception/SendNotification/BadCertificateEnvironmentException.php
+++ b/src/Exception/SendNotification/BadCertificateEnvironmentException.php
@@ -18,11 +18,6 @@
*/
class BadCertificateEnvironmentException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad certificate environment.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadCertificateException.php b/src/Exception/SendNotification/BadCertificateException.php
index 7e2eb42..782d25e 100644
--- a/src/Exception/SendNotification/BadCertificateException.php
+++ b/src/Exception/SendNotification/BadCertificateException.php
@@ -18,11 +18,6 @@
*/
class BadCertificateException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad certificate.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadCollapseIdException.php b/src/Exception/SendNotification/BadCollapseIdException.php
index 1fab178..224ab9e 100644
--- a/src/Exception/SendNotification/BadCollapseIdException.php
+++ b/src/Exception/SendNotification/BadCollapseIdException.php
@@ -18,11 +18,6 @@
*/
class BadCollapseIdException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad collapse id.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadDeviceTokenException.php b/src/Exception/SendNotification/BadDeviceTokenException.php
index 3118aa4..8f79b42 100644
--- a/src/Exception/SendNotification/BadDeviceTokenException.php
+++ b/src/Exception/SendNotification/BadDeviceTokenException.php
@@ -19,11 +19,6 @@
*/
class BadDeviceTokenException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad device token.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadExpirationDateException.php b/src/Exception/SendNotification/BadExpirationDateException.php
index 1cbfac7..d19528b 100644
--- a/src/Exception/SendNotification/BadExpirationDateException.php
+++ b/src/Exception/SendNotification/BadExpirationDateException.php
@@ -18,11 +18,6 @@
*/
class BadExpirationDateException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad expiration date.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadMessageIdException.php b/src/Exception/SendNotification/BadMessageIdException.php
index c958c23..e424d5d 100644
--- a/src/Exception/SendNotification/BadMessageIdException.php
+++ b/src/Exception/SendNotification/BadMessageIdException.php
@@ -18,11 +18,6 @@
*/
class BadMessageIdException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad message identifier.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadPathException.php b/src/Exception/SendNotification/BadPathException.php
index c530aa1..a6214a8 100644
--- a/src/Exception/SendNotification/BadPathException.php
+++ b/src/Exception/SendNotification/BadPathException.php
@@ -18,11 +18,6 @@
*/
class BadPathException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad path.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadPriorityException.php b/src/Exception/SendNotification/BadPriorityException.php
index 4ede3f4..175dd05 100644
--- a/src/Exception/SendNotification/BadPriorityException.php
+++ b/src/Exception/SendNotification/BadPriorityException.php
@@ -18,11 +18,6 @@
*/
class BadPriorityException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad priority.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/BadTopicException.php b/src/Exception/SendNotification/BadTopicException.php
index 35412b9..08e07ad 100644
--- a/src/Exception/SendNotification/BadTopicException.php
+++ b/src/Exception/SendNotification/BadTopicException.php
@@ -18,11 +18,6 @@
*/
class BadTopicException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Bad topic.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/DeviceTokenNotForTopicException.php b/src/Exception/SendNotification/DeviceTokenNotForTopicException.php
index 9961459..bcc8b45 100644
--- a/src/Exception/SendNotification/DeviceTokenNotForTopicException.php
+++ b/src/Exception/SendNotification/DeviceTokenNotForTopicException.php
@@ -18,11 +18,6 @@
*/
class DeviceTokenNotForTopicException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Device token not found for topic.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/DuplicateHeadersException.php b/src/Exception/SendNotification/DuplicateHeadersException.php
index 327f4e8..e816748 100644
--- a/src/Exception/SendNotification/DuplicateHeadersException.php
+++ b/src/Exception/SendNotification/DuplicateHeadersException.php
@@ -18,11 +18,6 @@
*/
class DuplicateHeadersException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Duplicate headers.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/ExpiredProviderTokenException.php b/src/Exception/SendNotification/ExpiredProviderTokenException.php
index 702098c..5f32dc6 100644
--- a/src/Exception/SendNotification/ExpiredProviderTokenException.php
+++ b/src/Exception/SendNotification/ExpiredProviderTokenException.php
@@ -18,11 +18,6 @@
*/
class ExpiredProviderTokenException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Expired provider token.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/ForbiddenException.php b/src/Exception/SendNotification/ForbiddenException.php
index d3e5ce8..23712d5 100644
--- a/src/Exception/SendNotification/ForbiddenException.php
+++ b/src/Exception/SendNotification/ForbiddenException.php
@@ -18,11 +18,6 @@
*/
class ForbiddenException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Forbidden.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/IdleTimeoutException.php b/src/Exception/SendNotification/IdleTimeoutException.php
index 01a2c3c..d71f93a 100644
--- a/src/Exception/SendNotification/IdleTimeoutException.php
+++ b/src/Exception/SendNotification/IdleTimeoutException.php
@@ -18,11 +18,6 @@
*/
class IdleTimeoutException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Idle timeout.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/InternalServerErrorException.php b/src/Exception/SendNotification/InternalServerErrorException.php
index feb032e..32c98a4 100644
--- a/src/Exception/SendNotification/InternalServerErrorException.php
+++ b/src/Exception/SendNotification/InternalServerErrorException.php
@@ -18,11 +18,6 @@
*/
class InternalServerErrorException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Internal server error.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/InvalidProviderTokenException.php b/src/Exception/SendNotification/InvalidProviderTokenException.php
index 49ac622..4d37f37 100644
--- a/src/Exception/SendNotification/InvalidProviderTokenException.php
+++ b/src/Exception/SendNotification/InvalidProviderTokenException.php
@@ -18,11 +18,6 @@
*/
class InvalidProviderTokenException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Invalid provider token.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/InvalidResponseException.php b/src/Exception/SendNotification/InvalidResponseException.php
index e077d3c..4416f53 100644
--- a/src/Exception/SendNotification/InvalidResponseException.php
+++ b/src/Exception/SendNotification/InvalidResponseException.php
@@ -18,11 +18,6 @@
*/
class InvalidResponseException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Invalid response.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/MethodNotAllowedException.php b/src/Exception/SendNotification/MethodNotAllowedException.php
index 945e0de..7c0dd86 100644
--- a/src/Exception/SendNotification/MethodNotAllowedException.php
+++ b/src/Exception/SendNotification/MethodNotAllowedException.php
@@ -18,11 +18,6 @@
*/
class MethodNotAllowedException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Method not allowed.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/MissingContentInResponseException.php b/src/Exception/SendNotification/MissingContentInResponseException.php
index 834aff9..e09048a 100644
--- a/src/Exception/SendNotification/MissingContentInResponseException.php
+++ b/src/Exception/SendNotification/MissingContentInResponseException.php
@@ -18,11 +18,6 @@
*/
class MissingContentInResponseException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Missing content in response.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/MissingDeviceTokenException.php b/src/Exception/SendNotification/MissingDeviceTokenException.php
index a8d632f..3b24121 100644
--- a/src/Exception/SendNotification/MissingDeviceTokenException.php
+++ b/src/Exception/SendNotification/MissingDeviceTokenException.php
@@ -19,11 +19,6 @@
*/
class MissingDeviceTokenException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Missing device token.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/MissingErrorReasonInResponseException.php b/src/Exception/SendNotification/MissingErrorReasonInResponseException.php
index 97001da..699df5d 100644
--- a/src/Exception/SendNotification/MissingErrorReasonInResponseException.php
+++ b/src/Exception/SendNotification/MissingErrorReasonInResponseException.php
@@ -18,11 +18,6 @@
*/
class MissingErrorReasonInResponseException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Missing error reason in response.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/MissingProviderTokenException.php b/src/Exception/SendNotification/MissingProviderTokenException.php
index c961911..4179aa2 100644
--- a/src/Exception/SendNotification/MissingProviderTokenException.php
+++ b/src/Exception/SendNotification/MissingProviderTokenException.php
@@ -19,11 +19,6 @@
*/
class MissingProviderTokenException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Missing provider token.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/MissingTopicException.php b/src/Exception/SendNotification/MissingTopicException.php
index 54c4597..5fabd86 100644
--- a/src/Exception/SendNotification/MissingTopicException.php
+++ b/src/Exception/SendNotification/MissingTopicException.php
@@ -20,11 +20,6 @@
*/
class MissingTopicException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Missing topic.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/PayloadEmptyException.php b/src/Exception/SendNotification/PayloadEmptyException.php
index b3e7787..16ea0d7 100644
--- a/src/Exception/SendNotification/PayloadEmptyException.php
+++ b/src/Exception/SendNotification/PayloadEmptyException.php
@@ -18,11 +18,6 @@
*/
class PayloadEmptyException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Payload empty.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/PayloadTooLargeException.php b/src/Exception/SendNotification/PayloadTooLargeException.php
index eb08b4a..4f21377 100644
--- a/src/Exception/SendNotification/PayloadTooLargeException.php
+++ b/src/Exception/SendNotification/PayloadTooLargeException.php
@@ -18,11 +18,6 @@
*/
class PayloadTooLargeException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Payload to large.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/ServiceUnavailableException.php b/src/Exception/SendNotification/ServiceUnavailableException.php
index 89495ad..dc80e66 100644
--- a/src/Exception/SendNotification/ServiceUnavailableException.php
+++ b/src/Exception/SendNotification/ServiceUnavailableException.php
@@ -18,11 +18,6 @@
*/
class ServiceUnavailableException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Service unavailable.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/ShutdownException.php b/src/Exception/SendNotification/ShutdownException.php
index 3bbad38..f07663b 100644
--- a/src/Exception/SendNotification/ShutdownException.php
+++ b/src/Exception/SendNotification/ShutdownException.php
@@ -18,11 +18,6 @@
*/
class ShutdownException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Shutdown.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/TooManyProviderTokenUpdatesException.php b/src/Exception/SendNotification/TooManyProviderTokenUpdatesException.php
index b51e556..ca243ab 100644
--- a/src/Exception/SendNotification/TooManyProviderTokenUpdatesException.php
+++ b/src/Exception/SendNotification/TooManyProviderTokenUpdatesException.php
@@ -18,11 +18,6 @@
*/
class TooManyProviderTokenUpdatesException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Too many provider token updates.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/TooManyRequestsException.php b/src/Exception/SendNotification/TooManyRequestsException.php
index 1eba2df..d33bb85 100644
--- a/src/Exception/SendNotification/TooManyRequestsException.php
+++ b/src/Exception/SendNotification/TooManyRequestsException.php
@@ -18,11 +18,6 @@
*/
class TooManyRequestsException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Too many requests.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/TopicDisallowedException.php b/src/Exception/SendNotification/TopicDisallowedException.php
index 45ce4fb..afd24de 100644
--- a/src/Exception/SendNotification/TopicDisallowedException.php
+++ b/src/Exception/SendNotification/TopicDisallowedException.php
@@ -18,11 +18,6 @@
*/
class TopicDisallowedException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Topic disallowed.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/UndefinedErrorException.php b/src/Exception/SendNotification/UndefinedErrorException.php
index 107d503..75c7117 100644
--- a/src/Exception/SendNotification/UndefinedErrorException.php
+++ b/src/Exception/SendNotification/UndefinedErrorException.php
@@ -18,11 +18,6 @@
*/
class UndefinedErrorException extends SendNotificationException
{
- /**
- * Constructor.
- *
- * @param string $message
- */
public function __construct(string $message = 'Undefined error.')
{
parent::__construct($message);
diff --git a/src/Exception/SendNotification/UnregisteredException.php b/src/Exception/SendNotification/UnregisteredException.php
index b6dd658..4e27062 100644
--- a/src/Exception/SendNotification/UnregisteredException.php
+++ b/src/Exception/SendNotification/UnregisteredException.php
@@ -18,30 +18,16 @@
*/
class UnregisteredException extends SendNotificationException
{
- /**
- * @var \DateTime
- */
- private $lastConfirmed;
+ private \DateTimeInterface $lastConfirmed;
- /**
- * Constructor.
- *
- * @param \DateTime $lastConfirmed
- * @param string $message
- */
- public function __construct(\DateTime $lastConfirmed, string $message = 'Unregistered.')
+ public function __construct(\DateTimeInterface $lastConfirmed, string $message = 'Unregistered.')
{
$this->lastConfirmed = $lastConfirmed;
parent::__construct($message);
}
- /**
- * Get last confirmed
- *
- * @return \DateTime
- */
- public function getLastConfirmed(): \DateTime
+ public function getLastConfirmed(): \DateTimeInterface
{
return $this->lastConfirmed;
}
diff --git a/src/Jwt/ContentJwt.php b/src/Jwt/ContentJwt.php
index 2a16cc4..5690b18 100644
--- a/src/Jwt/ContentJwt.php
+++ b/src/Jwt/ContentJwt.php
@@ -21,39 +21,12 @@
*/
class ContentJwt implements JwtInterface
{
- /**
- * @var string
- */
- private $teamId;
-
- /**
- * @var string
- */
- private $key;
-
- /**
- * @var string
- */
- private $content;
-
- /**
- * @var string
- */
- private $tmpDir;
-
- /**
- * @var string
- */
- private $certificateFilePath;
-
- /**
- * Constructor.
- *
- * @param string $teamId
- * @param string $key
- * @param string $content
- * @param string $tmpDir
- */
+ private string $teamId;
+ private string $key;
+ private string $content;
+ private string $tmpDir;
+ private ?string $certificateFilePath = null;
+
public function __construct(string $teamId, string $key, string $content, string $tmpDir)
{
$this->teamId = $teamId;
@@ -62,10 +35,6 @@ public function __construct(string $teamId, string $key, string $content, string
$this->tmpDir = $tmpDir;
}
- /**
- * Implement __destruct
- * Remove temporary file
- */
public function __destruct()
{
if ($this->certificateFilePath) {
@@ -73,25 +42,16 @@ public function __destruct()
}
}
- /**
- * {@inheritdoc}
- */
public function getTeamId(): string
{
return $this->teamId;
}
- /**
- * {@inheritdoc}
- */
public function getKey(): string
{
return $this->key;
}
- /**
- * {@inheritdoc}
- */
public function getPath(): string
{
if ($this->certificateFilePath) {
@@ -104,13 +64,6 @@ public function getPath(): string
return $this->certificateFilePath;
}
- /**
- * Create a temporary file
- *
- * @return string Path to temporary file
- *
- * @throws \RuntimeException
- */
private function createTemporaryFile(): string
{
$tmpDir = $this->tmpDir;
@@ -121,9 +74,11 @@ private function createTemporaryFile(): string
$errorCode = $errorMessage = null;
- \set_error_handler(function ($errCode, $errMessage) use (&$errorCode, &$errorMessage) {
+ \set_error_handler(static function ($errCode, $errMessage) use (&$errorCode, &$errorMessage): bool {
$errorCode = $errCode;
$errorMessage = $errMessage;
+
+ return true;
});
if (!\file_exists($tmpDir)) {
@@ -161,15 +116,11 @@ private function createTemporaryFile(): string
return $tmpFilePath;
}
- /**
- * Remove temporary file
- *
- * @param string $filePath
- */
- private function removeTemporaryFile($filePath): void
+ private function removeTemporaryFile(string $filePath): void
{
// Set custom error handler for suppress error
- \set_error_handler(function () {
+ \set_error_handler(static function () {
+ return true;
});
\unlink($filePath);
diff --git a/src/Jwt/Jwt.php b/src/Jwt/Jwt.php
index 44ef273..b766260 100644
--- a/src/Jwt/Jwt.php
+++ b/src/Jwt/Jwt.php
@@ -15,35 +15,12 @@
use Apple\ApnPush\Exception\CertificateFileNotFoundException;
-/**
- * Default Json Web Token for authenticate in provider of apn push service
- */
class Jwt implements JwtInterface
{
- /**
- * @var string
- */
- private $teamId;
-
- /**
- * @var string
- */
- private $key;
-
- /**
- * @var string
- */
- private $path;
+ private string $teamId;
+ private string $key;
+ private string $path;
- /**
- * Constructor.
- *
- * @param string $teamId
- * @param string $key
- * @param string $path
- *
- * @throws CertificateFileNotFoundException
- */
public function __construct(string $teamId, string $key, string $path)
{
if (!\file_exists($path) || !\is_file($path)) {
@@ -58,32 +35,16 @@ public function __construct(string $teamId, string $key, string $path)
$this->path = $path;
}
- /**
- * Get the identifier of team (Apple Developer)
- *
- * @return string
- */
public function getTeamId(): string
{
return $this->teamId;
}
- /**
- * Get the key of certificate
- * You can see the key of certificate in Apple Developer Center
- *
- * @return string
- */
public function getKey(): string
{
return $this->key;
}
- /**
- * Get the path to private certificate
- *
- * @return string
- */
public function getPath(): string
{
return $this->path;
diff --git a/src/Jwt/JwtInterface.php b/src/Jwt/JwtInterface.php
index 746c81c..295758a 100644
--- a/src/Jwt/JwtInterface.php
+++ b/src/Jwt/JwtInterface.php
@@ -27,6 +27,7 @@ public function getTeamId(): string;
/**
* Get the key of token
+ * You can see the key of certificate in Apple Developer Center
*
* @return string
*/
diff --git a/src/Jwt/SignatureGenerator/SignatureGeneratorFactory.php b/src/Jwt/SignatureGenerator/SignatureGeneratorFactory.php
index 74bb01f..20fdc00 100644
--- a/src/Jwt/SignatureGenerator/SignatureGeneratorFactory.php
+++ b/src/Jwt/SignatureGenerator/SignatureGeneratorFactory.php
@@ -25,7 +25,7 @@
class SignatureGeneratorFactory
{
/**
- * @var array|callable[]
+ * @var array
*/
private static $resolvers = [];
diff --git a/src/Model/Alert.php b/src/Model/Alert.php
index d871f91..a0cf585 100644
--- a/src/Model/Alert.php
+++ b/src/Model/Alert.php
@@ -13,58 +13,17 @@
namespace Apple\ApnPush\Model;
-/**
- * Value object for alert object
- */
class Alert
{
- /**
- * @var string
- */
- private $title;
-
- /**
- * @var Localized
- */
- private $titleLocalized;
-
- /**
- * @var string
- */
- private $subtitle;
-
- /**
- * @var Localized
- */
- private $subtitleLocalized;
-
- /**
- * @var string
- */
- private $body;
-
- /**
- * @var Localized
- */
- private $bodyLocalized;
-
- /**
- * @var Localized
- */
- private $actionLocalized;
-
- /**
- * @var string
- */
- private $launchImage = '';
-
- /**
- * Constructor.
- *
- * @param string $body
- * @param string $title
- * @param string $subtitle
- */
+ private string $title;
+ private Localized $titleLocalized;
+ private string $subtitle;
+ private Localized $subtitleLocalized;
+ private string $body;
+ private Localized $bodyLocalized;
+ private Localized $actionLocalized;
+ private string $launchImage = '';
+
public function __construct(string $body = '', string $title = '', string $subtitle = '')
{
$this->body = $body;
@@ -76,14 +35,7 @@ public function __construct(string $body = '', string $title = '', string $subti
$this->actionLocalized = new Localized('');
}
- /**
- * Set title
- *
- * @param string $title
- *
- * @return Alert
- */
- public function withTitle(string $title): Alert
+ public function withTitle(string $title): self
{
$cloned = clone $this;
@@ -92,14 +44,7 @@ public function withTitle(string $title): Alert
return $cloned;
}
- /**
- * With localized title
- *
- * @param Localized $localized
- *
- * @return Alert
- */
- public function withLocalizedTitle(Localized $localized): Alert
+ public function withLocalizedTitle(Localized $localized): self
{
$cloned = clone $this;
@@ -108,35 +53,17 @@ public function withLocalizedTitle(Localized $localized): Alert
return $cloned;
}
- /**
- * Get title
- *
- * @return string
- */
public function getTitle(): string
{
return $this->title;
}
- /**
- * Get localized title
- *
- * @return Localized
- */
public function getTitleLocalized(): Localized
{
return $this->titleLocalized;
}
-
- /**
- * Set subtitle
- *
- * @param string $subtitle
- *
- * @return Alert
- */
- public function withSubtitle(string $subtitle): Alert
+ public function withSubtitle(string $subtitle): self
{
$cloned = clone $this;
@@ -145,14 +72,7 @@ public function withSubtitle(string $subtitle): Alert
return $cloned;
}
- /**
- * With localized subtitle
- *
- * @param Localized $localized
- *
- * @return Alert
- */
- public function withLocalizedSubtitle(Localized $localized): Alert
+ public function withLocalizedSubtitle(Localized $localized): self
{
$cloned = clone $this;
@@ -161,33 +81,16 @@ public function withLocalizedSubtitle(Localized $localized): Alert
return $cloned;
}
- /**
- * Get subtitle
- *
- * @return string
- */
public function getSubtitle(): string
{
return $this->subtitle;
}
- /**
- * Get localized subtitle
- *
- * @return Localized
- */
public function getSubtitleLocalized(): Localized
{
return $this->subtitleLocalized;
}
- /**
- * Set body
- *
- * @param string $body
- *
- * @return Alert
- */
public function withBody(string $body): Alert
{
$cloned = clone $this;
@@ -197,14 +100,7 @@ public function withBody(string $body): Alert
return $cloned;
}
- /**
- * Set localized body
- *
- * @param Localized $localized
- *
- * @return Alert
- */
- public function withBodyLocalized(Localized $localized): Alert
+ public function withBodyLocalized(Localized $localized): self
{
$cloned = clone $this;
@@ -213,34 +109,17 @@ public function withBodyLocalized(Localized $localized): Alert
return $cloned;
}
- /**
- * Get localized body
- *
- * @return Localized
- */
public function getBodyLocalized(): Localized
{
return $this->bodyLocalized;
}
- /**
- * Get body
- *
- * @return string
- */
public function getBody(): string
{
return $this->body;
}
- /**
- * With localized action
- *
- * @param Localized $localized
- *
- * @return Alert
- */
- public function withActionLocalized(Localized $localized): Alert
+ public function withActionLocalized(Localized $localized): self
{
$cloned = clone $this;
@@ -249,24 +128,12 @@ public function withActionLocalized(Localized $localized): Alert
return $cloned;
}
- /**
- * Get localized action
- *
- * @return Localized
- */
public function getActionLocalized(): Localized
{
return $this->actionLocalized;
}
- /**
- * Add launch image
- *
- * @param string $launchImage
- *
- * @return Alert
- */
- public function withLaunchImage(string $launchImage): Alert
+ public function withLaunchImage(string $launchImage): self
{
$cloned = clone $this;
@@ -275,11 +142,6 @@ public function withLaunchImage(string $launchImage): Alert
return $cloned;
}
- /**
- * Get launch image
- *
- * @return string
- */
public function getLaunchImage(): string
{
return $this->launchImage;
diff --git a/src/Model/ApnId.php b/src/Model/ApnId.php
index 735b11a..e1969b5 100644
--- a/src/Model/ApnId.php
+++ b/src/Model/ApnId.php
@@ -18,18 +18,8 @@
*/
class ApnId
{
- /**
- * @var string
- */
- private $value;
+ private string $value;
- /**
- * Constructor.
- *
- * @param string $value
- *
- * @throws \InvalidArgumentException
- */
public function __construct(string $value)
{
if (!\preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $value)) {
@@ -42,11 +32,6 @@ public function __construct(string $value)
$this->value = $value;
}
- /**
- * Get value
- *
- * @return string
- */
public function getValue(): string
{
return $this->value;
diff --git a/src/Model/Aps.php b/src/Model/Aps.php
index 77fea1a..2d2e4ee 100644
--- a/src/Model/Aps.php
+++ b/src/Model/Aps.php
@@ -13,76 +13,29 @@
namespace Apple\ApnPush\Model;
-/**
- * Default APS data
- */
class Aps
{
- /**
- * @var Alert
- */
- private $alert;
-
- /**
- * @var int|null
- */
- private $badge = null;
+ private ?Alert $alert;
+ private ?int $badge = null;
+ private bool $contentAvailable = false;
+ private bool $mutableContent = false;
+ private string $category = '';
+ private string $threadId = '';
+ private array $customData;
+ private ?array $urlArgs = null;
/**
* @var string|Sound
*/
private $sound = '';
- /**
- * @var bool
- */
- private $contentAvailable = false;
-
- /**
- * @var bool
- */
- private $mutableContent = false;
-
- /**
- * @var string
- */
- private $category = '';
-
- /**
- * @var string
- */
- private $threadId = '';
-
- /**
- * @var string[]|null
- */
- private $urlArgs = null;
-
- /**
- * @var array
- */
- private $customData;
-
- /**
- * Constructor.
- *
- * @param Alert|null $alert
- * @param array $customData
- */
public function __construct(?Alert $alert = null, array $customData = [])
{
$this->alert = $alert;
$this->customData = $customData;
}
- /**
- * Set alert
- *
- * @param Alert $alert
- *
- * @return Aps
- */
- public function withAlert(Alert $alert): Aps
+ public function withAlert(Alert $alert): self
{
$cloned = clone $this;
@@ -91,24 +44,12 @@ public function withAlert(Alert $alert): Aps
return $cloned;
}
- /**
- * Get alert data
- *
- * @return Alert
- */
public function getAlert(): ?Alert
{
return $this->alert;
}
- /**
- * Set category
- *
- * @param string $category
- *
- * @return Aps
- */
- public function withCategory(string $category): Aps
+ public function withCategory(string $category): self
{
$cloned = clone $this;
@@ -117,24 +58,19 @@ public function withCategory(string $category): Aps
return $cloned;
}
- /**
- * Get category
- *
- * @return string
- */
public function getCategory(): string
{
return $this->category;
}
/**
- * Set sound
+ * Set sound for APS
*
- * @param string|Sound $sound
+ * @param string|Sound|mixed $sound
*
- * @return Aps
+ * @return self
*/
- public function withSound($sound): Aps
+ public function withSound($sound): self
{
if (!\is_string($sound) && !$sound instanceof Sound) {
throw new \InvalidArgumentException(\sprintf(
@@ -152,49 +88,30 @@ public function withSound($sound): Aps
}
/**
- * Get sound
+ * Get sound for APS
*
- * @return string|Sound
+ * @return Sound|string
*/
public function getSound()
{
return $this->sound;
}
- /**
- * Set badge
- *
- * @param int $badge
- *
- * @return Aps
- */
- public function withBadge(int $badge): Aps
+ public function withBadge(int $badge): self
{
$cloned = clone $this;
- $cloned->badge = (int) $badge;
+ $cloned->badge = $badge;
return $cloned;
}
- /**
- * Get badge
- *
- * @return int|null
- */
public function getBadge(): ?int
{
return $this->badge;
}
- /**
- * Set content available option
- *
- * @param bool $contentAvailable
- *
- * @return Aps
- */
- public function withContentAvailable(bool $contentAvailable): Aps
+ public function withContentAvailable(bool $contentAvailable): self
{
$cloned = clone $this;
@@ -203,24 +120,12 @@ public function withContentAvailable(bool $contentAvailable): Aps
return $cloned;
}
- /**
- * Get content available option
- *
- * @return bool
- */
public function isContentAvailable(): bool
{
return $this->contentAvailable;
}
- /**
- * Set mutable content option
- *
- * @param bool $mutableContent
- *
- * @return Aps
- */
- public function withMutableContent(bool $mutableContent): Aps
+ public function withMutableContent(bool $mutableContent): self
{
$cloned = clone $this;
@@ -229,24 +134,12 @@ public function withMutableContent(bool $mutableContent): Aps
return $cloned;
}
- /**
- * Get mutable content option
- *
- * @return bool
- */
public function isMutableContent(): bool
{
return $this->mutableContent;
}
- /**
- * Set thread id
- *
- * @param string $threadId
- *
- * @return Aps
- */
- public function withThreadId(string $threadId): Aps
+ public function withThreadId(string $threadId): self
{
$cloned = clone $this;
@@ -255,24 +148,12 @@ public function withThreadId(string $threadId): Aps
return $cloned;
}
- /**
- * Get thread id
- *
- * @return string
- */
public function getThreadId(): string
{
return $this->threadId;
}
- /**
- * Set url arguments
- *
- * @param array $urlArgs
- *
- * @return Aps
- */
- public function withUrlArgs(array $urlArgs): Aps
+ public function withUrlArgs(array $urlArgs): self
{
$cloned = clone $this;
@@ -281,37 +162,25 @@ public function withUrlArgs(array $urlArgs): Aps
return $cloned;
}
- /**
- * Get url arguments
- *
- * @return string[]|null
- */
public function getUrlArgs(): ?array
{
return $this->urlArgs;
}
- /**
- * Get custom data
- *
- * @return array
- */
public function getCustomData(): array
{
return $this->customData;
}
/**
- * Add or replace custom data
+ * Set or replace custom data by name
*
* @param string $name
* @param mixed $value
*
- * @return Aps
- *
- * @throws \InvalidArgumentException
+ * @return self
*/
- public function withCustomData(string $name, $value): Aps
+ public function withCustomData(string $name, $value): self
{
if ($value && !is_array($value) && !is_scalar($value) && !$value instanceof \JsonSerializable) {
throw new \InvalidArgumentException(sprintf(
diff --git a/src/Model/CollapseId.php b/src/Model/CollapseId.php
index 8d8b034..e526d38 100644
--- a/src/Model/CollapseId.php
+++ b/src/Model/CollapseId.php
@@ -13,23 +13,10 @@
namespace Apple\ApnPush\Model;
-/**
- * The value object for store the apns-collapse-id
- */
class CollapseId
{
- /**
- * @var string
- */
- private $value;
+ private string $value;
- /**
- * Constructor.
- *
- * @param string $value
- *
- * @throws \InvalidArgumentException
- */
public function __construct(string $value)
{
if (\strlen($value) > 64) {
@@ -39,11 +26,6 @@ public function __construct(string $value)
$this->value = $value;
}
- /**
- * Get the value of collapse id
- *
- * @return string
- */
public function getValue(): string
{
return $this->value;
diff --git a/src/Model/DeviceToken.php b/src/Model/DeviceToken.php
index 6a3fb38..eb35c43 100644
--- a/src/Model/DeviceToken.php
+++ b/src/Model/DeviceToken.php
@@ -13,23 +13,10 @@
namespace Apple\ApnPush\Model;
-/**
- * Device token model
- */
class DeviceToken
{
- /**
- * @var string
- */
- private $value;
-
- /**
- * Constructor.
- *
- * @param string $token
- *
- * @throws \InvalidArgumentException
- */
+ private string $value;
+
public function __construct(string $token)
{
if (!\preg_match('/^[0-9a-fA-F]+$/', $token)) {
@@ -42,19 +29,11 @@ public function __construct(string $token)
$this->value = $token;
}
- /**
- * Get token value
- *
- * @return string
- */
public function getValue(): string
{
return $this->value;
}
- /**
- * {@inheritdoc}
- */
public function __toString()
{
return $this->value;
diff --git a/src/Model/Expiration.php b/src/Model/Expiration.php
index e7cc4f2..596c06c 100644
--- a/src/Model/Expiration.php
+++ b/src/Model/Expiration.php
@@ -13,36 +13,18 @@
namespace Apple\ApnPush\Model;
-/**
- * Expiration of notification
- */
class Expiration
{
- /**
- * @var \DateTime
- */
- private $storeTo;
+ private ?\DateTimeInterface $storeTo = null;
- /**
- * Constructor.
- *
- * @param \DateTime|null $availableTo
- */
- public function __construct(?\DateTime $availableTo = null)
+ public function __construct(?\DateTimeInterface $availableTo = null)
{
if ($availableTo) {
- $this->storeTo = clone $availableTo;
+ $this->storeTo = new \DateTime($availableTo->format(\DateTimeInterface::ATOM));
$this->storeTo->setTimezone(new \DateTimeZone('UTC'));
}
}
- /**
- * Get value
- *
- * @return int
- *
- * @throws \LogicException
- */
public function getValue(): int
{
if (!$this->storeTo) {
diff --git a/src/Model/Localized.php b/src/Model/Localized.php
index 1417fbe..1eae262 100644
--- a/src/Model/Localized.php
+++ b/src/Model/Localized.php
@@ -13,48 +13,22 @@
namespace Apple\ApnPush\Model;
-/**
- * Value object for store localized information
- */
class Localized
{
- /**
- * @var string
- */
- protected $key;
-
- /**
- * @var array
- */
- protected $args;
+ protected string $key;
+ protected array $args;
- /**
- * Constructor.
- *
- * @param string $key
- * @param array $args
- */
public function __construct(string $key, array $args = [])
{
$this->key = $key;
$this->args = $args;
}
- /**
- * Get localized key
- *
- * @return string
- */
public function getKey(): string
{
return $this->key;
}
- /**
- * Get localized args
- *
- * @return array
- */
public function getArgs(): array
{
return $this->args;
diff --git a/src/Model/Notification.php b/src/Model/Notification.php
index 160bc67..6dd41a9 100644
--- a/src/Model/Notification.php
+++ b/src/Model/Notification.php
@@ -13,51 +13,15 @@
namespace Apple\ApnPush\Model;
-/**
- * Send this notification to device.
- */
class Notification
{
- /**
- * @var Payload
- */
- private $payload;
-
- /**
- * @var ApnId
- */
- private $apnId;
-
- /**
- * @var Priority
- */
- private $priority;
-
- /**
- * @var Expiration
- */
- private $expiration;
-
- /**
- * @var CollapseId
- */
- private $collapseId;
-
- /**
- * @var PushType
- */
- private $pushType;
-
- /**
- * Constructor.
- *
- * @param Payload $payload
- * @param ApnId|null $apnId
- * @param Priority|null $priority
- * @param Expiration|null $expiration
- * @param CollapseId|null $collapseId
- * @param PushType|null $pushType
- */
+ private Payload $payload;
+ private ?ApnId $apnId;
+ private ?Priority $priority;
+ private ?Expiration $expiration;
+ private ?CollapseId $collapseId;
+ private ?PushType $pushType;
+
public function __construct(Payload $payload, ?ApnId $apnId = null, ?Priority $priority = null, ?Expiration $expiration = null, ?CollapseId $collapseId = null, ?PushType $pushType = null)
{
$this->payload = $payload;
@@ -68,26 +32,12 @@ public function __construct(Payload $payload, ?ApnId $apnId = null, ?Priority $p
$this->pushType = $pushType;
}
- /**
- * Create new notification with body only
- *
- * @param string $body
- *
- * @return Notification
- */
- public static function createWithBody(string $body): Notification
+ public static function createWithBody(string $body): self
{
return new self(Payload::createWithBody($body));
}
- /**
- * Set payload
- *
- * @param Payload $payload
- *
- * @return Notification
- */
- public function withPayload(Payload $payload): Notification
+ public function withPayload(Payload $payload): self
{
$cloned = clone $this;
@@ -96,24 +46,12 @@ public function withPayload(Payload $payload): Notification
return $cloned;
}
- /**
- * Get payload
- *
- * @return Payload
- */
public function getPayload(): Payload
{
return $this->payload;
}
- /**
- * Set apn identifier
- *
- * @param ApnId|null $apnId
- *
- * @return Notification
- */
- public function withApnId(?ApnId $apnId = null): Notification
+ public function withApnId(?ApnId $apnId = null): self
{
$cloned = clone $this;
@@ -122,24 +60,12 @@ public function withApnId(?ApnId $apnId = null): Notification
return $cloned;
}
- /**
- * Get identifier of notification
- *
- * @return ApnId
- */
public function getApnId(): ?ApnId
{
return $this->apnId;
}
- /**
- * Set priority
- *
- * @param Priority|null $priority
- *
- * @return Notification
- */
- public function withPriority(?Priority $priority = null): Notification
+ public function withPriority(?Priority $priority = null): self
{
$cloned = clone $this;
@@ -148,24 +74,12 @@ public function withPriority(?Priority $priority = null): Notification
return $cloned;
}
- /**
- * Get priority
- *
- * @return Priority
- */
public function getPriority(): ?Priority
{
return $this->priority;
}
- /**
- * Set expiration
- *
- * @param Expiration|null $expiration
- *
- * @return Notification
- */
- public function withExpiration(?Expiration $expiration = null): Notification
+ public function withExpiration(?Expiration $expiration = null): self
{
$cloned = clone $this;
@@ -174,24 +88,12 @@ public function withExpiration(?Expiration $expiration = null): Notification
return $cloned;
}
- /**
- * Get expiration
- *
- * @return Expiration
- */
public function getExpiration(): ?Expiration
{
return $this->expiration;
}
- /**
- * Set the collapse identifier
- *
- * @param CollapseId|null $collapseId
- *
- * @return Notification
- */
- public function withCollapseId(?CollapseId $collapseId = null): Notification
+ public function withCollapseId(?CollapseId $collapseId = null): self
{
$cloned = clone $this;
@@ -200,24 +102,12 @@ public function withCollapseId(?CollapseId $collapseId = null): Notification
return $cloned;
}
- /**
- * Get the collapse identifier
- *
- * @return CollapseId|null
- */
public function getCollapseId(): ?CollapseId
{
return $this->collapseId;
}
- /**
- * Set the push type
- *
- * @param PushType|null $pushType
- *
- * @return Notification
- */
- public function withPushType(?PushType $pushType): Notification
+ public function withPushType(?PushType $pushType): self
{
$cloned = clone $this;
@@ -226,11 +116,6 @@ public function withPushType(?PushType $pushType): Notification
return $cloned;
}
- /**
- * Get the push type
- *
- * @return PushType|null
- */
public function getPushType(): ?PushType
{
return $this->pushType;
diff --git a/src/Model/Payload.php b/src/Model/Payload.php
index 380f31e..7d2075b 100644
--- a/src/Model/Payload.php
+++ b/src/Model/Payload.php
@@ -13,52 +13,22 @@
namespace Apple\ApnPush\Model;
-/**
- * Payload model
- */
class Payload
{
- /**
- * @var Aps
- */
- private $aps;
-
- /**
- * @var array
- */
- private $customData;
+ private Aps $aps;
+ private array $customData;
- /**
- * Constructor.
- *
- * @param Aps $apsData
- * @param array $customData
- */
public function __construct(Aps $apsData, array $customData = [])
{
$this->aps = $apsData;
$this->customData = $customData;
}
- /**
- * Create new payload with body only.
- *
- * @param string $body
- *
- * @return Payload
- */
- public static function createWithBody(string $body): Payload
+ public static function createWithBody(string $body): self
{
return new self(new Aps(new Alert($body)));
}
- /**
- * Set aps
- *
- * @param Aps $aps
- *
- * @return Payload
- */
public function withAps(Aps $aps): Payload
{
$cloned = clone $this;
@@ -68,32 +38,25 @@ public function withAps(Aps $aps): Payload
return $cloned;
}
- /**
- * Get APS data
- *
- * @return Aps
- */
public function getAps(): Aps
{
return $this->aps;
}
/**
- * Add or replace custom data
+ * Add or replace custom data by name
*
* @param string $name
* @param mixed $value
*
- * @return Payload
- *
- * @throws \InvalidArgumentException
+ * @return self
*/
- public function withCustomData(string $name, $value): Payload
+ public function withCustomData(string $name, $value): self
{
- if ($value && !is_array($value) && !is_scalar($value) && !$value instanceof \JsonSerializable) {
+ if ($value && !\is_array($value) && !\is_scalar($value) && !$value instanceof \JsonSerializable) {
throw new \InvalidArgumentException(sprintf(
'The custom data value should be a scalar or \JsonSerializable instance, but "%s" given.',
- is_object($value) ? get_class($value) : gettype($value)
+ \is_object($value) ? \get_class($value) : \gettype($value)
));
}
@@ -104,11 +67,6 @@ public function withCustomData(string $name, $value): Payload
return $cloned;
}
- /**
- * Get custom data
- *
- * @return array
- */
public function getCustomData(): array
{
return $this->customData;
diff --git a/src/Model/Priority.php b/src/Model/Priority.php
index 44cc50a..7e16c78 100644
--- a/src/Model/Priority.php
+++ b/src/Model/Priority.php
@@ -13,23 +13,10 @@
namespace Apple\ApnPush\Model;
-/**
- * Message priority
- */
class Priority
{
- /**
- * @var int
- */
- private $value;
+ private int $value;
- /**
- * Constructor.
- *
- * @param int $priority
- *
- * @throws \InvalidArgumentException
- */
public function __construct(int $priority)
{
if (!\in_array($priority, [5, 10], true)) {
@@ -42,31 +29,16 @@ public function __construct(int $priority)
$this->value = $priority;
}
- /**
- * Create immediately priority
- *
- * @return Priority
- */
- public static function immediately(): Priority
+ public static function immediately(): self
{
return new self(10);
}
- /**
- * Create priority with power considerations
- *
- * @return Priority
- */
- public static function powerConsiderations(): Priority
+ public static function powerConsiderations(): self
{
return new self(5);
}
- /**
- * Get value
- *
- * @return int
- */
public function getValue(): int
{
return $this->value;
diff --git a/src/Model/PushType.php b/src/Model/PushType.php
index 380152a..df3a671 100644
--- a/src/Model/PushType.php
+++ b/src/Model/PushType.php
@@ -14,7 +14,6 @@
namespace Apple\ApnPush\Model;
/**
- * The type of the notification
* @see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns
*/
final class PushType
@@ -23,51 +22,28 @@ final class PushType
const TYPE_BACKGROUND = 'background';
const TYPE_LIVEACTIVITY = 'liveactivity';
- private $value;
+ private string $value;
- /**
- * Create alert push-type
- *
- * @return PushType
- */
- public static function alert(): PushType
+ public static function alert(): self
{
return new self(self::TYPE_ALERT);
}
- /**
- * Create background push-type
- *
- * @return PushType
- */
- public static function background(): PushType
+ public static function background(): self
{
return new self(self::TYPE_BACKGROUND);
}
- /**
- * Create liveactivity push-type
- *
- * @return PushType
- */
- public static function liveactivity(): PushType
+ public static function liveactivity(): self
{
return new self(self::TYPE_LIVEACTIVITY);
}
- /**
- * @return string
- */
public function __toString(): string
{
return $this->value;
}
- /**
- * @param string $type
- *
- * @throws \InvalidArgumentException
- */
private function __construct(string $type)
{
if (!\in_array($type, [self::TYPE_ALERT, self::TYPE_BACKGROUND, self::TYPE_LIVEACTIVITY], true)) {
diff --git a/src/Model/Receiver.php b/src/Model/Receiver.php
index 96c1414..d2c6023 100644
--- a/src/Model/Receiver.php
+++ b/src/Model/Receiver.php
@@ -13,49 +13,22 @@
namespace Apple\ApnPush\Model;
-/**
- * The receiver model.
- * Store device token and topic (application).
- */
class Receiver
{
- /**
- * @var DeviceToken
- */
- private $token;
-
- /**
- * @var string
- */
- private $topic;
+ private DeviceToken $token;
+ private string $topic;
- /**
- * Constructor.
- *
- * @param DeviceToken $token
- * @param string $topic
- */
public function __construct(DeviceToken $token, string $topic)
{
$this->token = $token;
$this->topic = $topic;
}
- /**
- * Get token
- *
- * @return DeviceToken
- */
public function getToken(): DeviceToken
{
return $this->token;
}
- /**
- * Get topic
- *
- * @return string
- */
public function getTopic(): string
{
return $this->topic;
diff --git a/src/Model/Sound.php b/src/Model/Sound.php
index 0e50b5d..245b8bb 100644
--- a/src/Model/Sound.php
+++ b/src/Model/Sound.php
@@ -13,33 +13,12 @@
namespace Apple\ApnPush\Model;
-/**
- * Value object for store sound object
- */
class Sound
{
- /**
- * @var bool
- */
- private $critical;
-
- /**
- * @var string
- */
- private $name;
-
- /**
- * @var float
- */
- private $volume;
+ private bool $critical;
+ private string $name;
+ private float $volume;
- /**
- * Constructor.
- *
- * @param string $name
- * @param float|int $volume
- * @param bool $critical
- */
public function __construct(string $name, float $volume = 1.0, bool $critical = false)
{
if ($volume < 0 || $volume > 1) {
@@ -54,31 +33,16 @@ public function __construct(string $name, float $volume = 1.0, bool $critical =
$this->critical = $critical;
}
- /**
- * Is critical?
- *
- * @return bool
- */
public function isCritical(): bool
{
return $this->critical;
}
- /**
- * Get the name of volume
- *
- * @return string
- */
public function getName(): string
{
return $this->name;
}
- /**
- * Get the volume
- *
- * @return float
- */
public function getVolume(): float
{
return $this->volume;
diff --git a/src/Protocol/Http/Authenticator/AuthenticatorInterface.php b/src/Protocol/Http/Authenticator/AuthenticatorInterface.php
index ad11eac..0b7fbc9 100644
--- a/src/Protocol/Http/Authenticator/AuthenticatorInterface.php
+++ b/src/Protocol/Http/Authenticator/AuthenticatorInterface.php
@@ -15,17 +15,7 @@
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * All HTTP authenticators should implement this interface
- */
interface AuthenticatorInterface
{
- /**
- * Authenticate request
- *
- * @param Request $request
- *
- * @return Request
- */
public function authenticate(Request $request): Request;
}
diff --git a/src/Protocol/Http/Authenticator/CertificateAuthenticator.php b/src/Protocol/Http/Authenticator/CertificateAuthenticator.php
index bc22e62..e4cf58c 100644
--- a/src/Protocol/Http/Authenticator/CertificateAuthenticator.php
+++ b/src/Protocol/Http/Authenticator/CertificateAuthenticator.php
@@ -21,24 +21,13 @@
*/
class CertificateAuthenticator implements AuthenticatorInterface
{
- /**
- * @var CertificateInterface
- */
- private $certificate;
-
- /**
- * Constructor.
- *
- * @param CertificateInterface $certificate
- */
+ private CertificateInterface$certificate;
+
public function __construct(CertificateInterface $certificate)
{
$this->certificate = $certificate;
}
- /**
- * {@inheritdoc}
- */
public function authenticate(Request $request): Request
{
$request = $request->withCertificate($this->certificate->getPath());
diff --git a/src/Protocol/Http/Authenticator/JwtAuthenticator.php b/src/Protocol/Http/Authenticator/JwtAuthenticator.php
index 18ed8a1..a198ce0 100644
--- a/src/Protocol/Http/Authenticator/JwtAuthenticator.php
+++ b/src/Protocol/Http/Authenticator/JwtAuthenticator.php
@@ -23,57 +23,23 @@
*/
class JwtAuthenticator implements AuthenticatorInterface
{
- /**
- * @var JwtInterface
- */
- private $jwt;
+ private JwtInterface $jwt;
+ private SignatureGeneratorInterface $signatureGenerator;
+ private ?\DateInterval $jwsLifetime;
+ private ?string $jws = null;
+ private ?\DateTimeInterface $jwsValidTo = null;
- /**
- * @var SignatureGeneratorInterface
- */
- private $signatureGenerator;
-
- /**
- * @var string
- */
- private $jws;
-
- /**
- * @var \DateInterval
- */
- private $jwsLifetime;
-
- /**
- * @var \DateTime
- */
- private $jwsValidTo;
-
- /**
- * Constructor.
- *
- * @param JwtInterface $jwt
- * @param \DateInterval|null $jwsLifetime
- * @param SignatureGeneratorInterface|null $signatureGenerator
- *
- * @throws \InvalidArgumentException
- * @throws \LogicException
- */
public function __construct(JwtInterface $jwt, ?\DateInterval $jwsLifetime = null, ?SignatureGeneratorInterface $signatureGenerator = null)
{
- $this->jwt = $jwt;
-
if ($jwsLifetime && $jwsLifetime->invert) {
throw new \InvalidArgumentException('JWS lifetime must not be inverted');
}
+ $this->jwt = $jwt;
$this->jwsLifetime = $jwsLifetime;
-
$this->signatureGenerator = $signatureGenerator ?: SignatureGeneratorFactory::resolve();
}
- /**
- * {@inheritdoc}
- */
public function authenticate(Request $request): Request
{
$now = new \DateTimeImmutable();
@@ -83,6 +49,6 @@ public function authenticate(Request $request): Request
$this->jwsValidTo = $this->jwsLifetime ? ($now)->add($this->jwsLifetime) : $this->jwsValidTo;
}
- return $request->withHeader('authorization', sprintf('bearer %s', $this->jws));
+ return $request->withHeader('authorization', \sprintf('bearer %s', $this->jws));
}
}
diff --git a/src/Protocol/Http/ExceptionFactory/ExceptionFactory.php b/src/Protocol/Http/ExceptionFactory/ExceptionFactory.php
index 6d01013..4640dd4 100644
--- a/src/Protocol/Http/ExceptionFactory/ExceptionFactory.php
+++ b/src/Protocol/Http/ExceptionFactory/ExceptionFactory.php
@@ -54,9 +54,6 @@
*/
class ExceptionFactory implements ExceptionFactoryInterface
{
- /**
- * {@inheritdoc}
- */
public function create(Response $response): SendNotificationException
{
$content = $response->getContent();
@@ -84,14 +81,6 @@ public function create(Response $response): SendNotificationException
return $this->createByReason($reason, $json);
}
- /**
- * Create exception by reason
- *
- * @param string $reason
- * @param array $json
- *
- * @return SendNotificationException
- */
private function createByReason(string $reason, array $json): SendNotificationException
{
$reason = \strtolower($reason);
@@ -162,8 +151,8 @@ private function createByReason(string $reason, array $json): SendNotificationEx
case 'unregistered':
$timestamp = \array_key_exists('timestamp', $json) ? $json['timestamp'] : 0;
- $lastConfirmed = new \DateTime('now', new \DateTimeZone('UTC'));
- $lastConfirmed->setTimestamp($timestamp);
+ $lastConfirmed = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
+ $lastConfirmed = $lastConfirmed->setTimestamp($timestamp);
return new UnregisteredException($lastConfirmed);
diff --git a/src/Protocol/Http/ExceptionFactory/ExceptionFactoryInterface.php b/src/Protocol/Http/ExceptionFactory/ExceptionFactoryInterface.php
index 7c26cb1..a155bf8 100644
--- a/src/Protocol/Http/ExceptionFactory/ExceptionFactoryInterface.php
+++ b/src/Protocol/Http/ExceptionFactory/ExceptionFactoryInterface.php
@@ -16,17 +16,7 @@
use Apple\ApnPush\Exception\SendNotification\SendNotificationException;
use Apple\ApnPush\Protocol\Http\Response;
-/**
- * All exception factories for convert response to exception should implement this interface
- */
interface ExceptionFactoryInterface
{
- /**
- * Create new exception by response
- *
- * @param Response $response
- *
- * @return SendNotificationException
- */
public function create(Response $response): SendNotificationException;
}
diff --git a/src/Protocol/Http/Request.php b/src/Protocol/Http/Request.php
index 3dc4494..73bfc61 100644
--- a/src/Protocol/Http/Request.php
+++ b/src/Protocol/Http/Request.php
@@ -13,43 +13,14 @@
namespace Apple\ApnPush\Protocol\Http;
-/**
- * Object for presentation http request
- */
class Request
{
- /**
- * @var string
- */
- private $url;
-
- /**
- * @var array
- */
- private $headers;
-
- /**
- * @var string
- */
- private $content;
-
- /**
- * @var string
- */
- private $certificate = '';
-
- /**
- * @var string
- */
- private $certificatePassPhrase = '';
-
- /**
- * Constructor.
- *
- * @param string $url
- * @param string $content
- * @param array $headers
- */
+ private string $url;
+ private array $headers;
+ private string $content;
+ private string $certificate = '';
+ private string $certificatePassPhrase = '';
+
public function __construct(string $url, string $content, array $headers = [])
{
$this->url = $url;
@@ -57,25 +28,12 @@ public function __construct(string $url, string $content, array $headers = [])
$this->content = $content;
}
- /**
- * Get url
- *
- * @return string
- */
public function getUrl(): string
{
return $this->url;
}
- /**
- * Add or replace header
- *
- * @param string $name
- * @param string $value
- *
- * @return Request
- */
- public function withHeader(string $name, string $value): Request
+ public function withHeader(string $name, string $value): self
{
$cloned = clone $this;
@@ -84,14 +42,7 @@ public function withHeader(string $name, string $value): Request
return $cloned;
}
- /**
- * Add multiple headers
- *
- * @param array $headers
- *
- * @return Request
- */
- public function withHeaders(array $headers): Request
+ public function withHeaders(array $headers): self
{
$cloned = clone $this;
@@ -102,34 +53,17 @@ public function withHeaders(array $headers): Request
return $cloned;
}
- /**
- * Get headers
- *
- * @return array
- */
public function getHeaders(): array
{
return $this->headers;
}
- /**
- * Get content
- *
- * @return string
- */
public function getContent(): string
{
return $this->content;
}
- /**
- * Use certificate for send request
- *
- * @param string $certificate
- *
- * @return Request
- */
- public function withCertificate(string $certificate): Request
+ public function withCertificate(string $certificate): self
{
$cloned = clone $this;
@@ -138,24 +72,12 @@ public function withCertificate(string $certificate): Request
return $cloned;
}
- /**
- * Get certificate
- *
- * @return string
- */
public function getCertificate(): string
{
return $this->certificate;
}
- /**
- * Use pass phrase of certificate for send request
- *
- * @param string $passPhrase
- *
- * @return Request
- */
- public function withCertificatePassPhrase(string $passPhrase): Request
+ public function withCertificatePassPhrase(string $passPhrase): self
{
$cloned = clone $this;
@@ -164,11 +86,6 @@ public function withCertificatePassPhrase(string $passPhrase): Request
return $cloned;
}
- /**
- * Get certificate pass phrase
- *
- * @return string
- */
public function getCertificatePassPhrase(): string
{
return $this->certificatePassPhrase;
diff --git a/src/Protocol/Http/Response.php b/src/Protocol/Http/Response.php
index 2adfd1d..e5764a7 100644
--- a/src/Protocol/Http/Response.php
+++ b/src/Protocol/Http/Response.php
@@ -13,48 +13,22 @@
namespace Apple\ApnPush\Protocol\Http;
-/**
- * Object for presentation http response
- */
class Response
{
- /**
- * @var int
- */
- private $statusCode;
-
- /**
- * @var string
- */
- private $content;
+ private int $statusCode;
+ private string $content;
- /**
- * Constructor.
- *
- * @param int $statusCode
- * @param string $content
- */
public function __construct(int $statusCode, string $content)
{
$this->statusCode = $statusCode;
$this->content = $content;
}
- /**
- * Get status code
- *
- * @return int
- */
public function getStatusCode(): int
{
return $this->statusCode;
}
- /**
- * Get content
- *
- * @return string
- */
public function getContent(): string
{
return $this->content;
diff --git a/src/Protocol/Http/Sender/CurlHttpSender.php b/src/Protocol/Http/Sender/CurlHttpSender.php
index b917de5..a0c7197 100644
--- a/src/Protocol/Http/Sender/CurlHttpSender.php
+++ b/src/Protocol/Http/Sender/CurlHttpSender.php
@@ -23,15 +23,10 @@
class CurlHttpSender implements HttpSenderInterface
{
/**
- * @var resource|\CurlHandle
+ * @var resource|\CurlHandle|null
*/
- private $resource;
+ private $resource; // @phpstan-ignore-line property.unusedType
- /**
- * {@inheritdoc}
- *
- * @throws HttpSenderException
- */
public function send(Request $request): Response
{
$this->initializeCurlResource();
@@ -52,9 +47,6 @@ public function send(Request $request): Response
return new Response($statusCode, (string) $content);
}
- /**
- * {@inheritdoc}
- */
public function close(): void
{
if ($this->resource) {
@@ -64,9 +56,6 @@ public function close(): void
$this->resource = null;
}
- /**
- * Initialize cURL resource
- */
private function initializeCurlResource(): void
{
if (!$this->resource) {
@@ -78,11 +67,6 @@ private function initializeCurlResource(): void
}
}
- /**
- * Prepare cURL resource by request
- *
- * @param Request $request
- */
private function prepareCurlResourceByRequest(Request $request): void
{
\curl_setopt($this->resource, CURLOPT_URL, $request->getUrl());
diff --git a/src/Protocol/Http/Sender/HttpSenderInterface.php b/src/Protocol/Http/Sender/HttpSenderInterface.php
index 23baf2a..bac79d7 100644
--- a/src/Protocol/Http/Sender/HttpSenderInterface.php
+++ b/src/Protocol/Http/Sender/HttpSenderInterface.php
@@ -33,8 +33,5 @@ interface HttpSenderInterface
*/
public function send(Request $request): Response;
- /**
- * Close connection
- */
public function close(): void;
}
diff --git a/src/Protocol/Http/UriFactory/UriFactory.php b/src/Protocol/Http/UriFactory/UriFactory.php
index 84cd4cf..f58b831 100644
--- a/src/Protocol/Http/UriFactory/UriFactory.php
+++ b/src/Protocol/Http/UriFactory/UriFactory.php
@@ -15,19 +15,8 @@
use Apple\ApnPush\Model\DeviceToken;
-/**
- * Default URI factory
- */
class UriFactory implements UriFactoryInterface
{
- /**
- * Create URI for device
- *
- * @param DeviceToken $deviceToken
- * @param bool $sandbox
- *
- * @return string
- */
public function create(DeviceToken $deviceToken, bool $sandbox): string
{
$uri = 'https://api.push.apple.com/3/device/%s';
diff --git a/src/Protocol/Http/UriFactory/UriFactoryInterface.php b/src/Protocol/Http/UriFactory/UriFactoryInterface.php
index 2fa2450..fa18fd7 100644
--- a/src/Protocol/Http/UriFactory/UriFactoryInterface.php
+++ b/src/Protocol/Http/UriFactory/UriFactoryInterface.php
@@ -15,18 +15,7 @@
use Apple\ApnPush\Model\DeviceToken;
-/**
- * All URI factories for create URI for send push notification via HTTP should implement this interface
- */
interface UriFactoryInterface
{
- /**
- * Create URI for send request
- *
- * @param DeviceToken $deviceToken
- * @param bool $sandbox
- *
- * @return string
- */
public function create(DeviceToken $deviceToken, bool $sandbox): string;
}
diff --git a/src/Protocol/Http/Visitor/AddApnIdHeaderVisitor.php b/src/Protocol/Http/Visitor/AddApnIdHeaderVisitor.php
index e5654bf..5958c35 100644
--- a/src/Protocol/Http/Visitor/AddApnIdHeaderVisitor.php
+++ b/src/Protocol/Http/Visitor/AddApnIdHeaderVisitor.php
@@ -16,14 +16,8 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * Visitor for add apn id header visitor
- */
class AddApnIdHeaderVisitor implements HttpProtocolVisitorInterface
{
- /**
- * {@inheritdoc}
- */
public function visit(Notification $notification, Request $request): Request
{
$apnId = $notification->getApnId();
diff --git a/src/Protocol/Http/Visitor/AddCollapseIdHeaderVisitor.php b/src/Protocol/Http/Visitor/AddCollapseIdHeaderVisitor.php
index 5fff0fa..fec2ca9 100644
--- a/src/Protocol/Http/Visitor/AddCollapseIdHeaderVisitor.php
+++ b/src/Protocol/Http/Visitor/AddCollapseIdHeaderVisitor.php
@@ -16,14 +16,8 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * Visitor for add the apns-collapse-id header.
- */
class AddCollapseIdHeaderVisitor implements HttpProtocolVisitorInterface
{
- /**
- * {@inheritdoc}
- */
public function visit(Notification $notification, Request $request): Request
{
$collapseId = $notification->getCollapseId();
diff --git a/src/Protocol/Http/Visitor/AddExpirationHeaderVisitor.php b/src/Protocol/Http/Visitor/AddExpirationHeaderVisitor.php
index 523c30e..364ddd4 100644
--- a/src/Protocol/Http/Visitor/AddExpirationHeaderVisitor.php
+++ b/src/Protocol/Http/Visitor/AddExpirationHeaderVisitor.php
@@ -16,14 +16,8 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * Visitor for add expiration header to request
- */
class AddExpirationHeaderVisitor implements HttpProtocolVisitorInterface
{
- /**
- * {@inheritdoc}
- */
public function visit(Notification $notification, Request $request): Request
{
$expiration = $notification->getExpiration();
diff --git a/src/Protocol/Http/Visitor/AddPriorityHeaderVisitor.php b/src/Protocol/Http/Visitor/AddPriorityHeaderVisitor.php
index b557b0d..e216f16 100644
--- a/src/Protocol/Http/Visitor/AddPriorityHeaderVisitor.php
+++ b/src/Protocol/Http/Visitor/AddPriorityHeaderVisitor.php
@@ -16,14 +16,8 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * Visitor for add priority header to request
- */
class AddPriorityHeaderVisitor implements HttpProtocolVisitorInterface
{
- /**
- * {@inheritdoc}
- */
public function visit(Notification $notification, Request $request): Request
{
$priority = $notification->getPriority();
diff --git a/src/Protocol/Http/Visitor/AddPushTypeHeaderVisitor.php b/src/Protocol/Http/Visitor/AddPushTypeHeaderVisitor.php
index 32dd87d..01f948a 100644
--- a/src/Protocol/Http/Visitor/AddPushTypeHeaderVisitor.php
+++ b/src/Protocol/Http/Visitor/AddPushTypeHeaderVisitor.php
@@ -16,14 +16,8 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * Visitor for add apns-push-type header to request
- */
class AddPushTypeHeaderVisitor implements HttpProtocolVisitorInterface
{
- /**
- * {@inheritdoc}
- */
public function visit(Notification $notification, Request $request): Request
{
$pushType = $notification->getPushType();
diff --git a/src/Protocol/Http/Visitor/HttpProtocolChainVisitor.php b/src/Protocol/Http/Visitor/HttpProtocolChainVisitor.php
index 2fadc49..49cf0cb 100644
--- a/src/Protocol/Http/Visitor/HttpProtocolChainVisitor.php
+++ b/src/Protocol/Http/Visitor/HttpProtocolChainVisitor.php
@@ -16,38 +16,23 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * Chain visitor for visit for notification and request before send request
- */
class HttpProtocolChainVisitor implements HttpProtocolVisitorInterface
{
/**
- * @var \SplPriorityQueue|HttpProtocolVisitorInterface[]
+ * @var \SplPriorityQueue
*/
- private $visitors;
+ private \SplPriorityQueue $visitors;
- /**
- * Constructor.
- */
public function __construct()
{
$this->visitors = new \SplPriorityQueue();
}
- /**
- * Add visitor to chain
- *
- * @param HttpProtocolVisitorInterface $visitor
- * @param int $priority
- */
public function add(HttpProtocolVisitorInterface $visitor, int $priority = 0): void
{
$this->visitors->insert($visitor, $priority);
}
- /**
- * {@inheritdoc}
- */
public function visit(Notification $notification, Request $request): Request
{
// Clone all visitors because \SplPriorityQueue remove object after iteration
diff --git a/src/Protocol/Http/Visitor/HttpProtocolVisitorInterface.php b/src/Protocol/Http/Visitor/HttpProtocolVisitorInterface.php
index d48e5cf..69bca63 100644
--- a/src/Protocol/Http/Visitor/HttpProtocolVisitorInterface.php
+++ b/src/Protocol/Http/Visitor/HttpProtocolVisitorInterface.php
@@ -16,10 +16,6 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Protocol\Http\Request;
-/**
- * All visitors for visit for notification and request before send request to Apple Apn Push service should implement
- * this interface.
- */
interface HttpProtocolVisitorInterface
{
/**
diff --git a/src/Protocol/HttpProtocol.php b/src/Protocol/HttpProtocol.php
index 245aafd..0f71049 100644
--- a/src/Protocol/HttpProtocol.php
+++ b/src/Protocol/HttpProtocol.php
@@ -25,51 +25,15 @@
use Apple\ApnPush\Protocol\Http\UriFactory\UriFactoryInterface;
use Apple\ApnPush\Protocol\Http\Visitor\HttpProtocolVisitorInterface;
-/**
- * Implement HTTP protocol for send push notification
- */
class HttpProtocol implements ProtocolInterface
{
- /**
- * @var AuthenticatorInterface
- */
- private $authenticator;
-
- /**
- * @var HttpSenderInterface
- */
- private $httpSender;
-
- /**
- * @var PayloadEncoderInterface
- */
- private $payloadEncoder;
-
- /**
- * @var UriFactoryInterface
- */
- private $uriFactory;
-
- /**
- * @var HttpProtocolVisitorInterface
- */
- private $visitor;
-
- /**
- * @var ExceptionFactoryInterface
- */
- private $exceptionFactory;
-
- /**
- * Constructor.
- *
- * @param AuthenticatorInterface $authenticator
- * @param HttpSenderInterface $httpSender
- * @param PayloadEncoderInterface $payloadEncoder
- * @param UriFactoryInterface $uriFactory
- * @param HttpProtocolVisitorInterface $visitor
- * @param ExceptionFactoryInterface $exceptionFactory
- */
+ private AuthenticatorInterface $authenticator;
+ private HttpSenderInterface $httpSender;
+ private PayloadEncoderInterface $payloadEncoder;
+ private UriFactoryInterface$uriFactory;
+ private HttpProtocolVisitorInterface $visitor;
+ private ExceptionFactoryInterface $exceptionFactory;
+
public function __construct(AuthenticatorInterface $authenticator, HttpSenderInterface $httpSender, PayloadEncoderInterface $payloadEncoder, UriFactoryInterface $uriFactory, HttpProtocolVisitorInterface $visitor, ExceptionFactoryInterface $exceptionFactory)
{
$this->authenticator = $authenticator;
@@ -80,11 +44,6 @@ public function __construct(AuthenticatorInterface $authenticator, HttpSenderInt
$this->exceptionFactory = $exceptionFactory;
}
- /**
- * {@inheritdoc}
- *
- * @throws HttpSenderException
- */
public function send(Receiver $receiver, Notification $notification, bool $sandbox): void
{
try {
@@ -96,24 +55,11 @@ public function send(Receiver $receiver, Notification $notification, bool $sandb
}
}
- /**
- * {@inheritdoc}
- */
public function closeConnection(): void
{
$this->httpSender->close();
}
- /**
- * Inner send process
- *
- * @param Receiver $receiver
- * @param Notification $notification
- * @param bool $sandbox
- *
- * @throws SendNotificationException
- * @throws HttpSenderException
- */
private function doSend(Receiver $receiver, Notification $notification, bool $sandbox): void
{
$payloadEncoded = $this->payloadEncoder->encode($notification->getPayload());
diff --git a/src/Protocol/ProtocolInterface.php b/src/Protocol/ProtocolInterface.php
index 7ecc931..911aa3c 100644
--- a/src/Protocol/ProtocolInterface.php
+++ b/src/Protocol/ProtocolInterface.php
@@ -17,9 +17,6 @@
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Model\Receiver;
-/**
- * All protocols for send notification should implement this interface
- */
interface ProtocolInterface
{
/**
diff --git a/src/Sender/Builder/BuilderInterface.php b/src/Sender/Builder/BuilderInterface.php
index b52b9c2..02e0ad8 100644
--- a/src/Sender/Builder/BuilderInterface.php
+++ b/src/Sender/Builder/BuilderInterface.php
@@ -16,9 +16,6 @@
use Apple\ApnPush\Protocol\ProtocolInterface;
use Apple\ApnPush\Sender\SenderInterface;
-/**
- * All builders for build senders should implement this interface
- */
interface BuilderInterface
{
/**
diff --git a/src/Sender/Builder/Http20Builder.php b/src/Sender/Builder/Http20Builder.php
index 931aa40..43ac257 100644
--- a/src/Sender/Builder/Http20Builder.php
+++ b/src/Sender/Builder/Http20Builder.php
@@ -40,45 +40,16 @@
class Http20Builder implements BuilderInterface
{
/**
- * @var \SplPriorityQueue|HttpProtocolVisitorInterface[]
+ * @var \SplPriorityQueue
*/
- private $visitors;
+ private \SplPriorityQueue $visitors;
- /**
- * @var UriFactoryInterface
- */
- private $uriFactory;
-
- /**
- * @var PayloadEncoderInterface
- */
- private $payloadEncoder;
-
- /**
- * @var AuthenticatorInterface
- */
- private $authenticator;
+ private UriFactoryInterface $uriFactory;
+ private PayloadEncoderInterface $payloadEncoder;
+ private AuthenticatorInterface $authenticator;
+ private HttpSenderInterface $httpSender;
+ private ExceptionFactoryInterface $exceptionFactory;
- /**
- * @var HttpSenderInterface
- */
- private $httpSender;
-
- /**
- * @var ExceptionFactoryInterface
- */
- private $exceptionFactory;
-
- /**
- * @var bool
- */
- private $addedDefaultVisitors;
-
- /**
- * Constructor.
- *
- * @param AuthenticatorInterface $authenticator
- */
public function __construct(AuthenticatorInterface $authenticator)
{
$this->authenticator = $authenticator;
@@ -88,123 +59,55 @@ public function __construct(AuthenticatorInterface $authenticator)
$this->httpSender = new CurlHttpSender();
$this->exceptionFactory = new ExceptionFactory();
- $this->addDefaultVisitors();
+ $this->addVisitor(new AddExpirationHeaderVisitor());
+ $this->addVisitor(new AddPriorityHeaderVisitor());
+ $this->addVisitor(new AddApnIdHeaderVisitor());
+ $this->addVisitor(new AddCollapseIdHeaderVisitor());
+ $this->addVisitor(new AddPushTypeHeaderVisitor());
}
- /**
- * Set authenticator
- *
- * @param AuthenticatorInterface $authenticator
- *
- * @return Http20Builder
- */
- public function setAuthenticator(AuthenticatorInterface $authenticator): Http20Builder
+ public function setAuthenticator(AuthenticatorInterface $authenticator): self
{
$this->authenticator = $authenticator;
return $this;
}
- /**
- * Add visitor
- *
- * @param HttpProtocolVisitorInterface $visitor
- * @param int $priority
- *
- * @return Http20Builder
- */
- public function addVisitor(HttpProtocolVisitorInterface $visitor, int $priority = 0): Http20Builder
+ public function addVisitor(HttpProtocolVisitorInterface $visitor, int $priority = 0): self
{
$this->visitors->insert($visitor, $priority);
return $this;
}
- /**
- * Add default visitors
- *
- * @return Http20Builder
- *
- * @deprecated This method is deprecated and will be a move to private scope.
- * Please do not use this method in your code.
- * This method will be called from the constructor of this builder.
- */
- public function addDefaultVisitors(): Http20Builder
- {
- if ($this->addedDefaultVisitors) {
- return $this;
- }
-
- $this->addedDefaultVisitors = true;
-
- $this->addVisitor(new AddExpirationHeaderVisitor());
- $this->addVisitor(new AddPriorityHeaderVisitor());
- $this->addVisitor(new AddApnIdHeaderVisitor());
- $this->addVisitor(new AddCollapseIdHeaderVisitor());
- $this->addVisitor(new AddPushTypeHeaderVisitor());
-
- return $this;
- }
-
- /**
- * Set URI factory
- *
- * @param UriFactoryInterface $uriFactory
- *
- * @return Http20Builder
- */
- public function setUriFactory(UriFactoryInterface $uriFactory): Http20Builder
+ public function setUriFactory(UriFactoryInterface $uriFactory): self
{
$this->uriFactory = $uriFactory;
return $this;
}
- /**
- * Set notification encoder
- *
- * @param PayloadEncoderInterface $payloadEncoder
- *
- * @return Http20Builder
- */
- public function setPayloadEncoder(PayloadEncoderInterface $payloadEncoder): Http20Builder
+ public function setPayloadEncoder(PayloadEncoderInterface $payloadEncoder): self
{
$this->payloadEncoder = $payloadEncoder;
return $this;
}
- /**
- * Set http sender
- *
- * @param HttpSenderInterface $httpSender
- *
- * @return Http20Builder
- */
- public function setHttpSender(HttpSenderInterface $httpSender): Http20Builder
+ public function setHttpSender(HttpSenderInterface $httpSender): self
{
$this->httpSender = $httpSender;
return $this;
}
- /**
- * Set exception factory
- *
- * @param ExceptionFactoryInterface $exceptionFactory
- *
- * @return Http20Builder
- */
- public function setExceptionFactory(ExceptionFactoryInterface $exceptionFactory): Http20Builder
+ public function setExceptionFactory(ExceptionFactoryInterface $exceptionFactory): self
{
$this->exceptionFactory = $exceptionFactory;
return $this;
}
- /**
- * {@inheritdoc}
- */
public function buildProtocol(): ProtocolInterface
{
$chainVisitor = $this->createChainVisitor();
@@ -219,9 +122,6 @@ public function buildProtocol(): ProtocolInterface
);
}
- /**
- * {@inheritdoc}
- */
public function build(): SenderInterface
{
$protocol = $this->buildProtocol();
@@ -229,11 +129,6 @@ public function build(): SenderInterface
return new Sender($protocol);
}
- /**
- * Create chain visitor
- *
- * @return HttpProtocolChainVisitor
- */
private function createChainVisitor(): HttpProtocolChainVisitor
{
$chainVisitors = new HttpProtocolChainVisitor();
diff --git a/src/Sender/Sender.php b/src/Sender/Sender.php
index 293d8ad..b7749e4 100644
--- a/src/Sender/Sender.php
+++ b/src/Sender/Sender.php
@@ -17,29 +17,15 @@
use Apple\ApnPush\Model\Receiver;
use Apple\ApnPush\Protocol\ProtocolInterface;
-/**
- * Default notification sender
- */
class Sender implements SenderInterface
{
- /**
- * @var ProtocolInterface
- */
- private $protocol;
+ private ProtocolInterface $protocol;
- /**
- * Constructor.
- *
- * @param ProtocolInterface $protocol
- */
public function __construct(ProtocolInterface $protocol)
{
$this->protocol = $protocol;
}
- /**
- * {@inheritdoc}
- */
public function send(Receiver $receiver, Notification $notification, bool $sandbox = false): void
{
$this->protocol->send($receiver, $notification, $sandbox);
diff --git a/src/Sender/SenderInterface.php b/src/Sender/SenderInterface.php
index 34bd1dd..7059d2c 100644
--- a/src/Sender/SenderInterface.php
+++ b/src/Sender/SenderInterface.php
@@ -13,12 +13,10 @@
namespace Apple\ApnPush\Sender;
+use Apple\ApnPush\Exception\SendNotification\SendNotificationException;
use Apple\ApnPush\Model\Notification;
use Apple\ApnPush\Model\Receiver;
-/**
- * All senders for send notifications to device should implement this interface
- */
interface SenderInterface
{
/**
@@ -28,7 +26,7 @@ interface SenderInterface
* @param Notification $notification
* @param bool $sandbox
*
- * @throws \Apple\ApnPush\Exception\SendNotification\SendNotificationException
+ * @throws SendNotificationException
*/
public function send(Receiver $receiver, Notification $notification, bool $sandbox = false): void;
}
diff --git a/src/phpcs.xml b/src/phpcs.xml
new file mode 100644
index 0000000..5ace9b2
--- /dev/null
+++ b/src/phpcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/tests/Certificate/CertificateTest.php b/tests/Certificate/CertificateTest.php
index 9779e3c..8692858 100644
--- a/tests/Certificate/CertificateTest.php
+++ b/tests/Certificate/CertificateTest.php
@@ -1,5 +1,7 @@
getPath();
- $fileContent = file_get_contents($filePath);
+ $fileContent = \file_get_contents($filePath);
self::assertEquals('content', $fileContent);
self::assertEquals('pass', $certificate->getPassPhrase());
diff --git a/tests/Encoder/PayloadEncoderTest.php b/tests/Encoder/PayloadEncoderTest.php
index 53a5d36..b405080 100644
--- a/tests/Encoder/PayloadEncoderTest.php
+++ b/tests/Encoder/PayloadEncoderTest.php
@@ -1,5 +1,7 @@
encoder = new PayloadEncoder();
diff --git a/tests/Jwt/ContentJwtTest.php b/tests/Jwt/ContentJwtTest.php
index b4b096b..07301c7 100644
--- a/tests/Jwt/ContentJwtTest.php
+++ b/tests/Jwt/ContentJwtTest.php
@@ -1,5 +1,7 @@
tmpFileName = \tempnam(\sys_get_temp_dir(), 'apn_push_test_jwt');
}
- /**
- * {@inheritdoc}
- */
protected function tearDown(): void
{
if (\file_exists($this->tmpFileName)) {
diff --git a/tests/Jwt/SignatureGenerator/CacheJwtSignatureGeneratorTest.php b/tests/Jwt/SignatureGenerator/CacheJwtSignatureGeneratorTest.php
index 59fd4a1..5d66edd 100644
--- a/tests/Jwt/SignatureGenerator/CacheJwtSignatureGeneratorTest.php
+++ b/tests/Jwt/SignatureGenerator/CacheJwtSignatureGeneratorTest.php
@@ -22,24 +22,10 @@
class CacheJwtSignatureGeneratorTest extends TestCase
{
- /**
- * @var SignatureGeneratorInterface
- */
- private $originGenerator;
-
- /**
- * @var CacheInterface
- */
- private $cache;
+ private SignatureGeneratorInterface $originGenerator;
+ private CacheInterface $cache;
+ private JwtCacheKeyGeneratorInterface $keyGenerator;
- /**
- * @var JwtCacheKeyGeneratorInterface
- */
- private $keyGenerator;
-
- /**
- * {@inheritdoc}
- */
protected function setUp(): void
{
$this->originGenerator = $this->createMock(SignatureGeneratorInterface::class);
diff --git a/tests/Model/AlertTest.php b/tests/Model/AlertTest.php
index f2b390d..de42528 100644
--- a/tests/Model/AlertTest.php
+++ b/tests/Model/AlertTest.php
@@ -1,5 +1,7 @@
certificate = $this->createMock(CertificateInterface::class);
diff --git a/tests/Protocol/Http/Authenticator/JwtAuthenticatorTest.php b/tests/Protocol/Http/Authenticator/JwtAuthenticatorTest.php
index 0d963c2..4d77c41 100644
--- a/tests/Protocol/Http/Authenticator/JwtAuthenticatorTest.php
+++ b/tests/Protocol/Http/Authenticator/JwtAuthenticatorTest.php
@@ -1,5 +1,7 @@
signatureGenerator = $this->createMock(SignatureGeneratorInterface::class);
diff --git a/tests/Protocol/Http/ExceptionFactory/ExceptionFactoryTest.php b/tests/Protocol/Http/ExceptionFactory/ExceptionFactoryTest.php
index 19f8672..3256ecd 100644
--- a/tests/Protocol/Http/ExceptionFactory/ExceptionFactoryTest.php
+++ b/tests/Protocol/Http/ExceptionFactory/ExceptionFactoryTest.php
@@ -1,5 +1,7 @@
exceptionFactory = new ExceptionFactory();
@@ -109,13 +105,13 @@ public function shouldFailIfMissingReason(): void
*
* @dataProvider provideReasons
*/
- public function shouldSuccessCreate($reason, \Exception $expectedException, array $extra = []): void
+ public function shouldSuccessCreate(string $reason, \Exception $expectedException, array $extra = []): void
{
- $json = array_merge([
+ $json = \array_merge([
'reason' => $reason,
], $extra);
- $response = new Response(200, json_encode($json));
+ $response = new Response(200, \json_encode($json));
$exception = $this->exceptionFactory->create($response);
self::assertEquals($expectedException, $exception);
@@ -126,7 +122,7 @@ public function shouldSuccessCreate($reason, \Exception $expectedException, arra
*
* @return array
*/
- public function provideReasons(): array
+ public static function provideReasons(): array
{
$lastUse = \DateTime::createFromFormat('!Y/m/d', '2017/01/01');
diff --git a/tests/Protocol/Http/UriFactory/UriFactoryTest.php b/tests/Protocol/Http/UriFactory/UriFactoryTest.php
index df4c9f7..3fec32b 100644
--- a/tests/Protocol/Http/UriFactory/UriFactoryTest.php
+++ b/tests/Protocol/Http/UriFactory/UriFactoryTest.php
@@ -1,5 +1,7 @@
uriFactory = new UriFactory();
diff --git a/tests/Protocol/Http/Visitor/AddApnIdHeaderVisitorTest.php b/tests/Protocol/Http/Visitor/AddApnIdHeaderVisitorTest.php
index fef55e2..0e167af 100644
--- a/tests/Protocol/Http/Visitor/AddApnIdHeaderVisitorTest.php
+++ b/tests/Protocol/Http/Visitor/AddApnIdHeaderVisitorTest.php
@@ -1,5 +1,7 @@
visitor = new AddApnIdHeaderVisitor();
diff --git a/tests/Protocol/Http/Visitor/AddCollapseIdHeaderVisitorTest.php b/tests/Protocol/Http/Visitor/AddCollapseIdHeaderVisitorTest.php
index f07d98d..c6f95d1 100644
--- a/tests/Protocol/Http/Visitor/AddCollapseIdHeaderVisitorTest.php
+++ b/tests/Protocol/Http/Visitor/AddCollapseIdHeaderVisitorTest.php
@@ -1,5 +1,7 @@
visitor = new AddCollapseIdHeaderVisitor();
diff --git a/tests/Protocol/Http/Visitor/AddExpirationHeaderVisitorTest.php b/tests/Protocol/Http/Visitor/AddExpirationHeaderVisitorTest.php
index a1f480c..51bc439 100644
--- a/tests/Protocol/Http/Visitor/AddExpirationHeaderVisitorTest.php
+++ b/tests/Protocol/Http/Visitor/AddExpirationHeaderVisitorTest.php
@@ -1,5 +1,7 @@
visitor = new AddExpirationHeaderVisitor();
diff --git a/tests/Protocol/Http/Visitor/AddPriorityHeaderVisitorTest.php b/tests/Protocol/Http/Visitor/AddPriorityHeaderVisitorTest.php
index 6a3327e..c0b8373 100644
--- a/tests/Protocol/Http/Visitor/AddPriorityHeaderVisitorTest.php
+++ b/tests/Protocol/Http/Visitor/AddPriorityHeaderVisitorTest.php
@@ -1,5 +1,7 @@
visitor = new AddPriorityHeaderVisitor();
diff --git a/tests/Protocol/Http/Visitor/AddPushTypeHeaderVisitorTest.php b/tests/Protocol/Http/Visitor/AddPushTypeHeaderVisitorTest.php
index 6a29241..7cec901 100644
--- a/tests/Protocol/Http/Visitor/AddPushTypeHeaderVisitorTest.php
+++ b/tests/Protocol/Http/Visitor/AddPushTypeHeaderVisitorTest.php
@@ -1,5 +1,7 @@
visitor = new AddPushTypeHeaderVisitor();
diff --git a/tests/Protocol/Http/Visitor/HttpProtocolChainVisitorTest.php b/tests/Protocol/Http/Visitor/HttpProtocolChainVisitorTest.php
index 4d0d3bf..834addf 100644
--- a/tests/Protocol/Http/Visitor/HttpProtocolChainVisitorTest.php
+++ b/tests/Protocol/Http/Visitor/HttpProtocolChainVisitorTest.php
@@ -1,5 +1,7 @@
visit($notification, $request);
}
- /**
- * Create visitor mock
- *
- * @return HttpProtocolVisitorInterface|MockObject
- */
private function createVisitor(): HttpProtocolVisitorInterface
{
$className = sprintf(
'HttpProtocolVisitorInterface_%s',
- \md5(\uniqid(\random_int(0, 9999), true))
+ \md5(\uniqid((string) \random_int(0, 9999), true))
);
$visitor = $this->getMockBuilder(HttpProtocolVisitorInterface::class)
diff --git a/tests/Protocol/HttpProtocolTest.php b/tests/Protocol/HttpProtocolTest.php
index 64539fd..f0d0c39 100644
--- a/tests/Protocol/HttpProtocolTest.php
+++ b/tests/Protocol/HttpProtocolTest.php
@@ -1,5 +1,7 @@
authenticator = $this->createMock(AuthenticatorInterface::class);
diff --git a/tests/Sender/Builder/Http20BuilderTest.php b/tests/Sender/Builder/Http20BuilderTest.php
index 8f45514..a1f2f9b 100644
--- a/tests/Sender/Builder/Http20BuilderTest.php
+++ b/tests/Sender/Builder/Http20BuilderTest.php
@@ -1,5 +1,7 @@
protocol = $this->createMock(ProtocolInterface::class);
diff --git a/tests/phpcs-ruleset.xml b/tests/phpcs-ruleset.xml
deleted file mode 100644
index d705999..0000000
--- a/tests/phpcs-ruleset.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/tests/phpcs.xml b/tests/phpcs.xml
new file mode 100644
index 0000000..7035280
--- /dev/null
+++ b/tests/phpcs.xml
@@ -0,0 +1,4 @@
+
+
+
+