Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
->in(__DIR__ . '/tests')
;

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setUsingCache(false)
->setRules([
'@PSR2' => true,
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
},
Expand Down
17 changes: 17 additions & 0 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset name="Cloudflare SDK"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">

<rule ref="rulesets/cleancode.xml">
<exclude name="MissingImport"/>
<exclude name="StaticAccess"/>
</rule>
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/controversial.xml"/>
<rule ref="rulesets/design.xml"/>
<rule ref="rulesets/naming.xml"/>
<rule ref="rulesets/unusedcode.xml"/>
</ruleset>
3 changes: 2 additions & 1 deletion src/Adapter/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions tests/Endpoints/DNSAnalyticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Loading