From b1fcc35d36bfd1ceb22e47cb3cb967b8de59015a Mon Sep 17 00:00:00 2001 From: Serhiy Lunak Date: Sun, 1 Sep 2024 10:02:06 +0100 Subject: [PATCH 1/2] Fix rector --- examples/CompleteNotificationExample.php | 3 +- examples/ReceiptExample.php | 9 ++--- src/Api/Licensing/License.php | 3 +- src/Api/Message/Attachment.php | 3 +- src/Api/Message/Message.php | 7 ++-- src/Api/Message/Priority.php | 3 +- src/Api/Message/Sound.php | 3 +- src/Client/GroupsClient.php | 3 +- src/Client/MessageClient.php | 3 +- src/Client/Response/ReceiptResponse.php | 33 ++++++++++--------- src/Exception/ExceptionInterface.php | 4 ++- tests/Api/Message/AttachmentTest.php | 3 +- tests/Api/Message/MessageTest.php | 3 +- tests/Api/Message/PriorityTest.php | 3 +- tests/Api/Message/SoundTest.php | 3 +- tests/Client/Response/ReceiptResponseTest.php | 9 ++--- 16 files changed, 56 insertions(+), 39 deletions(-) diff --git a/examples/CompleteNotificationExample.php b/examples/CompleteNotificationExample.php index bd4fcd6..bd2d18f 100644 --- a/examples/CompleteNotificationExample.php +++ b/examples/CompleteNotificationExample.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Example; +use DateTime; use Serhiy\Pushover\Api\Message\Attachment; use Serhiy\Pushover\Api\Message\CustomSound; use Serhiy\Pushover\Api\Message\Message; @@ -43,7 +44,7 @@ public function completeNotification(): void $message->setUrl('https://www.example.com'); $message->setUrlTitle('Example URL'); $message->setisHtml(false); - $message->setTimestamp(new \DateTime('now')); + $message->setTimestamp(new DateTime('now')); $message->setTtl(60 * 60 * 24); // 1 day // assign priority to the notification $message->setPriority(new Priority(Priority::NORMAL)); diff --git a/examples/ReceiptExample.php b/examples/ReceiptExample.php index a6b1a7d..48932eb 100644 --- a/examples/ReceiptExample.php +++ b/examples/ReceiptExample.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Example; +use DateTime; use Serhiy\Pushover\Api\Receipts\Receipt; use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\Response\CancelRetryResponse; @@ -38,7 +39,7 @@ public function queryEmergencyNotificationReceiptExample(): void if ($response->isSuccessful()) { // True or False whether the user has acknowledged the notification if ($response->isAcknowledged()) { - /** @var \DateTime $dateTime Timestamp of when the user acknowledged, or null */ + /** @var DateTime $dateTime Timestamp of when the user acknowledged, or null */ $acknowledgedAt = $response->getAcknowledgedAt(); /** @var Recipient $recipient User that first acknowledged the notification */ @@ -48,19 +49,19 @@ public function queryEmergencyNotificationReceiptExample(): void $acknowledgedByDevice = $response->getAcknowledgedByDevice(); } - /** @var \DateTime $lastDeliveredAt Timestamp of when the notification was last retried, or null */ + /** @var DateTime $lastDeliveredAt Timestamp of when the notification was last retried, or null */ $lastDeliveredAt = $response->getLastDeliveredAt(); /** @var bool $isExpired True or False whether the expiration date has passed */ $isExpired = $response->isExpired(); - /** @var \DateTime $expiresAt Timestamp of when the notification will stop being retried */ + /** @var DateTime $expiresAt Timestamp of when the notification will stop being retried */ $expiresAt = $response->getExpiresAt(); /** @var bool $hasCalledBack True or False whether our server has called back to your callback URL if any */ $hasCalledBack = $response->hasCalledBack(); - /** @var \DateTime $calledBackAt Timestamp of when our server called back, or null */ + /** @var DateTime $calledBackAt Timestamp of when our server called back, or null */ $calledBackAt = $response->getCalledBackAt(); } } diff --git a/src/Api/Licensing/License.php b/src/Api/Licensing/License.php index 2456e94..8e332c3 100644 --- a/src/Api/Licensing/License.php +++ b/src/Api/Licensing/License.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Api\Licensing; +use ReflectionClass; use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\AssignLicenseClient; use Serhiy\Pushover\Client\CheckLicenseClient; @@ -136,7 +137,7 @@ public function canBeAssigned(): bool */ public static function getAvailableOsTypes(): array { - $oClass = new \ReflectionClass(self::class); + $oClass = new ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Api/Message/Attachment.php b/src/Api/Message/Attachment.php index b22c796..a053796 100644 --- a/src/Api/Message/Attachment.php +++ b/src/Api/Message/Attachment.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Api\Message; +use ReflectionClass; use Serhiy\Pushover\Exception\InvalidArgumentException; /** @@ -95,7 +96,7 @@ public function __construct(string $filename, string $mimeType) */ public static function getSupportedAttachmentTypes(): array { - $oClass = new \ReflectionClass(self::class); + $oClass = new ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Api/Message/Message.php b/src/Api/Message/Message.php index 6912dcc..a037bc6 100644 --- a/src/Api/Message/Message.php +++ b/src/Api/Message/Message.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Api\Message; +use DateTime; use Serhiy\Pushover\Exception\InvalidArgumentException; /** @@ -70,7 +71,7 @@ class Message * or delivered to Pushover out of order, this default timestamping may cause a confusing order of messages when viewed on the user's device. * For these scenarios, your app may send messages to the API with the timestamp parameter set to the Unix timestamp of the original message. */ - private \DateTime $timestamp; + private DateTime $timestamp; /** * Normally a message delivered to a device is retained on the device until it is deleted by the user, @@ -92,7 +93,7 @@ public function __construct(string $message, ?string $title = null) $this->setTitle($title); } - $this->timestamp = new \DateTime(); + $this->timestamp = new DateTime(); } public function getMessage(): string @@ -176,7 +177,7 @@ public function getTimestamp(): int return $this->timestamp->getTimestamp(); } - public function setTimestamp(\DateTime $timestamp): void + public function setTimestamp(DateTime $timestamp): void { $this->timestamp = $timestamp; } diff --git a/src/Api/Message/Priority.php b/src/Api/Message/Priority.php index 602ca91..f058e66 100644 --- a/src/Api/Message/Priority.php +++ b/src/Api/Message/Priority.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Api\Message; +use ReflectionClass; use Serhiy\Pushover\Exception\InvalidArgumentException; use Serhiy\Pushover\Exception\LogicException; @@ -117,7 +118,7 @@ public function __construct( */ public static function getAvailablePriorities(): array { - $oClass = new \ReflectionClass(self::class); + $oClass = new ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Api/Message/Sound.php b/src/Api/Message/Sound.php index 07bbf5c..8fc5b4f 100644 --- a/src/Api/Message/Sound.php +++ b/src/Api/Message/Sound.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Api\Message; +use ReflectionClass; use Serhiy\Pushover\Exception\InvalidArgumentException; /** @@ -155,7 +156,7 @@ public function __construct( */ public static function getAvailableSounds(): array { - $oClass = new \ReflectionClass(self::class); + $oClass = new ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index 96ea459..6fa9418 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Client; +use ReflectionClass; use Serhiy\Pushover\Api\Groups\Group; use Serhiy\Pushover\Client\Curl\Curl; use Serhiy\Pushover\Exception\InvalidArgumentException; @@ -105,7 +106,7 @@ public function buildCurlPostFields(?Recipient $recipient = null): array */ private function isActionValid(string $action): bool { - $oClass = new \ReflectionClass(self::class); + $oClass = new ReflectionClass(self::class); if (\in_array($action, $oClass->getConstants(), true)) { return true; diff --git a/src/Client/MessageClient.php b/src/Client/MessageClient.php index 4bb6d30..da76ebd 100644 --- a/src/Client/MessageClient.php +++ b/src/Client/MessageClient.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Client; +use CURLFile; use Serhiy\Pushover\Api\Message\Notification; use Serhiy\Pushover\Api\Message\Priority; use Serhiy\Pushover\Client\Curl\Curl; @@ -40,7 +41,7 @@ public function buildApiUrl(): string /** * Builds array for CURLOPT_POSTFIELDS curl argument. * - * @return array + * @return array */ public function buildCurlPostFields(Notification $notification): array { diff --git a/src/Client/Response/ReceiptResponse.php b/src/Client/Response/ReceiptResponse.php index 6f3feb4..d5df28d 100644 --- a/src/Client/Response/ReceiptResponse.php +++ b/src/Client/Response/ReceiptResponse.php @@ -13,6 +13,7 @@ namespace Serhiy\Pushover\Client\Response; +use DateTime; use Serhiy\Pushover\Client\Response\Base\Response; use Serhiy\Pushover\Recipient; @@ -31,7 +32,7 @@ class ReceiptResponse extends Response /** * Timestamp of when the user acknowledged, or null. */ - private ?\DateTime $acknowledgedAt = null; + private ?DateTime $acknowledgedAt = null; /** * User that first acknowledged the notification. @@ -46,7 +47,7 @@ class ReceiptResponse extends Response /** * Timestamp of when the notification was last retried, or null. */ - private ?\DateTime $lastDeliveredAt = null; + private ?DateTime $lastDeliveredAt = null; /** * True or False whether the expiration date has passed. @@ -56,7 +57,7 @@ class ReceiptResponse extends Response /** * Timestamp of when the notification will stop being retried. */ - private \DateTime $expiresAt; + private DateTime $expiresAt; /** * True or False whether our server has called back to your callback URL if any. @@ -66,7 +67,7 @@ class ReceiptResponse extends Response /** * Timestamp of when our server called back, or null. */ - private ?\DateTime $calledBackAt = null; + private ?DateTime $calledBackAt = null; public function __construct(string $curlResponse) { @@ -78,7 +79,7 @@ public function isAcknowledged(): bool return $this->isAcknowledged; } - public function getAcknowledgedAt(): ?\DateTime + public function getAcknowledgedAt(): ?DateTime { return $this->acknowledgedAt; } @@ -93,7 +94,7 @@ public function getAcknowledgedByDevice(): string return $this->acknowledgedByDevice; } - public function getLastDeliveredAt(): ?\DateTime + public function getLastDeliveredAt(): ?DateTime { return $this->lastDeliveredAt; } @@ -103,7 +104,7 @@ public function isExpired(): bool return $this->isExpired; } - public function getExpiresAt(): \DateTime + public function getExpiresAt(): DateTime { return $this->expiresAt; } @@ -113,7 +114,7 @@ public function hasCalledBack(): bool return $this->hasCalledBack; } - public function getCalledBackAt(): ?\DateTime + public function getCalledBackAt(): ?DateTime { return $this->calledBackAt; } @@ -123,7 +124,7 @@ private function setIsAcknowledged(bool $isAcknowledged): void $this->isAcknowledged = $isAcknowledged; } - private function setAcknowledgedAt(\DateTime $acknowledgedAt): void + private function setAcknowledgedAt(DateTime $acknowledgedAt): void { $this->acknowledgedAt = $acknowledgedAt; } @@ -138,7 +139,7 @@ private function setAcknowledgedByDevice(string $acknowledgedByDevice): void $this->acknowledgedByDevice = $acknowledgedByDevice; } - private function setLastDeliveredAt(\DateTime $lastDeliveredAt): void + private function setLastDeliveredAt(DateTime $lastDeliveredAt): void { $this->lastDeliveredAt = $lastDeliveredAt; } @@ -148,7 +149,7 @@ private function setIsExpired(bool $isExpired): void $this->isExpired = $isExpired; } - private function setExpiresAt(\DateTime $expiresAt): void + private function setExpiresAt(DateTime $expiresAt): void { $this->expiresAt = $expiresAt; } @@ -158,7 +159,7 @@ private function setHasCalledBack(bool $hasCalledBack): void $this->hasCalledBack = $hasCalledBack; } - private function setCalledBackAt(\DateTime $calledBackAt): void + private function setCalledBackAt(DateTime $calledBackAt): void { $this->calledBackAt = $calledBackAt; } @@ -170,7 +171,7 @@ private function processCurlResponse(string $curlResponse): void if ($this->getRequestStatus() === 1) { if ($decodedCurlResponse->acknowledged === 1) { $this->setIsAcknowledged(true); - $this->setAcknowledgedAt(new \DateTime('@'.$decodedCurlResponse->acknowledged_at)); + $this->setAcknowledgedAt(new DateTime('@'.$decodedCurlResponse->acknowledged_at)); $recipient = new Recipient($decodedCurlResponse->acknowledged_by); $recipient->addDevice($decodedCurlResponse->acknowledged_by_device); @@ -178,7 +179,7 @@ private function processCurlResponse(string $curlResponse): void $this->setAcknowledgedByDevice($recipient->getDeviceListCommaSeparated()); } - $this->setLastDeliveredAt(new \DateTime('@'.$decodedCurlResponse->last_delivered_at)); + $this->setLastDeliveredAt(new DateTime('@'.$decodedCurlResponse->last_delivered_at)); if ($decodedCurlResponse->expired === 1) { $this->setIsExpired(true); @@ -186,11 +187,11 @@ private function processCurlResponse(string $curlResponse): void $this->setIsExpired(false); } - $this->setExpiresAt(new \DateTime('@'.$decodedCurlResponse->expires_at)); + $this->setExpiresAt(new DateTime('@'.$decodedCurlResponse->expires_at)); if ($decodedCurlResponse->called_back === 1) { $this->setHasCalledBack(true); - $this->setCalledBackAt(new \DateTime('@'.$decodedCurlResponse->called_back_at)); + $this->setCalledBackAt(new DateTime('@'.$decodedCurlResponse->called_back_at)); } } } diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index 78d9dde..e4b935f 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -13,11 +13,13 @@ namespace Serhiy\Pushover\Exception; +use Throwable; + /** * Base ExceptionInterface for the Pushover component. * * @author Serhiy Lunak */ -interface ExceptionInterface extends \Throwable +interface ExceptionInterface extends Throwable { } diff --git a/tests/Api/Message/AttachmentTest.php b/tests/Api/Message/AttachmentTest.php index fe0ade9..adb4eef 100644 --- a/tests/Api/Message/AttachmentTest.php +++ b/tests/Api/Message/AttachmentTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use ReflectionClass; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Attachment; @@ -80,7 +81,7 @@ public function testSetFilename(Attachment $attachment): void #[Depends('testCanBeConstructed')] public function testGetSupportedAttachmentTypes(Attachment $attachment): void { - $supportedAttachmentsTypes = new \ReflectionClass(Attachment::class); + $supportedAttachmentsTypes = new ReflectionClass(Attachment::class); $this->assertEquals($supportedAttachmentsTypes->getConstants(), $attachment->getSupportedAttachmentTypes()); } diff --git a/tests/Api/Message/MessageTest.php b/tests/Api/Message/MessageTest.php index a0831f1..7700915 100644 --- a/tests/Api/Message/MessageTest.php +++ b/tests/Api/Message/MessageTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use DateTime; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Message; use Serhiy\Pushover\Api\Message\Priority; @@ -154,7 +155,7 @@ public function testGetTimestamp(): void { $message = new Message('This is a test message'); - $datetime = new \DateTime(); + $datetime = new DateTime(); $message->setTimestamp($datetime); $this->assertEquals($datetime->getTimestamp(), $message->getTimestamp()); diff --git a/tests/Api/Message/PriorityTest.php b/tests/Api/Message/PriorityTest.php index 166a361..b53dd9b 100644 --- a/tests/Api/Message/PriorityTest.php +++ b/tests/Api/Message/PriorityTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use ReflectionClass; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Priority; @@ -82,7 +83,7 @@ public function testGetCallback(Priority $priority): void #[Depends('testCanBeConstructed')] public function testAvailablePriorities(Priority $priority): void { - $availablePriorities = new \ReflectionClass(Priority::class); + $availablePriorities = new ReflectionClass(Priority::class); $this->assertEquals($availablePriorities->getConstants(), $priority->getAvailablePriorities()); } diff --git a/tests/Api/Message/SoundTest.php b/tests/Api/Message/SoundTest.php index a462f8b..8e573c3 100644 --- a/tests/Api/Message/SoundTest.php +++ b/tests/Api/Message/SoundTest.php @@ -13,6 +13,7 @@ namespace Api\Message; +use ReflectionClass; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Sound; @@ -39,7 +40,7 @@ public function testGetSound(Sound $sound): void #[Depends('testCanBeConstructed')] public function testAvailableSounds(Sound $sound): void { - $availableSounds = new \ReflectionClass(Sound::class); + $availableSounds = new ReflectionClass(Sound::class); $this->assertEquals($availableSounds->getConstants(), $sound->getAvailableSounds()); } diff --git a/tests/Client/Response/ReceiptResponseTest.php b/tests/Client/Response/ReceiptResponseTest.php index b6fcba2..222adf7 100644 --- a/tests/Client/Response/ReceiptResponseTest.php +++ b/tests/Client/Response/ReceiptResponseTest.php @@ -13,6 +13,7 @@ namespace Client\Response; +use DateTime; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Response\ReceiptResponse; @@ -59,13 +60,13 @@ public function testGetAcknowledgedByDevice(ReceiptResponse $response): void #[Depends('testCanBeConstructed')] public function testGetExpiresAt(ReceiptResponse $response): void { - $this->assertInstanceOf(\DateTime::class, $response->getExpiresAt()); + $this->assertInstanceOf(DateTime::class, $response->getExpiresAt()); } #[Depends('testCanBeConstructed')] public function testGetLastDeliveredAt(ReceiptResponse $response): void { - $this->assertInstanceOf(\DateTime::class, $response->getLastDeliveredAt()); + $this->assertInstanceOf(DateTime::class, $response->getLastDeliveredAt()); } #[Depends('testCanBeConstructed')] @@ -77,13 +78,13 @@ public function testIsAcknowledged(ReceiptResponse $response): void #[Depends('testCanBeConstructed')] public function testGetCalledBackAt(ReceiptResponse $response): void { - $this->assertInstanceOf(\DateTime::class, $response->getCalledBackAt()); + $this->assertInstanceOf(DateTime::class, $response->getCalledBackAt()); } #[Depends('testCanBeConstructed')] public function testGetAcknowledgedAt(ReceiptResponse $response): void { - $this->assertInstanceOf(\DateTime::class, $response->getAcknowledgedAt()); + $this->assertInstanceOf(DateTime::class, $response->getAcknowledgedAt()); } #[Depends('testCanBeConstructed')] From 5dc187e39e577bf14094c09557a12714a2fa1016 Mon Sep 17 00:00:00 2001 From: Serhiy Lunak Date: Sun, 1 Sep 2024 10:03:00 +0100 Subject: [PATCH 2/2] Fix cs --- examples/CompleteNotificationExample.php | 3 +- examples/ReceiptExample.php | 9 +++-- src/Api/Licensing/License.php | 3 +- src/Api/Message/Attachment.php | 3 +- src/Api/Message/Message.php | 7 ++-- src/Api/Message/Priority.php | 3 +- src/Api/Message/Sound.php | 3 +- src/Client/GroupsClient.php | 3 +- src/Client/MessageClient.php | 3 +- src/Client/Response/ReceiptResponse.php | 33 +++++++++---------- src/Exception/ExceptionInterface.php | 4 +-- tests/Api/Message/AttachmentTest.php | 3 +- tests/Api/Message/MessageTest.php | 3 +- tests/Api/Message/PriorityTest.php | 3 +- tests/Api/Message/SoundTest.php | 3 +- tests/Client/Response/ReceiptResponseTest.php | 9 +++-- 16 files changed, 39 insertions(+), 56 deletions(-) diff --git a/examples/CompleteNotificationExample.php b/examples/CompleteNotificationExample.php index bd2d18f..bd4fcd6 100644 --- a/examples/CompleteNotificationExample.php +++ b/examples/CompleteNotificationExample.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Example; -use DateTime; use Serhiy\Pushover\Api\Message\Attachment; use Serhiy\Pushover\Api\Message\CustomSound; use Serhiy\Pushover\Api\Message\Message; @@ -44,7 +43,7 @@ public function completeNotification(): void $message->setUrl('https://www.example.com'); $message->setUrlTitle('Example URL'); $message->setisHtml(false); - $message->setTimestamp(new DateTime('now')); + $message->setTimestamp(new \DateTime('now')); $message->setTtl(60 * 60 * 24); // 1 day // assign priority to the notification $message->setPriority(new Priority(Priority::NORMAL)); diff --git a/examples/ReceiptExample.php b/examples/ReceiptExample.php index 48932eb..a6b1a7d 100644 --- a/examples/ReceiptExample.php +++ b/examples/ReceiptExample.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Example; -use DateTime; use Serhiy\Pushover\Api\Receipts\Receipt; use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\Response\CancelRetryResponse; @@ -39,7 +38,7 @@ public function queryEmergencyNotificationReceiptExample(): void if ($response->isSuccessful()) { // True or False whether the user has acknowledged the notification if ($response->isAcknowledged()) { - /** @var DateTime $dateTime Timestamp of when the user acknowledged, or null */ + /** @var \DateTime $dateTime Timestamp of when the user acknowledged, or null */ $acknowledgedAt = $response->getAcknowledgedAt(); /** @var Recipient $recipient User that first acknowledged the notification */ @@ -49,19 +48,19 @@ public function queryEmergencyNotificationReceiptExample(): void $acknowledgedByDevice = $response->getAcknowledgedByDevice(); } - /** @var DateTime $lastDeliveredAt Timestamp of when the notification was last retried, or null */ + /** @var \DateTime $lastDeliveredAt Timestamp of when the notification was last retried, or null */ $lastDeliveredAt = $response->getLastDeliveredAt(); /** @var bool $isExpired True or False whether the expiration date has passed */ $isExpired = $response->isExpired(); - /** @var DateTime $expiresAt Timestamp of when the notification will stop being retried */ + /** @var \DateTime $expiresAt Timestamp of when the notification will stop being retried */ $expiresAt = $response->getExpiresAt(); /** @var bool $hasCalledBack True or False whether our server has called back to your callback URL if any */ $hasCalledBack = $response->hasCalledBack(); - /** @var DateTime $calledBackAt Timestamp of when our server called back, or null */ + /** @var \DateTime $calledBackAt Timestamp of when our server called back, or null */ $calledBackAt = $response->getCalledBackAt(); } } diff --git a/src/Api/Licensing/License.php b/src/Api/Licensing/License.php index 8e332c3..2456e94 100644 --- a/src/Api/Licensing/License.php +++ b/src/Api/Licensing/License.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Api\Licensing; -use ReflectionClass; use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\AssignLicenseClient; use Serhiy\Pushover\Client\CheckLicenseClient; @@ -137,7 +136,7 @@ public function canBeAssigned(): bool */ public static function getAvailableOsTypes(): array { - $oClass = new ReflectionClass(self::class); + $oClass = new \ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Api/Message/Attachment.php b/src/Api/Message/Attachment.php index a053796..b22c796 100644 --- a/src/Api/Message/Attachment.php +++ b/src/Api/Message/Attachment.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Api\Message; -use ReflectionClass; use Serhiy\Pushover\Exception\InvalidArgumentException; /** @@ -96,7 +95,7 @@ public function __construct(string $filename, string $mimeType) */ public static function getSupportedAttachmentTypes(): array { - $oClass = new ReflectionClass(self::class); + $oClass = new \ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Api/Message/Message.php b/src/Api/Message/Message.php index a037bc6..6912dcc 100644 --- a/src/Api/Message/Message.php +++ b/src/Api/Message/Message.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Api\Message; -use DateTime; use Serhiy\Pushover\Exception\InvalidArgumentException; /** @@ -71,7 +70,7 @@ class Message * or delivered to Pushover out of order, this default timestamping may cause a confusing order of messages when viewed on the user's device. * For these scenarios, your app may send messages to the API with the timestamp parameter set to the Unix timestamp of the original message. */ - private DateTime $timestamp; + private \DateTime $timestamp; /** * Normally a message delivered to a device is retained on the device until it is deleted by the user, @@ -93,7 +92,7 @@ public function __construct(string $message, ?string $title = null) $this->setTitle($title); } - $this->timestamp = new DateTime(); + $this->timestamp = new \DateTime(); } public function getMessage(): string @@ -177,7 +176,7 @@ public function getTimestamp(): int return $this->timestamp->getTimestamp(); } - public function setTimestamp(DateTime $timestamp): void + public function setTimestamp(\DateTime $timestamp): void { $this->timestamp = $timestamp; } diff --git a/src/Api/Message/Priority.php b/src/Api/Message/Priority.php index f058e66..602ca91 100644 --- a/src/Api/Message/Priority.php +++ b/src/Api/Message/Priority.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Api\Message; -use ReflectionClass; use Serhiy\Pushover\Exception\InvalidArgumentException; use Serhiy\Pushover\Exception\LogicException; @@ -118,7 +117,7 @@ public function __construct( */ public static function getAvailablePriorities(): array { - $oClass = new ReflectionClass(self::class); + $oClass = new \ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Api/Message/Sound.php b/src/Api/Message/Sound.php index 8fc5b4f..07bbf5c 100644 --- a/src/Api/Message/Sound.php +++ b/src/Api/Message/Sound.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Api\Message; -use ReflectionClass; use Serhiy\Pushover\Exception\InvalidArgumentException; /** @@ -156,7 +155,7 @@ public function __construct( */ public static function getAvailableSounds(): array { - $oClass = new ReflectionClass(self::class); + $oClass = new \ReflectionClass(self::class); return $oClass->getConstants(); } diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index 6fa9418..96ea459 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Client; -use ReflectionClass; use Serhiy\Pushover\Api\Groups\Group; use Serhiy\Pushover\Client\Curl\Curl; use Serhiy\Pushover\Exception\InvalidArgumentException; @@ -106,7 +105,7 @@ public function buildCurlPostFields(?Recipient $recipient = null): array */ private function isActionValid(string $action): bool { - $oClass = new ReflectionClass(self::class); + $oClass = new \ReflectionClass(self::class); if (\in_array($action, $oClass->getConstants(), true)) { return true; diff --git a/src/Client/MessageClient.php b/src/Client/MessageClient.php index da76ebd..4bb6d30 100644 --- a/src/Client/MessageClient.php +++ b/src/Client/MessageClient.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Client; -use CURLFile; use Serhiy\Pushover\Api\Message\Notification; use Serhiy\Pushover\Api\Message\Priority; use Serhiy\Pushover\Client\Curl\Curl; @@ -41,7 +40,7 @@ public function buildApiUrl(): string /** * Builds array for CURLOPT_POSTFIELDS curl argument. * - * @return array + * @return array */ public function buildCurlPostFields(Notification $notification): array { diff --git a/src/Client/Response/ReceiptResponse.php b/src/Client/Response/ReceiptResponse.php index d5df28d..6f3feb4 100644 --- a/src/Client/Response/ReceiptResponse.php +++ b/src/Client/Response/ReceiptResponse.php @@ -13,7 +13,6 @@ namespace Serhiy\Pushover\Client\Response; -use DateTime; use Serhiy\Pushover\Client\Response\Base\Response; use Serhiy\Pushover\Recipient; @@ -32,7 +31,7 @@ class ReceiptResponse extends Response /** * Timestamp of when the user acknowledged, or null. */ - private ?DateTime $acknowledgedAt = null; + private ?\DateTime $acknowledgedAt = null; /** * User that first acknowledged the notification. @@ -47,7 +46,7 @@ class ReceiptResponse extends Response /** * Timestamp of when the notification was last retried, or null. */ - private ?DateTime $lastDeliveredAt = null; + private ?\DateTime $lastDeliveredAt = null; /** * True or False whether the expiration date has passed. @@ -57,7 +56,7 @@ class ReceiptResponse extends Response /** * Timestamp of when the notification will stop being retried. */ - private DateTime $expiresAt; + private \DateTime $expiresAt; /** * True or False whether our server has called back to your callback URL if any. @@ -67,7 +66,7 @@ class ReceiptResponse extends Response /** * Timestamp of when our server called back, or null. */ - private ?DateTime $calledBackAt = null; + private ?\DateTime $calledBackAt = null; public function __construct(string $curlResponse) { @@ -79,7 +78,7 @@ public function isAcknowledged(): bool return $this->isAcknowledged; } - public function getAcknowledgedAt(): ?DateTime + public function getAcknowledgedAt(): ?\DateTime { return $this->acknowledgedAt; } @@ -94,7 +93,7 @@ public function getAcknowledgedByDevice(): string return $this->acknowledgedByDevice; } - public function getLastDeliveredAt(): ?DateTime + public function getLastDeliveredAt(): ?\DateTime { return $this->lastDeliveredAt; } @@ -104,7 +103,7 @@ public function isExpired(): bool return $this->isExpired; } - public function getExpiresAt(): DateTime + public function getExpiresAt(): \DateTime { return $this->expiresAt; } @@ -114,7 +113,7 @@ public function hasCalledBack(): bool return $this->hasCalledBack; } - public function getCalledBackAt(): ?DateTime + public function getCalledBackAt(): ?\DateTime { return $this->calledBackAt; } @@ -124,7 +123,7 @@ private function setIsAcknowledged(bool $isAcknowledged): void $this->isAcknowledged = $isAcknowledged; } - private function setAcknowledgedAt(DateTime $acknowledgedAt): void + private function setAcknowledgedAt(\DateTime $acknowledgedAt): void { $this->acknowledgedAt = $acknowledgedAt; } @@ -139,7 +138,7 @@ private function setAcknowledgedByDevice(string $acknowledgedByDevice): void $this->acknowledgedByDevice = $acknowledgedByDevice; } - private function setLastDeliveredAt(DateTime $lastDeliveredAt): void + private function setLastDeliveredAt(\DateTime $lastDeliveredAt): void { $this->lastDeliveredAt = $lastDeliveredAt; } @@ -149,7 +148,7 @@ private function setIsExpired(bool $isExpired): void $this->isExpired = $isExpired; } - private function setExpiresAt(DateTime $expiresAt): void + private function setExpiresAt(\DateTime $expiresAt): void { $this->expiresAt = $expiresAt; } @@ -159,7 +158,7 @@ private function setHasCalledBack(bool $hasCalledBack): void $this->hasCalledBack = $hasCalledBack; } - private function setCalledBackAt(DateTime $calledBackAt): void + private function setCalledBackAt(\DateTime $calledBackAt): void { $this->calledBackAt = $calledBackAt; } @@ -171,7 +170,7 @@ private function processCurlResponse(string $curlResponse): void if ($this->getRequestStatus() === 1) { if ($decodedCurlResponse->acknowledged === 1) { $this->setIsAcknowledged(true); - $this->setAcknowledgedAt(new DateTime('@'.$decodedCurlResponse->acknowledged_at)); + $this->setAcknowledgedAt(new \DateTime('@'.$decodedCurlResponse->acknowledged_at)); $recipient = new Recipient($decodedCurlResponse->acknowledged_by); $recipient->addDevice($decodedCurlResponse->acknowledged_by_device); @@ -179,7 +178,7 @@ private function processCurlResponse(string $curlResponse): void $this->setAcknowledgedByDevice($recipient->getDeviceListCommaSeparated()); } - $this->setLastDeliveredAt(new DateTime('@'.$decodedCurlResponse->last_delivered_at)); + $this->setLastDeliveredAt(new \DateTime('@'.$decodedCurlResponse->last_delivered_at)); if ($decodedCurlResponse->expired === 1) { $this->setIsExpired(true); @@ -187,11 +186,11 @@ private function processCurlResponse(string $curlResponse): void $this->setIsExpired(false); } - $this->setExpiresAt(new DateTime('@'.$decodedCurlResponse->expires_at)); + $this->setExpiresAt(new \DateTime('@'.$decodedCurlResponse->expires_at)); if ($decodedCurlResponse->called_back === 1) { $this->setHasCalledBack(true); - $this->setCalledBackAt(new DateTime('@'.$decodedCurlResponse->called_back_at)); + $this->setCalledBackAt(new \DateTime('@'.$decodedCurlResponse->called_back_at)); } } } diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index e4b935f..78d9dde 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -13,13 +13,11 @@ namespace Serhiy\Pushover\Exception; -use Throwable; - /** * Base ExceptionInterface for the Pushover component. * * @author Serhiy Lunak */ -interface ExceptionInterface extends Throwable +interface ExceptionInterface extends \Throwable { } diff --git a/tests/Api/Message/AttachmentTest.php b/tests/Api/Message/AttachmentTest.php index adb4eef..fe0ade9 100644 --- a/tests/Api/Message/AttachmentTest.php +++ b/tests/Api/Message/AttachmentTest.php @@ -13,7 +13,6 @@ namespace Api\Message; -use ReflectionClass; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Attachment; @@ -81,7 +80,7 @@ public function testSetFilename(Attachment $attachment): void #[Depends('testCanBeConstructed')] public function testGetSupportedAttachmentTypes(Attachment $attachment): void { - $supportedAttachmentsTypes = new ReflectionClass(Attachment::class); + $supportedAttachmentsTypes = new \ReflectionClass(Attachment::class); $this->assertEquals($supportedAttachmentsTypes->getConstants(), $attachment->getSupportedAttachmentTypes()); } diff --git a/tests/Api/Message/MessageTest.php b/tests/Api/Message/MessageTest.php index 7700915..a0831f1 100644 --- a/tests/Api/Message/MessageTest.php +++ b/tests/Api/Message/MessageTest.php @@ -13,7 +13,6 @@ namespace Api\Message; -use DateTime; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Message; use Serhiy\Pushover\Api\Message\Priority; @@ -155,7 +154,7 @@ public function testGetTimestamp(): void { $message = new Message('This is a test message'); - $datetime = new DateTime(); + $datetime = new \DateTime(); $message->setTimestamp($datetime); $this->assertEquals($datetime->getTimestamp(), $message->getTimestamp()); diff --git a/tests/Api/Message/PriorityTest.php b/tests/Api/Message/PriorityTest.php index b53dd9b..166a361 100644 --- a/tests/Api/Message/PriorityTest.php +++ b/tests/Api/Message/PriorityTest.php @@ -13,7 +13,6 @@ namespace Api\Message; -use ReflectionClass; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Priority; @@ -83,7 +82,7 @@ public function testGetCallback(Priority $priority): void #[Depends('testCanBeConstructed')] public function testAvailablePriorities(Priority $priority): void { - $availablePriorities = new ReflectionClass(Priority::class); + $availablePriorities = new \ReflectionClass(Priority::class); $this->assertEquals($availablePriorities->getConstants(), $priority->getAvailablePriorities()); } diff --git a/tests/Api/Message/SoundTest.php b/tests/Api/Message/SoundTest.php index 8e573c3..a462f8b 100644 --- a/tests/Api/Message/SoundTest.php +++ b/tests/Api/Message/SoundTest.php @@ -13,7 +13,6 @@ namespace Api\Message; -use ReflectionClass; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Api\Message\Sound; @@ -40,7 +39,7 @@ public function testGetSound(Sound $sound): void #[Depends('testCanBeConstructed')] public function testAvailableSounds(Sound $sound): void { - $availableSounds = new ReflectionClass(Sound::class); + $availableSounds = new \ReflectionClass(Sound::class); $this->assertEquals($availableSounds->getConstants(), $sound->getAvailableSounds()); } diff --git a/tests/Client/Response/ReceiptResponseTest.php b/tests/Client/Response/ReceiptResponseTest.php index 222adf7..b6fcba2 100644 --- a/tests/Client/Response/ReceiptResponseTest.php +++ b/tests/Client/Response/ReceiptResponseTest.php @@ -13,7 +13,6 @@ namespace Client\Response; -use DateTime; use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Response\ReceiptResponse; @@ -60,13 +59,13 @@ public function testGetAcknowledgedByDevice(ReceiptResponse $response): void #[Depends('testCanBeConstructed')] public function testGetExpiresAt(ReceiptResponse $response): void { - $this->assertInstanceOf(DateTime::class, $response->getExpiresAt()); + $this->assertInstanceOf(\DateTime::class, $response->getExpiresAt()); } #[Depends('testCanBeConstructed')] public function testGetLastDeliveredAt(ReceiptResponse $response): void { - $this->assertInstanceOf(DateTime::class, $response->getLastDeliveredAt()); + $this->assertInstanceOf(\DateTime::class, $response->getLastDeliveredAt()); } #[Depends('testCanBeConstructed')] @@ -78,13 +77,13 @@ public function testIsAcknowledged(ReceiptResponse $response): void #[Depends('testCanBeConstructed')] public function testGetCalledBackAt(ReceiptResponse $response): void { - $this->assertInstanceOf(DateTime::class, $response->getCalledBackAt()); + $this->assertInstanceOf(\DateTime::class, $response->getCalledBackAt()); } #[Depends('testCanBeConstructed')] public function testGetAcknowledgedAt(ReceiptResponse $response): void { - $this->assertInstanceOf(DateTime::class, $response->getAcknowledgedAt()); + $this->assertInstanceOf(\DateTime::class, $response->getAcknowledgedAt()); } #[Depends('testCanBeConstructed')]