From 1df304cd03453a9e9a21ba1134cf5bc3237d69f1 Mon Sep 17 00:00:00 2001 From: Shubham Date: Wed, 8 Jan 2025 16:16:01 +0530 Subject: [PATCH] chore: revert 'fix: avoid deprecation messages for PHP 8.4' (#837) --- .github/workflows/test-and-deploy.yml | 2 +- src/Twilio/Base/BaseClient.php | 24 ++++++++-------- src/Twilio/Domain.php | 4 +-- src/Twilio/Http/Client.php | 4 +-- src/Twilio/Http/CurlClient.php | 8 +++--- src/Twilio/Http/File.php | 2 +- src/Twilio/Http/GuzzleClient.php | 4 +-- src/Twilio/Jwt/AccessToken.php | 2 +- src/Twilio/Jwt/JWT.php | 2 +- src/Twilio/Jwt/TaskRouter/CapabilityToken.php | 2 +- .../Jwt/TaskRouter/TaskQueueCapability.php | 2 +- .../Jwt/TaskRouter/WorkerCapability.php | 2 +- .../Jwt/TaskRouter/WorkspaceCapability.php | 2 +- src/Twilio/Page.php | 2 +- src/Twilio/TaskRouter/WorkflowRule.php | 2 +- src/Twilio/TaskRouter/WorkflowRuleTarget.php | 2 +- src/Twilio/TwiML/GenericNode.php | 2 -- src/Twilio/TwiML/TwiML.php | 4 +-- src/Twilio/Values.php | 2 +- src/Twilio/Version.php | 28 +++++++++---------- tests/Bootstrap.php | 2 +- tests/Twilio/Holodeck.php | 4 +-- tests/Twilio/Request.php | 2 +- tests/Twilio/Unit/ValuesTest.php | 2 +- 24 files changed, 55 insertions(+), 57 deletions(-) diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 3870274252..fc94bb5cd2 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -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, 8.4 ] + php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3 ] dependencies: - "lowest" - "highest" diff --git a/src/Twilio/Base/BaseClient.php b/src/Twilio/Base/BaseClient.php index 7ec0f35ca4..d19fdb2db1 100644 --- a/src/Twilio/Base/BaseClient.php +++ b/src/Twilio/Base/BaseClient.php @@ -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); } diff --git a/src/Twilio/Domain.php b/src/Twilio/Domain.php index 82bc66db9f..cbf6dd263a 100644 --- a/src/Twilio/Domain.php +++ b/src/Twilio/Domain.php @@ -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, diff --git a/src/Twilio/Http/Client.php b/src/Twilio/Http/Client.php index eb11478cb8..9f3d103226 100644 --- a/src/Twilio/Http/Client.php +++ b/src/Twilio/Http/Client.php @@ -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; } diff --git a/src/Twilio/Http/CurlClient.php b/src/Twilio/Http/CurlClient.php index 8000376895..aaf99f2aaf 100644 --- a/src/Twilio/Http/CurlClient.php +++ b/src/Twilio/Http/CurlClient.php @@ -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, diff --git a/src/Twilio/Http/File.php b/src/Twilio/Http/File.php index 0fc61d5e97..304e772137 100644 --- a/src/Twilio/Http/File.php +++ b/src/Twilio/Http/File.php @@ -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; diff --git a/src/Twilio/Http/GuzzleClient.php b/src/Twilio/Http/GuzzleClient.php index fe070165e1..8b88b09f8c 100644 --- a/src/Twilio/Http/GuzzleClient.php +++ b/src/Twilio/Http/GuzzleClient.php @@ -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, diff --git a/src/Twilio/Jwt/AccessToken.php b/src/Twilio/Jwt/AccessToken.php index 223101062c..4ac8a3f43f 100644 --- a/src/Twilio/Jwt/AccessToken.php +++ b/src/Twilio/Jwt/AccessToken.php @@ -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; diff --git a/src/Twilio/Jwt/JWT.php b/src/Twilio/Jwt/JWT.php index 3d14f83c68..8e1cbd24ce 100644 --- a/src/Twilio/Jwt/JWT.php +++ b/src/Twilio/Jwt/JWT.php @@ -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'); diff --git a/src/Twilio/Jwt/TaskRouter/CapabilityToken.php b/src/Twilio/Jwt/TaskRouter/CapabilityToken.php index 3136ab13e4..e2ed051c7c 100644 --- a/src/Twilio/Jwt/TaskRouter/CapabilityToken.php +++ b/src/Twilio/Jwt/TaskRouter/CapabilityToken.php @@ -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; diff --git a/src/Twilio/Jwt/TaskRouter/TaskQueueCapability.php b/src/Twilio/Jwt/TaskRouter/TaskQueueCapability.php index ce7eaef066..51ca2d08fe 100644 --- a/src/Twilio/Jwt/TaskRouter/TaskQueueCapability.php +++ b/src/Twilio/Jwt/TaskRouter/TaskQueueCapability.php @@ -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); } diff --git a/src/Twilio/Jwt/TaskRouter/WorkerCapability.php b/src/Twilio/Jwt/TaskRouter/WorkerCapability.php index 50fc981068..2bde217bbe 100644 --- a/src/Twilio/Jwt/TaskRouter/WorkerCapability.php +++ b/src/Twilio/Jwt/TaskRouter/WorkerCapability.php @@ -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/**'; diff --git a/src/Twilio/Jwt/TaskRouter/WorkspaceCapability.php b/src/Twilio/Jwt/TaskRouter/WorkspaceCapability.php index 64e198d572..c644ec1667 100644 --- a/src/Twilio/Jwt/TaskRouter/WorkspaceCapability.php +++ b/src/Twilio/Jwt/TaskRouter/WorkspaceCapability.php @@ -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); } diff --git a/src/Twilio/Page.php b/src/Twilio/Page.php index 74bae62d42..df59add088 100644 --- a/src/Twilio/Page.php +++ b/src/Twilio/Page.php @@ -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; } diff --git a/src/Twilio/TaskRouter/WorkflowRule.php b/src/Twilio/TaskRouter/WorkflowRule.php index 07ae386c49..0183882ecc 100644 --- a/src/Twilio/TaskRouter/WorkflowRule.php +++ b/src/Twilio/TaskRouter/WorkflowRule.php @@ -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; diff --git a/src/Twilio/TaskRouter/WorkflowRuleTarget.php b/src/Twilio/TaskRouter/WorkflowRuleTarget.php index d9a13b03fd..c84fbbcdfc 100644 --- a/src/Twilio/TaskRouter/WorkflowRuleTarget.php +++ b/src/Twilio/TaskRouter/WorkflowRuleTarget.php @@ -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; diff --git a/src/Twilio/TwiML/GenericNode.php b/src/Twilio/TwiML/GenericNode.php index 6e22a1fee3..6eead6c879 100644 --- a/src/Twilio/TwiML/GenericNode.php +++ b/src/Twilio/TwiML/GenericNode.php @@ -4,8 +4,6 @@ class GenericNode extends TwiML { - protected $value; - /** * GenericNode constructor. * diff --git a/src/Twilio/TwiML/TwiML.php b/src/Twilio/TwiML/TwiML.php index d8715201c8..6e8ceb4a79 100644 --- a/src/Twilio/TwiML/TwiML.php +++ b/src/Twilio/TwiML/TwiML.php @@ -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)); } diff --git a/src/Twilio/Values.php b/src/Twilio/Values.php index c4ea33b65d..7d6ba964c5 100644 --- a/src/Twilio/Values.php +++ b/src/Twilio/Values.php @@ -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]; } diff --git a/src/Twilio/Version.php b/src/Twilio/Version.php index 5b2f274113..d0ede2f247 100644 --- a/src/Twilio/Version.php +++ b/src/Twilio/Version.php @@ -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, ?int $limit = null, ?int $pageLimit = null): Stream { + public function stream(Page $page, $limit = null, $pageLimit = null): Stream { return new Stream($page, $limit, $pageLimit); } @@ -206,8 +206,8 @@ public function stream(Page $page, ?int $limit = null, ?int $pageLimit = null): */ 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, diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index ea0e814478..62a676edc0 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -1,6 +1,6 @@ requests[] = new Request($method, $url, $params, $data, $headers, $user, $password); if (\count($this->responses) === 0) { return new Response(404, null, null); diff --git a/tests/Twilio/Request.php b/tests/Twilio/Request.php index b3fa14719f..9d939ffd0f 100644 --- a/tests/Twilio/Request.php +++ b/tests/Twilio/Request.php @@ -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; diff --git a/tests/Twilio/Unit/ValuesTest.php b/tests/Twilio/Unit/ValuesTest.php index a870fa386e..70f73163f1 100644 --- a/tests/Twilio/Unit/ValuesTest.php +++ b/tests/Twilio/Unit/ValuesTest.php @@ -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 = [];