From 8c0a15ceefcb227ee780271964ae37045a9190da Mon Sep 17 00:00:00 2001 From: iv-craig Date: Mon, 16 Dec 2024 14:47:49 -0500 Subject: [PATCH 1/2] Add PHP 8.4 to workflow matrices --- .github/workflows/phpstan.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index b389ed0..886806f 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.3] + php: [8.3, 8.4] steps: - name: Checkout code diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 727f155..88428ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.1, 8.2, 8.3] + php: [8.1, 8.2, 8.3, 8.4] name: Tests on PHP ${{ matrix.php }} - ${{ matrix.stability }} From e47169ea79820b25d64d6ae4c27d95f65ac3994b Mon Sep 17 00:00:00 2001 From: iv-craig Date: Mon, 16 Dec 2024 15:53:28 -0500 Subject: [PATCH 2/2] Address static analysis issues for PHP 8.4 --- src/Exceptions/CouldNotSendNotification.php | 34 ++++++++++++--------- src/InterfaxFile.php | 3 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Exceptions/CouldNotSendNotification.php b/src/Exceptions/CouldNotSendNotification.php index 3931a3e..465b4c3 100644 --- a/src/Exceptions/CouldNotSendNotification.php +++ b/src/Exceptions/CouldNotSendNotification.php @@ -3,6 +3,7 @@ namespace NotificationChannels\Interfax\Exceptions; use Exception; +use Throwable; use NotificationChannels\Interfax\InterfaxMessage; class CouldNotSendNotification extends Exception @@ -13,29 +14,34 @@ class CouldNotSendNotification extends Exception protected array $responseAttributes; /** - * @param string $message - * @param int $code - * @param Exception|null $previous - * @param InterfaxMessage $interfaxMessage - * @param array $responseAttributes + * @param InterfaxMessage $message + * @param array $responseAttributes + * @param string $exceptionMessage + * @return CouldNotSendNotification */ - final public function __construct(string $message, int $code, Exception $previous = null, InterfaxMessage $interfaxMessage, array $responseAttributes) + public static function serviceRespondedWithAnError(InterfaxMessage $message, array $responseAttributes, string $exceptionMessage = 'The fax failed to send via InterFAX.') { - parent::__construct($message, $code, $previous); + $exception = new self($exceptionMessage, $responseAttributes['status'], null); + $exception->setInterfaxMessage($message); + $exception->setResponseAttributes($responseAttributes); + + return $exception; + } + /** + * @param InterfaxMessage $interfaxMessage + */ + public function setInterfaxMessage(InterfaxMessage $interfaxMessage): void + { $this->interfaxMessage = $interfaxMessage; - $this->responseAttributes = $responseAttributes; } /** - * @param InterfaxMessage $message - * @param array $responseAttributes - * @param string $exceptionMessage - * @return CouldNotSendNotification + * @param array $responseAttributes */ - public static function serviceRespondedWithAnError(InterfaxMessage $message, array $responseAttributes, string $exceptionMessage = 'The fax failed to send via InterFAX.') + public function setResponseAttributes(array $responseAttributes): void { - return new static($exceptionMessage, $responseAttributes['status'], null, $message, $responseAttributes); + $this->responseAttributes = $responseAttributes; } /** diff --git a/src/InterfaxFile.php b/src/InterfaxFile.php index 75e1112..5d7465e 100644 --- a/src/InterfaxFile.php +++ b/src/InterfaxFile.php @@ -7,12 +7,13 @@ class InterfaxFile extends \Interfax\File /** * File constructor. * + * @param \Interfax\Client $client * @param resource|string $location * @param array $params * * @throws \InvalidArgumentException */ - public function __construct(\Interfax\Client $client, $location, $params = [], \Interfax\GenericFactory $factory = null) + public function __construct(\Interfax\Client $client, $location, $params = [], ?\Interfax\GenericFactory $factory = null) { if ($chunkSize = config('services.interfax.chunk_size')) { static::$DEFAULT_CHUNK_SIZE = $chunkSize;