From 1679b97d36a37fbd855470464064d73e363067bf Mon Sep 17 00:00:00 2001 From: Sambhav Pokharel Date: Mon, 10 Nov 2025 14:04:53 -0500 Subject: [PATCH 1/4] Add Rector to project --- .gitignore | 1 + tests/rector.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/rector.php diff --git a/.gitignore b/.gitignore index 2b1aafc..2f6a1d0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock .php_cs_cache .phpstan_cache .phpunit.result.cache +.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 1adae5c47371d720bbf20699fbf170253af1528b Mon Sep 17 00:00:00 2001 From: Sambhav Pokharel Date: Tue, 11 Nov 2025 09:47:56 -0500 Subject: [PATCH 2/4] Integrate Rector to Phing & Github Action workflows --- .github/workflows/ci.yaml | 7 +++++++ build.xml | 13 +++++++++++++ tests/phpcs.xml | 1 + 3 files changed, 21 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7c5b7e8..494079d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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/build.xml b/build.xml index 08c5a01..161e43f 100644 --- a/build.xml +++ b/build.xml @@ -38,6 +38,7 @@ + @@ -139,6 +140,18 @@ + + + + + + + + + + + + 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.* From b8b4859c67f0289c18bb5b9f570ab3999a6e8ead Mon Sep 17 00:00:00 2001 From: sambhavp96 <40562292+sambhavp96@users.noreply.github.com> Date: Tue, 11 Nov 2025 10:04:26 -0500 Subject: [PATCH 3/4] Add rector-console to PHP 8.3 CI tasks --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 494079d..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 From 23abdaea297ae737e0a61810585858e3b180f73f Mon Sep 17 00:00:00 2001 From: Sambhav Pokharel Date: Tue, 11 Nov 2025 11:24:31 -0500 Subject: [PATCH 4/4] Rector Level 22 --- composer.json | 3 ++- src/VuFindHttp/HttpService.php | 4 ++-- tests/rector.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index d2b13c6..0293374 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "phpstan/phpstan": "1.12.7", "phpunit/phpunit": "10.5.36", "phing/phing": "3.0", - "squizlabs/php_codesniffer": "3.10.3" + "squizlabs/php_codesniffer": "3.10.3", + "rector/rector": "^1.2" }, "autoload": { "psr-0": { diff --git a/src/VuFindHttp/HttpService.php b/src/VuFindHttp/HttpService.php index 27c0568..97127f9 100644 --- a/src/VuFindHttp/HttpService.php +++ b/src/VuFindHttp/HttpService.php @@ -201,7 +201,7 @@ public function get( $timeout = null, array $headers = [] ) { - if ($params) { + if ($params !== []) { $query = $this->createQueryString($params); if (str_contains($url, '?')) { $url .= '&' . $query; @@ -211,7 +211,7 @@ public function get( } $client = $this->createClient($url, \Laminas\Http\Request::METHOD_GET, $timeout); - if ($headers) { + if ($headers !== []) { $client->setHeaders($headers); } return $this->send($client); diff --git a/tests/rector.php b/tests/rector.php index e51d604..926d1d9 100644 --- a/tests/rector.php +++ b/tests/rector.php @@ -18,4 +18,4 @@ ]) ->withTypeCoverageLevel(0) ->withDeadCodeLevel(6) - ->withCodeQualityLevel(18); + ->withCodeQualityLevel(24);