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
18 changes: 8 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ jobs:

steps:
- name: Set up PHP
uses: shivammathur/setup-php@1.7.0
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
coverage: xdebug
ini-values: xdebug.overload_var_dump=1
coverage: none
extensions: mbstring, intl
tools: prestissimo

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Download dependencies
run: composer update --no-interaction --prefer-stable --prefer-lowest --prefer-dist
Expand All @@ -34,21 +32,21 @@ jobs:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 10
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- name: Set up PHP
uses: shivammathur/setup-php@1.7.0
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
ini-values: xdebug.overload_var_dump=1
coverage: none
extensions: mbstring, intl

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Download dependencies
run: composer update --no-interaction --prefer-dist
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,77 +6,77 @@ on:
jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: '8.4'
coverage: none
tools: phpstan:0.12.88, cs2pr
tools: phpstan:2.3, cs2pr

- name: Download dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v4

- name: PHPStan
run: phpstan analyze --no-progress --error-format=checkstyle | cs2pr

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: '8.4'
coverage: none
tools: php-cs-fixer:2.19.0, cs2pr
tools: php-cs-fixer:3.95, cs2pr

- name: PHP-CS-Fixer
run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr

psalm:
name: Psalm
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: '8.4'
coverage: none
tools: vimeo/psalm:4.7.2
tools: psalm:6.20

- name: Download dependencies
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v4

- name: Psalm
run: psalm --no-progress --output-format=github

composer-normalize:
name: Composer Normalize
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: '8.4'
coverage: none
tools: composer-normalize
tools: composer-normalize:2.56

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v7

- name: Normalize
run: composer-normalize --dry-run
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor/
composer.lock
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
6 changes: 3 additions & 3 deletions .php_cs → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude(__DIR__.'/vendor')
->exclude('vendor')
;

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder)
;
;
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## Unreleased

### Added

- Every request carries a `User-Agent: ipdata-php/<version>` header. The version is the installed version of `ipdata/api-client` as recorded by Composer (`Composer\InstalledVersions`, Composer 2 and newer); without it the header is `ipdata-php`.
- `Ipdata::DEFAULT_BASE_URL` is public, so the trailing `$httpVersion` argument can be passed without repeating the endpoint: `new Ipdata('my_api_key', $httpClient, $psr17Factory, Ipdata::DEFAULT_BASE_URL, '2.0')`.

### Fixed

- The static-analysis workflow runs again, on a current runner image with current releases of PHPStan, Psalm, PHP-CS-Fixer and composer-normalize; the test workflow covers PHP 7.2 to 8.4 with current `actions/checkout` and `shivammathur/setup-php` releases and no longer requests the Composer 1 plugin `prestissimo`.
- The PHP-CS-Fixer configuration moved to `.php-cs-fixer.dist.php` (PHP-CS-Fixer 3 file name and API) and excludes `vendor/` correctly; the two remaining coding-style findings in `src/Ipdata.php` are fixed.
- Two PHPStan baseline entries that no longer matched a reported error are removed.
- `composer.json` is normalized.
- `bulkLookup()` throws an `\InvalidArgumentException` when the IP addresses cannot be encoded as JSON (for example invalid UTF-8) instead of failing with a `TypeError` while writing the request body.

## 0.1.3

### Added
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ The library is transport-agnostic, so "the platform" is the PSR-18 client you in
use Ipdata\ApiClient\Ipdata;
use Nyholm\Psr7\Factory\Psr17Factory;

$ipdata = new Ipdata('my_api_key', new Client(), new Psr17Factory(), 'https://api.ipdata.co', '2.0');
$ipdata = new Ipdata('my_api_key', new Client(), new Psr17Factory(), Ipdata::DEFAULT_BASE_URL, '2.0');
```

On PHP 8 you can skip the base URL with a named argument: `new Ipdata('my_api_key', new Client(), new Psr17Factory(), httpVersion: '2.0')`.
Expand All @@ -225,6 +225,8 @@ A few things to keep in mind:
* `Ipdata` has no `close()` method because it does not own the connections: they belong to the PSR-18 client you
injected and are closed when that client is released, at the latest when the process ends. Timeouts, proxies
and other transport settings are configured on that client as well.
* Every request carries a `User-Agent: ipdata-php/<version>` header, where the version is the installed version of
this package as recorded by Composer.

## Available Fields

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ipdata/api-client",
"type": "library",
"description": "API client for ipdata.co",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Tobias Nyholm",
Expand All @@ -17,7 +17,7 @@
"require-dev": {
"nyholm/psr7": "^1.2",
"php-http/discovery": "^1.7",
"php-http/mock-client": "^1.3",
"php-http/mock-client": "^1.5",
"phpunit/phpunit": "^8.5"
},
"autoload": {
Expand Down
22 changes: 8 additions & 14 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
parameters:
ignoreErrors:
-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:lookup\\(\\) return type has no value type specified in iterable type array\\.$#"
message: '#^Method Ipdata\\ApiClient\\Ipdata\:\:buildLookup\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Ipdata.php

-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:bulkLookup\\(\\) has parameter \\$ips with no value type specified in iterable type array\\.$#"
message: '#^Method Ipdata\\ApiClient\\Ipdata\:\:bulkLookup\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Ipdata.php

-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:bulkLookup\\(\\) return type has no value type specified in iterable type array\\.$#"
message: '#^Method Ipdata\\ApiClient\\Ipdata\:\:lookup\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Ipdata.php

-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:buildLookup\\(\\) has parameter \\$ips with no value type specified in iterable type array\\.$#"
count: 1
path: src/Ipdata.php

-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:buildLookup\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Ipdata.php

-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:parseResponse\\(\\) return type has no value type specified in iterable type array\\.$#"
message: '#^Method Ipdata\\ApiClient\\Ipdata\:\:parseResponse\(\) return type has no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
count: 1
path: src/Ipdata.php

1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<psalm
errorLevel="2"
resolveFromConfigFile="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
Loading
Loading