From d46e65ace0617b7477b10ecd3d43cc73d94a1f04 Mon Sep 17 00:00:00 2001 From: Dejan Gavrilovic Date: Thu, 11 Dec 2025 12:59:10 +0100 Subject: [PATCH] php 8.4 code adjustments --- .github/workflows/test.yml | 2 +- composer.json | 2 +- src/APIException.php | 3 ++- src/Http/HttpCallBack.php | 2 +- src/Http/HttpRequest.php | 2 +- src/Messaging/Controllers/APIController.php | 24 ++++++++++----------- src/Voice/Controllers/APIController.php | 22 +++++++++---------- src/WebRtc/Controllers/APIController.php | 8 +++---- 8 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e503de..669c386 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [windows-2022, windows-2025, ubuntu-22.04, ubuntu-24.04] - php-version: [8.0, 8.1, 8.2, 8.3] + php-version: [8.0, 8.1, 8.2, 8.3, 8.4] steps: - name: Checkout uses: actions/checkout@v5 diff --git a/composer.json b/composer.json index 8944e38..213e6f8 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "require": { "ext-SimpleXML": "*", - "php": ">=7.2.0", + "php": ">=8.4.0", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*", diff --git a/src/APIException.php b/src/APIException.php index cbd2462..55ae203 100644 --- a/src/APIException.php +++ b/src/APIException.php @@ -35,9 +35,10 @@ public function __construct($reason, $context) $this->context = $context; $this->errorMessage = $reason; - if (get_class() != 'APIException') { + if (static::class !== 'BandwidthLib\APIException') { $this->unbox(); } + } /** diff --git a/src/Http/HttpCallBack.php b/src/Http/HttpCallBack.php index aa00bef..eb0cc1e 100644 --- a/src/Http/HttpCallBack.php +++ b/src/Http/HttpCallBack.php @@ -29,7 +29,7 @@ class HttpCallBack * @param callable|null $onBeforeRequest Called before an API call * @param callable|null $onAfterRequest Called after an API call */ - public function __construct(callable $onBeforeRequest = null, callable $onAfterRequest = null) + public function __construct(?callable $onBeforeRequest = null, ?callable $onAfterRequest = null) { $this->onBeforeRequest = $onBeforeRequest; $this->onAfterRequest = $onAfterRequest; diff --git a/src/Http/HttpRequest.php b/src/Http/HttpRequest.php index a1ba9c9..a65baf3 100644 --- a/src/Http/HttpRequest.php +++ b/src/Http/HttpRequest.php @@ -43,7 +43,7 @@ class HttpRequest * @param string|null $queryUrl Query url * @param array|null $parameters Map of parameters sent */ - public function __construct(string $httpMethod = null, array $headers = null, string $queryUrl = null, array $parameters = null) + public function __construct(?string $httpMethod = null, ?array $headers = null, ?string $queryUrl = null, ?array $parameters = null) { $this->httpMethod = $httpMethod; $this->headers = $headers; diff --git a/src/Messaging/Controllers/APIController.php b/src/Messaging/Controllers/APIController.php index 9a67190..5be434f 100644 --- a/src/Messaging/Controllers/APIController.php +++ b/src/Messaging/Controllers/APIController.php @@ -40,7 +40,7 @@ public function __construct($config, $httpCallBack = null) */ public function listMedia( string $accountId, - string $continuationToken = null + ?string $continuationToken = null ) { //prepare query string for API call @@ -225,7 +225,7 @@ public function uploadMedia( string $mediaId, string $body, string $contentType = 'application/octet-stream', - string $cacheControl = null + ?string $cacheControl = null ) { //prepare query string for API call @@ -418,16 +418,16 @@ public function deleteMedia( * @throws APIException Thrown if API call fails */ public function getMessages( - string $accountId, - string $messageId = null, - string $sourceTn = null, - string $destinationTn = null, - string $messageStatus = null, - int $errorCode = null, - string $fromDateTime = null, - string $toDateTime = null, - string $pageToken = null, - int $limit = null + string $accountId, + ?string $messageId = null, + ?string $sourceTn = null, + ?string $destinationTn = null, + ?string $messageStatus = null, + ?int $errorCode = null, + ?string $fromDateTime = null, + ?string $toDateTime = null, + ?string $pageToken = null, + ?int $limit = null ) { //prepare query string for API call diff --git a/src/Voice/Controllers/APIController.php b/src/Voice/Controllers/APIController.php index f5069da..d205274 100644 --- a/src/Voice/Controllers/APIController.php +++ b/src/Voice/Controllers/APIController.php @@ -1492,12 +1492,12 @@ public function deleteCallTranscription( * @throws APIException Thrown if API call fails */ public function getConferences( - string $accountId, - string $name = null, - string $minCreatedTime = null, - string $maxCreatedTime = null, - int $pageSize = 1000, - string $pageToken = null + string $accountId, + ?string $name = null, + ?string $minCreatedTime = null, + ?string $maxCreatedTime = null, + int $pageSize = 1000, + ?string $pageToken = null ) { //prepare query string for API call @@ -2403,11 +2403,11 @@ public function getDownloadConferenceRecording( * @throws APIException Thrown if API call fails */ public function getQueryCallRecordings( - string $accountId, - string $from = null, - string $to = null, - string $minStartTime = null, - string $maxStartTime = null + string $accountId, + ?string $from = null, + ?string $to = null, + ?string $minStartTime = null, + ?string $maxStartTime = null ) { //prepare query string for API call diff --git a/src/WebRtc/Controllers/APIController.php b/src/WebRtc/Controllers/APIController.php index 354e85c..d802f5d 100644 --- a/src/WebRtc/Controllers/APIController.php +++ b/src/WebRtc/Controllers/APIController.php @@ -43,7 +43,7 @@ public function __construct($config, $httpCallBack = null) */ public function createParticipant( string $accountId, - Models\Participant $body = null + ?Models\Participant $body = null ) { //prepare query string for API call @@ -283,7 +283,7 @@ public function deleteParticipant( */ public function createSession( string $accountId, - Models\Session $body = null + ?Models\Session $body = null ) { //prepare query string for API call @@ -602,7 +602,7 @@ public function addParticipantToSession( string $accountId, string $sessionId, string $participantId, - Models\Subscriptions $body = null + ?Models\Subscriptions $body = null ) { //prepare query string for API call @@ -854,7 +854,7 @@ public function updateParticipantSubscriptions( string $accountId, string $sessionId, string $participantId, - Models\Subscriptions $body = null + ?Models\Subscriptions $body = null ) { //prepare query string for API call