From a76042d2272be40e901e20604cf59a1b3e504ade Mon Sep 17 00:00:00 2001 From: Paul Mitchum Date: Wed, 12 Jun 2024 12:34:41 -0700 Subject: [PATCH] Support PHP 8.3 (#21) --- .circleci/config.yml | 8 +++---- .editorconfig | 17 ++++++++++++++ composer.json | 4 ++-- rector.php | 40 ++++++++++++++++----------------- src/ETL/Load/Load.php | 2 -- src/ETL/Transform/Transform.php | 2 -- src/Harvester.php | 1 - test/json/data.json | 2 +- 8 files changed, 43 insertions(+), 33 deletions(-) create mode 100644 .editorconfig diff --git a/.circleci/config.yml b/.circleci/config.yml index 287abc6..8219296 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -143,7 +143,7 @@ jobs: tag: << parameters.version >> parameters: version: - default: "7.4" + default: "8.3" description: The `cimg/php` Docker image version tag. type: string install-flags: @@ -154,7 +154,7 @@ jobs: - when: condition: and: - - equal: [ "8.1", <> ] + - equal: [ "8.3", <> ] - equal: [ "", <> ] steps: - run-phpunit-tests: @@ -164,7 +164,7 @@ jobs: condition: not: and: - - equal: [ "8.1", <> ] + - equal: [ "8.3", <> ] - equal: [ "", <> ] steps: - run-phpunit-tests: @@ -176,5 +176,5 @@ workflows: - matrix-conditions: matrix: parameters: - version: [ "8.2", "7.4", "8.0", "8.1" ] + version: [ "8.3", "8.2", "7.4", "8.0", "8.1" ] install-flags: [ "", "--prefer-lowest" ] diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..deef668 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# @see http://editorconfig.org/ + +# This is the top-most .editorconfig file; do not search in parent directories. +root = true + +# All files. +[*] +end_of_line = LF +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[test/json/*.json] +indent_style = space +indent_size = 2 diff --git a/composer.json b/composer.json index 334be4b..1a44132 100644 --- a/composer.json +++ b/composer.json @@ -6,12 +6,12 @@ "require": { "php": ">7.3 <9.0", "ext-json": "*", - "getdkan/contracts": "^1.1.2", + "getdkan/contracts": "^1.1.3", "guzzlehttp/guzzle": "^6.5.8 || >7.4.5", "opis/json-schema": "^1.0.8" }, "require-dev": { - "phpunit/phpunit": ">7.5 <8.5 || >=8.5.14 <10.0.0", + "phpunit/phpunit": "^9.6", "rector/rector": "^0.15.19", "squizlabs/php_codesniffer": "^3.7", "symfony/phpunit-bridge": "^7.0" diff --git a/rector.php b/rector.php index 53fe609..1236e6d 100644 --- a/rector.php +++ b/rector.php @@ -3,44 +3,42 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Core\ValueObject\PhpVersion; use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector; use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector; use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector; use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Set\ValueObject\SetList; -use Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector; return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ - __DIR__ . '/src', - __DIR__ . '/test', + __DIR__ . '/src', + __DIR__ . '/test', + __DIR__ . 'rector.php', ]); - // Our base version of PHP. - $rectorConfig->phpVersion(PhpVersion::PHP_74); - $rectorConfig->sets([ - SetList::PHP_82, - // Please no dead code or unneeded variables. - SetList::DEAD_CODE, - // Try to figure out type hints. - SetList::TYPE_DECLARATION, + SetList::PHP_74, + // Please no dead code or unneeded variables. + SetList::DEAD_CODE, + // Try to figure out type hints. + SetList::TYPE_DECLARATION, ]); $rectorConfig->skip([ - // Don't throw errors on JSON parse problems. Yet. - // @todo Throw errors and deal with them appropriately. - JsonThrowOnErrorRector::class, - // We like our tags. Please don't remove them. - RemoveUselessParamTagRector::class, - RemoveUselessReturnTagRector::class, - RemoveUselessVarTagRector::class, - ArrayShapeFromConstantArrayReturnRector::class, - AddMethodCallBasedStrictParamTypeRector::class, + // Don't throw errors on JSON parse problems. Yet. + // @todo Throw errors and deal with them appropriately. + JsonThrowOnErrorRector::class, + // We like our tags. Please don't remove them. + RemoveUselessParamTagRector::class, + RemoveUselessReturnTagRector::class, + RemoveUselessVarTagRector::class, + ArrayShapeFromConstantArrayReturnRector::class, + AddMethodCallBasedStrictParamTypeRector::class, ]); + $rectorConfig->removeUnusedImports(); $rectorConfig->importNames(); $rectorConfig->importShortClasses(false); }; diff --git a/src/ETL/Load/Load.php b/src/ETL/Load/Load.php index 9f9ce1d..53fe86d 100644 --- a/src/ETL/Load/Load.php +++ b/src/ETL/Load/Load.php @@ -3,8 +3,6 @@ namespace Harvest\ETL\Load; use Harvest\Harvester; -use Harvest\Log\MakeItLog; -use Harvest\Storage\StorageInterface; use Harvest\Util; abstract class Load diff --git a/src/ETL/Transform/Transform.php b/src/ETL/Transform/Transform.php index 35abe37..7f3460d 100644 --- a/src/ETL/Transform/Transform.php +++ b/src/ETL/Transform/Transform.php @@ -2,8 +2,6 @@ namespace Harvest\ETL\Transform; -use Harvest\Log\MakeItLog; - abstract class Transform { diff --git a/src/Harvester.php b/src/Harvester.php index c3c4202..19c0ca6 100644 --- a/src/Harvester.php +++ b/src/Harvester.php @@ -2,7 +2,6 @@ namespace Harvest; -use Harvest\ETL\Transform\Transform; use Harvest\ETL\Factory; class Harvester diff --git a/test/json/data.json b/test/json/data.json index e76fd9a..9238758 100644 --- a/test/json/data.json +++ b/test/json/data.json @@ -335,4 +335,4 @@ "spatial": "POLYGON ((60.8642578125 29.878755346038, 61.787109375 30.977609093349, 61.7431640625 31.391157522825, 60.7763671875 31.653381399664, 60.8642578125 32.361403315275, 60.556640625 33.137551192346, 60.908203125 33.578014746144, 60.5126953125 33.614619292334, 60.5126953125 34.307143856288, 60.8642578125 34.343436068483, 61.3037109375 35.603718740697, 62.666015625 35.353216101238, 64.5556640625 36.421282443649, 64.86328125 37.195330582801, 65.654296875 37.195330582801, 65.654296875 37.474858084971, 67.9833984375 37.055177106661, 68.7744140625 37.265309955619, 69.345703125 37.125286284967, 69.697265625 37.683820326694, 70.3125 37.683820326694, 70.3125 38.065392351332, 71.0595703125 38.582526159353, 71.279296875 37.78808138412, 71.7626953125 37.926867601481, 71.4990234375 37.405073750177, 71.630859375 36.738884124394, 73.3447265625 37.474858084971, 73.7841796875 37.474858084971, 73.7841796875 37.265309955619, 74.7509765625 37.335224359306, 74.9267578125 37.160316546737, 74.1357421875 36.809284702059, 72.9931640625 36.949891786813, 71.54296875 36.315125147481, 71.2353515625 36.066862132579, 71.5869140625 35.460669951495, 71.54296875 34.813803317113, 71.103515625 34.560859367084, 71.1474609375 34.08906131585, 70.3125 33.979808728725, 69.873046875 33.979808728725, 70.2685546875 33.321348526699, 69.345703125 32.916485347314, 69.2578125 32.324275588877, 69.1259765625 31.802892586707, 68.7744140625 31.578535426473, 68.0712890625 31.802892586707, 67.67578125 31.615965936476, 67.8515625 31.353636941501, 67.4560546875 31.278550858947, 67.0166015625 31.278550858947, 66.4892578125 30.939924331023, 66.2255859375 30.334953881989, 66.357421875 29.91685223307, 65.0390625 29.535229562948, 64.248046875 29.611670115197, 64.2041015625 29.420460341013, 63.4130859375 29.458731185355, 62.6220703125 29.420460341013))", "title": "Afghanistan Election Districts" }] -} \ No newline at end of file +}