Skip to content

Commit 2fe30ec

Browse files
Merge pull request #12 from ipdata/fix-noticed-issues
Fix issues found during the connection-reuse review
2 parents 5e17e46 + 757cc07 commit 2fe30ec

11 files changed

Lines changed: 157 additions & 56 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ jobs:
1313

1414
steps:
1515
- name: Set up PHP
16-
uses: shivammathur/setup-php@1.7.0
16+
uses: shivammathur/setup-php@v2
1717
with:
1818
php-version: '7.2'
19-
coverage: xdebug
20-
ini-values: xdebug.overload_var_dump=1
19+
coverage: none
2120
extensions: mbstring, intl
22-
tools: prestissimo
2321

2422
- name: Checkout code
25-
uses: actions/checkout@v2
23+
uses: actions/checkout@v7
2624

2725
- name: Download dependencies
2826
run: composer update --no-interaction --prefer-stable --prefer-lowest --prefer-dist
@@ -34,21 +32,21 @@ jobs:
3432
name: Build
3533
runs-on: ubuntu-latest
3634
strategy:
35+
fail-fast: false
3736
max-parallel: 10
3837
matrix:
39-
php: ['7.2', '7.3', '7.4', '8.0']
38+
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
4039

4140
steps:
4241
- name: Set up PHP
43-
uses: shivammathur/setup-php@1.7.0
42+
uses: shivammathur/setup-php@v2
4443
with:
4544
php-version: ${{ matrix.php }}
46-
coverage: xdebug
47-
ini-values: xdebug.overload_var_dump=1
45+
coverage: none
4846
extensions: mbstring, intl
4947

5048
- name: Checkout code
51-
uses: actions/checkout@v2
49+
uses: actions/checkout@v7
5250

5351
- name: Download dependencies
5452
run: composer update --no-interaction --prefer-dist

‎.github/workflows/static.yml‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,77 +6,77 @@ on:
66
jobs:
77
phpstan:
88
name: PHPStan
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-latest
1010

1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v7
1414

1515
- name: Setup PHP
1616
uses: shivammathur/setup-php@v2
1717
with:
18-
php-version: 8.0
18+
php-version: '8.4'
1919
coverage: none
20-
tools: phpstan:0.12.88, cs2pr
20+
tools: phpstan:2.3, cs2pr
2121

2222
- name: Download dependencies
23-
uses: ramsey/composer-install@v1
23+
uses: ramsey/composer-install@v4
2424

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

2828
php-cs-fixer:
2929
name: PHP-CS-Fixer
30-
runs-on: ubuntu-20.04
30+
runs-on: ubuntu-latest
3131

3232
steps:
3333
- name: Checkout code
34-
uses: actions/checkout@v2
34+
uses: actions/checkout@v7
3535

3636
- name: Setup PHP
3737
uses: shivammathur/setup-php@v2
3838
with:
39-
php-version: 8.0
39+
php-version: '8.4'
4040
coverage: none
41-
tools: php-cs-fixer:2.19.0, cs2pr
41+
tools: php-cs-fixer:3.95, cs2pr
4242

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

4646
psalm:
4747
name: Psalm
48-
runs-on: ubuntu-20.04
48+
runs-on: ubuntu-latest
4949
steps:
5050
- name: Checkout code
51-
uses: actions/checkout@v2
51+
uses: actions/checkout@v7
5252

5353
- name: Setup PHP
5454
uses: shivammathur/setup-php@v2
5555
with:
56-
php-version: 8.0
56+
php-version: '8.4'
5757
coverage: none
58-
tools: vimeo/psalm:4.7.2
58+
tools: psalm:6.20
5959

6060
- name: Download dependencies
61-
uses: ramsey/composer-install@v1
61+
uses: ramsey/composer-install@v4
6262

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

6666
composer-normalize:
6767
name: Composer Normalize
68-
runs-on: ubuntu-20.04
68+
runs-on: ubuntu-latest
6969

7070
steps:
7171
- name: Setup PHP
7272
uses: shivammathur/setup-php@v2
7373
with:
74-
php-version: 7.4
74+
php-version: '8.4'
7575
coverage: none
76-
tools: composer-normalize
76+
tools: composer-normalize:2.56
7777

7878
- name: Checkout code
79-
uses: actions/checkout@v2
79+
uses: actions/checkout@v7
8080

8181
- name: Normalize
8282
run: composer-normalize --dry-run

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/vendor/
22
composer.lock
3-
.php_cs.cache
3+
.php-cs-fixer.cache
44
.phpunit.result.cache

.php_cs renamed to .php-cs-fixer.dist.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
$finder = PhpCsFixer\Finder::create()
44
->in(__DIR__)
5-
->exclude(__DIR__.'/vendor')
5+
->exclude('vendor')
66
;
77

8-
return PhpCsFixer\Config::create()
8+
return (new PhpCsFixer\Config())
99
->setRules([
1010
'@Symfony' => true,
1111
'array_syntax' => ['syntax' => 'short'],
1212
])
1313
->setFinder($finder)
14-
;
14+
;

‎CHANGELOG.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
### Added
6+
7+
- 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`.
8+
- `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')`.
9+
10+
### Fixed
11+
12+
- 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`.
13+
- 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.
14+
- Two PHPStan baseline entries that no longer matched a reported error are removed.
15+
- `composer.json` is normalized.
16+
- `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.
17+
318
## 0.1.3
419

520
### Added

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ The library is transport-agnostic, so "the platform" is the PSR-18 client you in
202202
use Ipdata\ApiClient\Ipdata;
203203
use Nyholm\Psr7\Factory\Psr17Factory;
204204

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

208208
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')`.
@@ -225,6 +225,8 @@ A few things to keep in mind:
225225
* `Ipdata` has no `close()` method because it does not own the connections: they belong to the PSR-18 client you
226226
injected and are closed when that client is released, at the latest when the process ends. Timeouts, proxies
227227
and other transport settings are configured on that client as well.
228+
* Every request carries a `User-Agent: ipdata-php/<version>` header, where the version is the installed version of
229+
this package as recorded by Composer.
228230

229231
## Available Fields
230232

‎composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "ipdata/api-client",
3-
"type": "library",
43
"description": "API client for ipdata.co",
54
"license": "MIT",
5+
"type": "library",
66
"authors": [
77
{
88
"name": "Tobias Nyholm",
@@ -17,7 +17,7 @@
1717
"require-dev": {
1818
"nyholm/psr7": "^1.2",
1919
"php-http/discovery": "^1.7",
20-
"php-http/mock-client": "^1.3",
20+
"php-http/mock-client": "^1.5",
2121
"phpunit/phpunit": "^8.5"
2222
},
2323
"autoload": {

‎phpstan-baseline.neon‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:lookup\\(\\) return type has no value type specified in iterable type array\\.$#"
4+
message: '#^Method Ipdata\\ApiClient\\Ipdata\:\:buildLookup\(\) return type has no value type specified in iterable type array\.$#'
5+
identifier: missingType.iterableValue
56
count: 1
67
path: src/Ipdata.php
78

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

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

1821
-
19-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:buildLookup\\(\\) has parameter \\$ips with no value type specified in iterable type array\\.$#"
20-
count: 1
21-
path: src/Ipdata.php
22-
23-
-
24-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:buildLookup\\(\\) return type has no value type specified in iterable type array\\.$#"
25-
count: 1
26-
path: src/Ipdata.php
27-
28-
-
29-
message: "#^Method Ipdata\\\\ApiClient\\\\Ipdata\\:\\:parseResponse\\(\\) return type has no value type specified in iterable type array\\.$#"
22+
message: '#^Method Ipdata\\ApiClient\\Ipdata\:\:parseResponse\(\) return type has no value type specified in iterable type array\.$#'
23+
identifier: missingType.iterableValue
3024
count: 1
3125
path: src/Ipdata.php
3226

‎psalm.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<psalm
33
errorLevel="2"
44
resolveFromConfigFile="true"
5+
findUnusedCode="false"
56
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
67
xmlns="https://getpsalm.org/schema/config"
78
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"

0 commit comments

Comments
 (0)