Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid deprecation messages for PHP 8.4 #834

Merged
merged 8 commits into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3 ]
php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 ]
dependencies:
- "lowest"
- "highest"
24 changes: 12 additions & 12 deletions src/Twilio/Base/BaseClient.php
Original file line number Diff line number Diff line change
@@ -49,13 +49,13 @@ class BaseClient
* @throws ConfigurationException If valid authentication is not present
*/
public function __construct(
string $username = null,
string $password = null,
string $accountSid = null,
string $region = null,
HttpClient $httpClient = null,
array $environment = null,
array $userAgentExtensions = null
?string $username = null,
?string $password = null,
?string $accountSid = null,
?string $region = null,
?HttpClient $httpClient = null,
?array $environment = null,
?array $userAgentExtensions = null
) {
$this->environment = $environment ?: \getenv();

@@ -119,9 +119,9 @@ public function request(
array $params = [],
array $data = [],
array $headers = [],
string $username = null,
string $password = null,
int $timeout = null
?string $username = null,
?string $password = null,
?int $timeout = null
): \Twilio\Http\Response{
$username = $username ?: $this->username;
$password = $password ?: $this->password;
@@ -341,7 +341,7 @@ public function getEdge(): string
*
* @param string $uri Edge to use, unsets the Edge when called with no arguments
*/
public function setEdge(string $edge = null): void
public function setEdge(?string $edge = null): void
{
$this->edge = $this->getArg($edge, self::ENV_EDGE);
}
@@ -381,7 +381,7 @@ public function getLogLevel(): ?string
*
* @param string $logLevel log level to use
*/
public function setLogLevel(string $logLevel = null): void
public function setLogLevel(?string $logLevel = null): void
{
$this->logLevel = $this->getArg($logLevel, self::ENV_LOG);
}
4 changes: 2 additions & 2 deletions src/Twilio/Domain.php
Original file line number Diff line number Diff line change
@@ -57,8 +57,8 @@ public function absoluteUrl(string $uri): string {
*/
public function request(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response {
?string $user = null, ?string $password = null,
?int $timeout = null): Response {
$url = $this->absoluteUrl($uri);
return $this->client->request(
$method,
4 changes: 2 additions & 2 deletions src/Twilio/Http/Client.php
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@
interface Client {
public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response;
?string $user = null, ?string $password = null,
?int $timeout = null): Response;
}
8 changes: 4 additions & 4 deletions src/Twilio/Http/CurlClient.php
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ public function __construct(array $options = []) {

public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response {
?string $user = null, ?string $password = null,
?int $timeout = null): Response {
$options = $this->options($method, $url, $params, $data, $headers,
$user, $password, $timeout);

@@ -85,8 +85,8 @@ public function request(string $method, string $url,

public function options(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): array {
?string $user = null, ?string $password = null,
?int $timeout = null): array {
$timeout = $timeout ?? self::DEFAULT_TIMEOUT;
$options = $this->curlOptions + [
CURLOPT_URL => $url,
2 changes: 1 addition & 1 deletion src/Twilio/Http/File.php
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ final class File {
* @param string|resource|mixed|null $contents
* @param string $contentType
*/
public function __construct(string $fileName, $contents = null, string $contentType = null) {
public function __construct(string $fileName, $contents = null, ?string $contentType = null) {
$this->fileName = $fileName;
$this->contents = $contents;
$this->contentType = $contentType;
4 changes: 2 additions & 2 deletions src/Twilio/Http/GuzzleClient.php
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ public function __construct(ClientInterface $client) {

public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response {
?string $user = null, ?string $password = null,
?int $timeout = null): Response {
try {
$options = [
'timeout' => $timeout,
2 changes: 1 addition & 1 deletion src/Twilio/Jwt/AccessToken.php
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ class AccessToken {
/** @var string[] $customClaims */
private $customClaims;

public function __construct(string $accountSid, string $signingKeySid, string $secret, int $ttl = 3600, string $identity = null, string $region = null) {
public function __construct(string $accountSid, string $signingKeySid, string $secret, int $ttl = 3600, ?string $identity = null, ?string $region = null) {
$this->signingKeySid = $signingKeySid;
$this->accountSid = $accountSid;
$this->secret = $secret;
2 changes: 1 addition & 1 deletion src/Twilio/Jwt/JWT.php
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ class JWT {
* @throws \DomainException
* @throws \UnexpectedValueException
*/
public static function decode(string $jwt, string $key = null, bool $verify = true) {
public static function decode(string $jwt, ?string $key = null, bool $verify = true) {
$tks = \explode('.', $jwt);
if (\count($tks) !== 3) {
throw new \UnexpectedValueException('Wrong number of segments');
2 changes: 1 addition & 1 deletion src/Twilio/Jwt/TaskRouter/CapabilityToken.php
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ class CapabilityToken {
protected $optional = ['required' => false];

public function __construct(string $accountSid, string $authToken, string $workspaceSid, string $channelId,
string $resourceUrl = null, string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
?string $resourceUrl = null, ?string $overrideBaseUrl = null, ?string $overrideBaseWSUrl = null) {
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->friendlyName = $channelId;
2 changes: 1 addition & 1 deletion src/Twilio/Jwt/TaskRouter/TaskQueueCapability.php
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
*/
class TaskQueueCapability extends CapabilityToken {
public function __construct(string $accountSid, string $authToken, string $workspaceSid, string $taskQueueSid,
string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
?string $overrideBaseUrl = null, ?string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $taskQueueSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
}

2 changes: 1 addition & 1 deletion src/Twilio/Jwt/TaskRouter/WorkerCapability.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ class WorkerCapability extends CapabilityToken {
private $activityUrl;

public function __construct(string $accountSid, string $authToken, string $workspaceSid, string $workerSid,
string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
?string $overrideBaseUrl = null, ?string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $workerSid, null, $overrideBaseUrl, $overrideBaseWSUrl);

$this->tasksUrl = $this->baseUrl . '/Tasks/**';
2 changes: 1 addition & 1 deletion src/Twilio/Jwt/TaskRouter/WorkspaceCapability.php
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

class WorkspaceCapability extends CapabilityToken {
public function __construct(string $accountSid, string $authToken, string $workspaceSid,
string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
?string $overrideBaseUrl = null, ?string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $workspaceSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
}

2 changes: 1 addition & 1 deletion src/Twilio/Page.php
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ protected function hasMeta(string $key): bool {
return \array_key_exists('meta', $this->payload) && \array_key_exists($key, $this->payload['meta']);
}

protected function getMeta(string $key, string $default = null): ?string {
protected function getMeta(string $key, ?string $default = null): ?string {
return $this->hasMeta($key) ? $this->payload['meta'][$key] : $default;
}

2 changes: 1 addition & 1 deletion src/Twilio/TaskRouter/WorkflowRule.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ class WorkflowRule implements \JsonSerializable {
public $friendly_name;
public $targets;

public function __construct(string $expression, array $targets, string $friendly_name = null) {
public function __construct(string $expression, array $targets, ?string $friendly_name = null) {
$this->expression = $expression;
$this->targets = $targets;
$this->friendly_name = $friendly_name;
2 changes: 1 addition & 1 deletion src/Twilio/TaskRouter/WorkflowRuleTarget.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ class WorkflowRuleTarget implements \JsonSerializable {
public $priority;
public $timeout;

public function __construct(string $queue, int $priority = null, int $timeout = null, string $expression = null) {
public function __construct(string $queue, ?int $priority = null, ?int $timeout = null, ?string $expression = null) {
$this->queue = $queue;
$this->priority = $priority;
$this->timeout = $timeout;
2 changes: 2 additions & 0 deletions src/Twilio/TwiML/GenericNode.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@

class GenericNode extends TwiML {

protected $value;

/**
* GenericNode constructor.
*
4 changes: 2 additions & 2 deletions src/Twilio/TwiML/TwiML.php
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ abstract class TwiML {
* @param string $value XML value
* @param array $attributes XML attributes
*/
public function __construct(string $name, string $value = null, array $attributes = []) {
public function __construct(string $name, ?string $value = null, array $attributes = []) {
$this->name = $name;
$this->attributes = $attributes;
$this->children = [];
@@ -73,7 +73,7 @@ public function setAttribute(string $key, string $value): TwiML {
* @param array $attributes XML attributes
* @return TwiML
*/
public function addChild(string $name, string $value = null, array $attributes = []): TwiML {
public function addChild(string $name, ?string $value = null, array $attributes = []): TwiML {
return $this->nest(new GenericNode($name, $value, $attributes));
}

2 changes: 1 addition & 1 deletion src/Twilio/Values.php
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ class Values implements \ArrayAccess {
protected $options;
private static $noneConstants = array(self::NONE, self::ARRAY_NONE, self::INT_NONE, self::BOOL_NONE);

public static function array_get(array $array, string $key, string $default = null) {
public static function array_get(array $array, string $key, ?string $default = null) {
if (\array_key_exists($key, $array)) {
return $array[$key];
}
28 changes: 14 additions & 14 deletions src/Twilio/Version.php
Original file line number Diff line number Diff line change
@@ -50,8 +50,8 @@ public function relativeUri(string $uri): string {

public function request(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $username = null, string $password = null,
int $timeout = null): Response {
?string $username = null, ?string $password = null,
?int $timeout = null): Response {
$uri = $this->relativeUri($uri);
return $this->getDomain()->request(
$method,
@@ -96,8 +96,8 @@ protected function exception(Response $response, string $header): TwilioExceptio
*/
public function fetch(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $username = null, string $password = null,
int $timeout = null) {
?string $username = null, ?string $password = null,
?int $timeout = null) {
$response = $this->request(
$method,
$uri,
@@ -122,8 +122,8 @@ public function fetch(string $method, string $uri,
*/
public function update(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $username = null, string $password = null,
int $timeout = null) {
?string $username = null, ?string $password = null,
?int $timeout = null) {
$response = $this->request(
$method,
$uri,
@@ -147,8 +147,8 @@ public function update(string $method, string $uri,
*/
public function delete(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $username = null, string $password = null,
int $timeout = null): bool {
?string $username = null, ?string $password = null,
?int $timeout = null): bool {
$response = $this->request(
$method,
$uri,
@@ -167,7 +167,7 @@ public function delete(string $method, string $uri,
return $response->getStatusCode() === 204;
}

public function readLimits(int $limit = null, int $pageSize = null): array {
public function readLimits(?int $limit = null, ?int $pageSize = null): array {
if ($limit && $pageSize === null) {
$pageSize = $limit;
}
@@ -183,8 +183,8 @@ public function readLimits(int $limit = null, int $pageSize = null): array {

public function page(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $username = null, string $password = null,
int $timeout = null): Response {
?string $username = null, ?string $password = null,
?int $timeout = null): Response {
return $this->request(
$method,
$uri,
@@ -197,7 +197,7 @@ public function page(string $method, string $uri,
);
}

public function stream(Page $page, $limit = null, $pageLimit = null): Stream {
public function stream(Page $page, ?int $limit = null, ?int $pageLimit = null): Stream {
return new Stream($page, $limit, $pageLimit);
}

@@ -206,8 +206,8 @@ public function stream(Page $page, $limit = null, $pageLimit = null): Stream {
*/
public function create(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $username = null, string $password = null,
int $timeout = null) {
?string $username = null, ?string $password = null,
?int $timeout = null) {
$response = $this->request(
$method,
$uri,
2 changes: 1 addition & 1 deletion tests/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

\error_reporting(E_ALL | E_STRICT);
\error_reporting(E_ALL);
\ini_set('display_errors', 1);

$root = \realpath(\dirname(__DIR__));
4 changes: 2 additions & 2 deletions tests/Twilio/Holodeck.php
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@ class Holodeck implements Client {

public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response {
?string $user = null, ?string $password = null,
?int $timeout = null): Response {
$this->requests[] = new Request($method, $url, $params, $data, $headers, $user, $password);
if (\count($this->responses) === 0) {
return new Response(404, null, null);
2 changes: 1 addition & 1 deletion tests/Twilio/Request.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ class Request {

public function __construct(string $method, string $url,
?array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null) {
?string $user = null, ?string $password = null) {
$this->method = $method;
$this->url = $url;
$this->params = $params;
2 changes: 1 addition & 1 deletion tests/Twilio/Unit/ValuesTest.php
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ private function testPassingValues(
int $intVal = Values::INT_NONE,
bool $boolVal = Values::BOOL_NONE,
string $stringVal = Values::NONE,
\DateTime $dateTimeVal = null
?\DateTime $dateTimeVal = null
): array
{
$arr = [];