diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 136cf0c6..d0c3132d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,31 +11,27 @@ jobs: runs-on: ubuntu-latest env: - LOWEST: '0' PHP_VERSION: '8.3' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ env.PHP_VERSION }} - name: Cache Composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /tmp/composer-cache - key: ${{ runner.os }}-php${{ env.PHP_VERSION }}-lowest${{ env.LOWEST }}-{{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-php${{ env.PHP_VERSION }}-${{ hashFiles('**/composer.json') }} - name: Install dependencies - uses: php-actions/composer@v5 - env: - COMPOSER_PREFER_LOWEST: ${{ env.LOWEST }} + uses: php-actions/composer@v6 with: command: install - args: --prefer-dist --no-progress --prefer-stable --no-suggest --verbose + args: --prefer-dist --no-progress --verbose php_version: ${{ env.PHP_VERSION }} - version: 1 - name: Run lint run: make lint diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml index c821e5a5..4db92b61 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/semgrep.yml @@ -12,7 +12,7 @@ name: Semgrep config jobs: semgrep: name: semgrep/ci - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} SEMGREP_URL: https://cloudflare.semgrep.dev diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d683efe..cf628e1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,30 +14,29 @@ jobs: fail-fast: false matrix: lowest: ['0', '1'] - php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php-versions: ['8.1', '8.2', '8.3', '8.4'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - name: Cache Composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /tmp/composer-cache - key: ${{ runner.os }}-php${{ matrix.php-versions }}-lowest${{ matrix.lowest }}-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-php${{ matrix.php-versions }}-lowest${{ matrix.lowest }}-${{ hashFiles('**/composer.json') }} - name: Install dependencies - uses: php-actions/composer@v5 + uses: php-actions/composer@v6 env: COMPOSER_PREFER_LOWEST: ${{ matrix.lowest }} with: command: install - args: --prefer-dist --no-progress --prefer-stable --no-suggest --verbose + args: --prefer-dist --no-progress --verbose php_version: ${{ matrix.php-versions }} - version: 1 - name: Run tests run: make test diff --git a/.php_cs b/.php-cs-fixer.php similarity index 87% rename from .php_cs rename to .php-cs-fixer.php index 1280456e..0378b14b 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -5,7 +5,7 @@ ->in(__DIR__ . '/tests') ; -return PhpCsFixer\Config::create() +return (new PhpCsFixer\Config()) ->setUsingCache(false) ->setRules([ '@PSR2' => true, diff --git a/Makefile b/Makefile index 5d2917df..0b7a26f9 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,12 @@ all: lint test fix: - php vendor/bin/php-cs-fixer fix --config=.php_cs + php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php lint: - php vendor/bin/php-cs-fixer fix --config=.php_cs --dry-run - php vendor/bin/phpmd src/ text cleancode,codesize,controversial,design,naming,unusedcode - php vendor/bin/phpmd tests/ text cleancode,codesize,controversial,design,naming,unusedcode + php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --dry-run + php vendor/bin/phpmd src/ text phpmd.xml + php vendor/bin/phpmd tests/ text phpmd.xml test: php vendor/bin/phpunit --configuration phpunit.xml diff --git a/composer.json b/composer.json index 8f3e171a..f2373b85 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "library", "require": { "guzzlehttp/guzzle": "^7.0.1", - "php": ">=7.3", + "php": ">=8.1", "psr/http-message": "^1.0 || ^2.0", "ext-json": "*" }, diff --git a/phpmd.xml b/phpmd.xml new file mode 100644 index 00000000..dd8386ae --- /dev/null +++ b/phpmd.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/src/Adapter/Guzzle.php b/src/Adapter/Guzzle.php index 5c7c6e74..540816a9 100644 --- a/src/Adapter/Guzzle.php +++ b/src/Adapter/Guzzle.php @@ -5,6 +5,7 @@ use Cloudflare\API\Auth\Auth; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; +use InvalidArgumentException; use Psr\Http\Message\ResponseInterface; class Guzzle implements Adapter @@ -76,7 +77,7 @@ public function delete(string $uri, array $data = [], array $headers = []): Resp public function request(string $method, string $uri, array $data = [], array $headers = []) { if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) { - throw new \InvalidArgumentException('Request method must be get, post, put, patch, or delete'); + throw new InvalidArgumentException('Request method must be get, post, put, patch, or delete'); } try { diff --git a/tests/Endpoints/DNSAnalyticsTest.php b/tests/Endpoints/DNSAnalyticsTest.php index d293bf60..28e693c1 100644 --- a/tests/Endpoints/DNSAnalyticsTest.php +++ b/tests/Endpoints/DNSAnalyticsTest.php @@ -14,7 +14,6 @@ public function testGetDNSAnalyticsReportTable() 'Endpoints/getDNSAnalyticsReportTable.json' ); - $authMock = $this->createMock(\Cloudflare\API\Auth\Auth::class); $mock = $this->createMock(\Cloudflare\API\Adapter\Adapter::class); $mock->method('get')->willReturn($response); @@ -53,7 +52,6 @@ public function testGetDNSAnalyticsReportByTime() 'Endpoints/getDNSAnalyticsReportByTime.json' ); - $authMock = $this->createMock(\Cloudflare\API\Auth\Auth::class); $mock = $this->createMock(\Cloudflare\API\Adapter\Adapter::class); $mock->method('get')->willReturn($response);