From 16013a9415ac3a75db2f92c536e88214232064e7 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Fri, 24 Jan 2025 20:54:46 -0500 Subject: [PATCH 1/4] Adding PHP-CS-Fixer --- .gitignore | 1 + .php-cs-fixer.dist.php | 8 ++++++++ composer.json | 11 +++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .php-cs-fixer.dist.php diff --git a/.gitignore b/.gitignore index 5add72b3e8..c46fd83fe7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ package.xml docs .phpintel/ tests/.phpunit.result.cache +.php-cs-fixer.cache # You should be keeping these in a global gitignore, see for example # https://help.github.com/articles/ignoring-files#global-gitignore diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000000..3fa7bfeff0 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,8 @@ +setRules(['nullable_type_declaration_for_default_null_value' => true,]); + +return $config->setFinder(PhpCsFixer\Finder::create()->in(__DIR__.'/src')); + diff --git a/composer.json b/composer.json index fa61a9dfba..0b6a9cb1a5 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ }, "require-dev": { "guzzlehttp/guzzle": "^6.3 || ^7.0", - "phpunit/phpunit": ">=7.0 < 10" + "phpunit/phpunit": ">=7.0 < 10", + "friendsofphp/php-cs-fixer": "^3.68" }, "suggest": { "guzzlehttp/guzzle": "An HTTP client to execute the API requests" @@ -32,7 +33,13 @@ "Twilio\\Tests\\": "tests/Twilio/" } }, + "scripts": { + "php84-fix": [ + "@putenv PHP_CS_FIXER_IGNORE_ENV=1", + "vendor/bin/php-cs-fixer -vvv fix --using-cache=no ." + ] + }, "config": { "lock": false } -} \ No newline at end of file +} From 8433c7a6e7165f04033478208e9a24d85ec4b7a4 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Fri, 24 Jan 2025 21:14:43 -0500 Subject: [PATCH 2/4] Test PHP 8.4 --- .github/workflows/test-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index fc94bb5cd2..3870274252 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 ] + php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 ] dependencies: - "lowest" - "highest" From 6507fb3a1259cbaddafbf8c6d8eb99e35e3c26f2 Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Fri, 24 Jan 2025 21:47:20 -0500 Subject: [PATCH 3/4] CS-Fixer V3 will work with PHP 7.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0b6a9cb1a5..702f5bc52d 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require-dev": { "guzzlehttp/guzzle": "^6.3 || ^7.0", "phpunit/phpunit": ">=7.0 < 10", - "friendsofphp/php-cs-fixer": "^3.68" + "friendsofphp/php-cs-fixer": "^3.0" }, "suggest": { "guzzlehttp/guzzle": "An HTTP client to execute the API requests" From 5254a5715873986ebee7a38bb492d3f562aec46a Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Fri, 24 Jan 2025 21:56:38 -0500 Subject: [PATCH 4/4] Update PHPUnit tests to be PHP 8.4 compatible --- tests/Twilio/Holodeck.php | 4 ++-- tests/Twilio/Request.php | 2 +- tests/Twilio/Unit/ValuesTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Twilio/Holodeck.php b/tests/Twilio/Holodeck.php index abccbcf7bb..962ac8fb63 100644 --- a/tests/Twilio/Holodeck.php +++ b/tests/Twilio/Holodeck.php @@ -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); diff --git a/tests/Twilio/Request.php b/tests/Twilio/Request.php index 9d939ffd0f..b3fa14719f 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 70f73163f1..a870fa386e 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 = [];