Skip to content

Commit

Permalink
PHP8.4 nullcheck fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK committed Dec 3, 2024
1 parent 3dcc2b5 commit 7f13bff
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/Account/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Config implements
public function __construct(
?string $sms_callback_url = null,
?string $dr_callback_url = null,
int|string $max_outbound_request = null,
int|string $max_inbound_request = null,
int|string $max_calls_per_second = null
int|string|null $max_outbound_request = null,
int|string|null $max_inbound_request = null,
int|string|null $max_calls_per_second = null
) {
if (!is_null($sms_callback_url)) {
$this->data['sms_callback_url'] = $sms_callback_url;
Expand Down
8 changes: 7 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ public function __construct(
// Disable throwing E_USER_DEPRECATED notices by default, the user can turn it on during development
if (array_key_exists('show_deprecations', $this->options) && ($this->options['show_deprecations'] == true)) {
set_error_handler(
static fn (int $errno, string $errstr, string $errfile = null, int $errline = null, array $errorcontext = null) => true,
static fn (
int $errno,
string $errstr,
?string $errfile = null,
?int $errline = null,
?array $errorcontext = null
) => true,
E_USER_DEPRECATED
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/Conversation/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public function getAPIResource(): APIResource
return $this->api;
}

public function listConversations(ListConversationFilter $conversationFilter = null): IterableAPICollection
{
public function listConversations(
?ListConversationFilter $conversationFilter = null
): IterableAPICollection {
if (!$conversationFilter) {
$conversationFilter = new ListConversationFilter();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Numbers/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function get(string $number): Number
* @throws ClientException\Request
* @throws ClientException\Server
*/
public function searchAvailable(string $country, FilterInterface $options = null): array
public function searchAvailable(string $country, ?FilterInterface $options = null): array
{
if (is_null($options)) {
$options = new AvailableNumbers([
Expand Down Expand Up @@ -134,7 +134,7 @@ public function searchAvailable(string $country, FilterInterface $options = null
* @throws ClientException\Request
* @throws ClientException\Server
*/
public function searchOwned($number = null, FilterInterface $options = null): array
public function searchOwned($number = null, ?FilterInterface $options = null): array
{
if ($number !== null) {
if ($options !== null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Subaccount/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function updateSubaccount(string $apiKey, string $subaccountApiKey, Accou
return $this->api->partiallyUpdate($apiKey . '/subaccounts/' . $subaccountApiKey, $account->toArray());
}

public function getCreditTransfers(string $apiKey, FilterInterface $filter = null): mixed
public function getCreditTransfers(string $apiKey, ?FilterInterface $filter = null): mixed
{
if (!$filter) {
$filter = new EmptyFilter();
Expand All @@ -101,7 +101,7 @@ public function getCreditTransfers(string $apiKey, FilterInterface $filter = nul
return array_map(fn ($item) => $hydrator->hydrate($item), $transfers);
}

public function getBalanceTransfers(string $apiKey, FilterInterface $filter = null): mixed
public function getBalanceTransfers(string $apiKey, ?FilterInterface $filter = null): mixed
{
if (!$filter) {
$filter = new EmptyFilter();
Expand Down
2 changes: 1 addition & 1 deletion src/Users/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getApiResource(): APIResource
return $this->api;
}

public function listUsers(FilterInterface $filter = null): IterableAPICollection
public function listUsers(?FilterInterface $filter = null): IterableAPICollection
{
if (is_null($filter)) {
$filter = new EmptyFilter();
Expand Down
2 changes: 1 addition & 1 deletion src/Verify/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function trigger($verification): Verification
* @throws ClientException\Request
* @throws ClientException\Server
*/
public function check(Verification|array|string $verification, string $code, string $ip = null): Verification
public function check(Verification|array|string $verification, string $code, ?string $ip = null): Verification
{
if (is_array($verification)) {
trigger_error(
Expand Down
2 changes: 1 addition & 1 deletion src/Verify/RequestPSD2.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
protected string $number,
protected string $payee,
protected string $amount,
int $workflowId = null
?int $workflowId = null
) {
if ($workflowId) {
$this->setWorkflowId($workflowId);
Expand Down
4 changes: 2 additions & 2 deletions src/Verify2/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function isSilentAuthRequest(BaseVerifyRequest $request): bool
return false;
}

public function listCustomTemplates(TemplateFilter $filter = null): IterableAPICollection
public function listCustomTemplates(?TemplateFilter $filter = null): IterableAPICollection
{
$collection = $this->api->search($filter, '/templates');
$collection->setNaiveCount(true);
Expand Down Expand Up @@ -158,7 +158,7 @@ public function deleteCustomTemplateFragment(string $templateId, string $fragmen
return true;
}

public function listTemplateFragments(string $templateId, TemplateFilter $filter = null): IterableAPICollection
public function listTemplateFragments(string $templateId, ?TemplateFilter $filter = null): IterableAPICollection
{
$api = clone $this->getAPIResource();
$api->setCollectionName('template_fragments');
Expand Down
2 changes: 1 addition & 1 deletion src/Voice/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function playTTS(string $callId, Talk $action): array
return $this->api->update($callId . '/talk', $payload);
}

public function search(FilterInterface $filter = null): IterableAPICollection
public function search(?FilterInterface $filter = null): IterableAPICollection
{
$response = $this->api->search($filter);
$response->setApiResource(clone $this->api);
Expand Down
2 changes: 1 addition & 1 deletion test/ProactiveConnect/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public function testWillDownloadItemCsv(): void
fwrite($handle, (string) $response->getContents());
fseek($handle, 0);

while (($row = fgetcsv($handle)) !== false) {
while (($row = fgetcsv($handle, 0, ',', '"', '\\')) !== false) {
if (!$header) {
$header = $row;
} else {
Expand Down

0 comments on commit 7f13bff

Please sign in to comment.