From c7b3cba0012fb7e377c8549fff3d9f23e2d8f0e8 Mon Sep 17 00:00:00 2001 From: Sambhav Pokharel Date: Wed, 12 Nov 2025 16:24:11 -0500 Subject: [PATCH 1/4] Add Rector to project --- .github/workflows/ci.yaml | 9 ++++++++- .gitignore | 1 + build.xml | 13 +++++++++++++ composer.json | 1 + tests/phpcs.xml | 1 + tests/rector.php | 21 +++++++++++++++++++++ 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/rector.php diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7c5b7e8..414cddb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: - php-version: 8.2 phing_tasks: "phpunitfast" - php-version: 8.3 - phing_tasks: "phpunitfast phpcs-console php-cs-fixer-dryrun phpstan-console" + phing_tasks: "phpunitfast phpcs-console php-cs-fixer-dryrun phpstan-console rector-console" steps: - name: Setup PHP @@ -27,6 +27,13 @@ jobs: php-version: ${{ matrix.php-version }} extensions: intl, xsl + - name: Cache rector data + uses: actions/cache@v4 + with: + path: .rector + key: "php-${{ matrix.php-version }}-rector-${{ github.sha }}" + restore-keys: "php-${{ matrix.php-version }}-rector-" + - name: Checkout uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 6de40ea..66e7fa4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock .php_cs_cache .phpstan_cache tests/.phpunit.result.cache +.rector diff --git a/build.xml b/build.xml index 74e498d..3fd265e 100644 --- a/build.xml +++ b/build.xml @@ -38,6 +38,7 @@ + @@ -82,6 +83,18 @@ + + + + + + + + + + + + diff --git a/composer.json b/composer.json index 2313166..322706e 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,7 @@ "phpstan/phpstan": "1.12.7", "phpunit/phpunit": "10.5.36", "phing/phing": "3.0", + "rector/rector": "^1.2", "squizlabs/php_codesniffer": "3.10.3" } } diff --git a/tests/phpcs.xml b/tests/phpcs.xml index 55f14a4..12dbbf9 100644 --- a/tests/phpcs.xml +++ b/tests/phpcs.xml @@ -5,6 +5,7 @@ . */config/* *.php-cs-fixer.* + *rector.* diff --git a/tests/rector.php b/tests/rector.php new file mode 100644 index 0000000..e51d604 --- /dev/null +++ b/tests/rector.php @@ -0,0 +1,21 @@ +withCache( + cacheClass: FileCacheStorage::class, + cacheDirectory: __DIR__ . '/../.rector' + )->withPaths([ + __DIR__ . '/../src', + ]) + ->withSets([ + PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES, + ]) + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(6) + ->withCodeQualityLevel(18); From 8f04ba216e9e827726f9eb406f1dac5a397303d9 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Wed, 12 Nov 2025 16:27:52 -0500 Subject: [PATCH 2/4] Apply suggestion from @demiankatz --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 322706e..2f5d473 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "phpstan/phpstan": "1.12.7", "phpunit/phpunit": "10.5.36", "phing/phing": "3.0", - "rector/rector": "^1.2", + "rector/rector": "1.2.7", "squizlabs/php_codesniffer": "3.10.3" } } From 5bdf73bb6485d16059dc95ee93b9fa3ce1c1b969 Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Wed, 12 Nov 2025 16:34:12 -0500 Subject: [PATCH 3/4] Tweak tool versions to more closely match main project. --- composer.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 2f5d473..cf78854 100644 --- a/composer.json +++ b/composer.json @@ -26,14 +26,13 @@ "php": ">=8.1" }, "require-dev": { - "friendsofphp/php-cs-fixer": "3.64.0", + "friendsofphp/php-cs-fixer": "3.89.2", "guzzlehttp/guzzle": "^7.8.1", - "pear/http_request2": "2.6.0", "phpmd/phpmd": "2.15.0", - "phpstan/phpstan": "1.12.7", + "phpstan/phpstan": "2.1.32", "phpunit/phpunit": "10.5.36", - "phing/phing": "3.0", + "phing/phing": "3.1.0", "rector/rector": "1.2.7", - "squizlabs/php_codesniffer": "3.10.3" + "squizlabs/php_codesniffer": "4.0.1" } } From 3916e07856ab0e137ccdf84e42017a350d59517a Mon Sep 17 00:00:00 2001 From: Demian Katz Date: Wed, 12 Nov 2025 16:35:31 -0500 Subject: [PATCH 4/4] Fix typo. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cf78854..740644a 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "phpstan/phpstan": "2.1.32", "phpunit/phpunit": "10.5.36", "phing/phing": "3.1.0", - "rector/rector": "1.2.7", + "rector/rector": "2.2.7", "squizlabs/php_codesniffer": "4.0.1" } }