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 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/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/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/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..926d1d9 --- /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(24);