Skip to content

Commit

Permalink
Merge pull request #231 from maxmind/greg/release
Browse files Browse the repository at this point in the history
Release 3.1.0
  • Loading branch information
horgh authored Nov 15, 2024
2 parents 279446f + c86fbea commit ae7bc7b
Show file tree
Hide file tree
Showing 30 changed files with 166 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3

- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['8.1', '8.2']
php-versions: ['8.1', '8.2', '8.3', '8.4']
name: "PHP ${{ matrix.php-versions }} test on ${{ matrix.operating-system }}"
steps:
- name: Setup PHP
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _site
.gh-pages
.idea
.php_cs.cache
.php-cs-fixer.cache
.phpunit.cache/
.phpunit.result.cache
GeoLite2-City.mmdb
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
CHANGELOG
=========

3.1.0 (2024-11-15)
------------------

* This library no longer uses implicitly nullable parameter types. This
will fix deprecation warning in PHP 8.4. Reported by Steven Lewis.
GitHub #230.
* The PHPDoc type hints have been improved for use with PHPStan.

3.0.0 (2023-12-04)
------------------

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,6 @@ The GeoIP2 PHP API uses [Semantic Versioning](https://semver.org/).

## Copyright and License ##

This software is Copyright (c) 2013-2023 by MaxMind, Inc.
This software is Copyright (c) 2013-2024 by MaxMind, Inc.

This is free software, licensed under the Apache License, Version 2.0.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
}
],
"require": {
"maxmind-db/reader": "^1.11.1",
"maxmind/web-service-common": "~0.8",
"maxmind-db/reader": "^1.12.0",
"maxmind/web-service-common": "~0.10",
"php": ">=8.1",
"ext-json": "*"
},
Expand Down
8 changes: 4 additions & 4 deletions dev-bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ php composer.phar update --no-dev
perl -pi -e "s/(?<=const VERSION = ').+?(?=';)/$tag/g" src/WebService/Client.php


box_phar_hash='c24c400c424a68041d7af146c71943bf1acc0c5abafa45297c503b832b9c6b16 box.phar'
box_phar_hash='8d12a7d69a5003a80bd603ea95a8f3dcea30b9a2ad84cd7cb15b8193929def9e box.phar'

if ! echo "$box_phar_hash" | sha256sum -c; then
wget -O box.phar "https://github.com/box-project/box/releases/download/4.5.1/box.phar"
wget -O box.phar "https://github.com/box-project/box/releases/download/4.6.1/box.phar"
fi

echo "$box_phar_hash" | sha256sum -c
Expand Down Expand Up @@ -93,10 +93,10 @@ if [ -n "$(git status --porcelain)" ]; then
fi

# Using Composer is possible, but they don't recommend it.
phpdocumentor_phar_hash='bad7e4b8c99e73391bb3183a127593ecd1cd66ae42b4a33efe495d193e257f04 phpDocumentor.phar'
phpdocumentor_phar_hash='9760ac280a10041928a8743354f68692c22f14cd5d05135dfc15e11d3b3c25ea phpDocumentor.phar'

if ! echo "$phpdocumentor_phar_hash" | sha256sum -c; then
wget -O phpDocumentor.phar https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.4.3/phpDocumentor.phar
wget -O phpDocumentor.phar https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.5.3/phpDocumentor.phar
fi

echo "$phpdocumentor_phar_hash" | sha256sum -c
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ parameters:
paths:
- src
- tests
checkMissingIterableValueType: false

9 changes: 6 additions & 3 deletions src/Database/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class Reader implements ProviderInterface
/**
* Constructor.
*
* @param string $filename the path to the GeoIP2 database file
* @param array $locales list of locale codes to use in name property
* from most preferred to least preferred
* @param string $filename the path to the GeoIP2 database file
* @param array<string> $locales list of locale codes to use in name property
* from most preferred to least preferred
*
* @throws InvalidDatabaseException if the database is corrupt or invalid
*/
Expand Down Expand Up @@ -215,6 +215,9 @@ private function flatModelFor(string $class, string $type, string $ipAddress): o
return new $class($record);
}

/**
* @return array{0:array<string, mixed>, 1:int}
*/
private function getRecord(string $class, string $type, string $ipAddress): array
{
if (!str_contains($this->dbType, $type)) {
Expand Down
29 changes: 11 additions & 18 deletions src/Model/AnonymousIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class AnonymousIp implements \JsonSerializable

/**
* @ignore
*
* @param array<string, mixed> $raw
*/
public function __construct(array $raw)
{
Expand All @@ -78,27 +80,18 @@ public function __construct(array $raw)
$this->network = Util::cidr($ipAddress, $raw['prefix_len']);
}

/**
* @return array<string, mixed>|null
*/
public function jsonSerialize(): ?array
{
$js = [];
if ($this->isAnonymous !== null) {
$js['is_anonymous'] = $this->isAnonymous;
}
if ($this->isAnonymousVpn !== null) {
$js['is_anonymous_vpn'] = $this->isAnonymousVpn;
}
if ($this->isHostingProvider !== null) {
$js['is_hosting_provider'] = $this->isHostingProvider;
}
if ($this->isPublicProxy !== null) {
$js['is_public_proxy'] = $this->isPublicProxy;
}
if ($this->isResidentialProxy !== null) {
$js['is_residential_proxy'] = $this->isResidentialProxy;
}
if ($this->isTorExitNode !== null) {
$js['is_tor_exit_node'] = $this->isTorExitNode;
}
$js['is_anonymous'] = $this->isAnonymous;
$js['is_anonymous_vpn'] = $this->isAnonymousVpn;
$js['is_hosting_provider'] = $this->isHostingProvider;
$js['is_public_proxy'] = $this->isPublicProxy;
$js['is_residential_proxy'] = $this->isResidentialProxy;
$js['is_tor_exit_node'] = $this->isTorExitNode;
$js['ip_address'] = $this->ipAddress;
$js['network'] = $this->network;

Expand Down
5 changes: 5 additions & 0 deletions src/Model/Asn.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class Asn implements \JsonSerializable

/**
* @ignore
*
* @param array<string, mixed> $raw
*/
public function __construct(array $raw)
{
Expand All @@ -50,6 +52,9 @@ public function __construct(array $raw)
$this->network = Util::cidr($ipAddress, $raw['prefix_len']);
}

/**
* @return array<string, mixed>|null
*/
public function jsonSerialize(): ?array
{
$js = [];
Expand Down
6 changes: 6 additions & 0 deletions src/Model/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ class City extends Country

/**
* @ignore
*
* @param array<string, mixed> $raw
* @param list<string> $locales
*/
public function __construct(array $raw, array $locales = ['en'])
{
Expand Down Expand Up @@ -90,6 +93,9 @@ public function __construct(array $raw, array $locales = ['en'])
$this->subdivisions = $subdivisions;
}

/**
* @return array<string, mixed>|null
*/
public function jsonSerialize(): ?array
{
$js = parent::jsonSerialize();
Expand Down
5 changes: 5 additions & 0 deletions src/Model/ConnectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class ConnectionType implements \JsonSerializable

/**
* @ignore
*
* @param array<string, mixed> $raw
*/
public function __construct(array $raw)
{
Expand All @@ -42,6 +44,9 @@ public function __construct(array $raw)
$this->network = Util::cidr($ipAddress, $raw['prefix_len']);
}

/**
* @return array<string, mixed>|null
*/
public function jsonSerialize(): ?array
{
$js = [];
Expand Down
6 changes: 6 additions & 0 deletions src/Model/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class Country implements \JsonSerializable

/**
* @ignore
*
* @param array<string, mixed> $raw
* @param list<string> $locales
*/
public function __construct(array $raw, array $locales = ['en'])
{
Expand All @@ -81,6 +84,9 @@ public function __construct(array $raw, array $locales = ['en'])
$this->traits = new Traits($raw['traits'] ?? []);
}

/**
* @return array<string, mixed>|null
*/
public function jsonSerialize(): ?array
{
$js = [];
Expand Down
5 changes: 5 additions & 0 deletions src/Model/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Domain implements \JsonSerializable

/**
* @ignore
*
* @param array<string, mixed> $raw
*/
public function __construct(array $raw)
{
Expand All @@ -42,6 +44,9 @@ public function __construct(array $raw)
$this->network = Util::cidr($ipAddress, $raw['prefix_len']);
}

/**
* @return array<string, mixed>|null
*/
public function jsonSerialize(): ?array
{
$js = [];
Expand Down
5 changes: 5 additions & 0 deletions src/Model/Isp.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Isp implements \JsonSerializable

/**
* @ignore
*
* @param array<string, mixed> $raw
*/
public function __construct(array $raw)
{
Expand All @@ -81,6 +83,9 @@ public function __construct(array $raw)
$this->network = Util::cidr($ipAddress, $raw['prefix_len']);
}

/**
* @return array<string, mixed>|null
*/
public function jsonSerialize(): ?array
{
$js = [];
Expand Down
12 changes: 9 additions & 3 deletions src/Record/AbstractNamedRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ abstract class AbstractNamedRecord implements \JsonSerializable
public readonly ?string $name;

/**
* @var array An array map where the keys are locale codes
* and the values are names. This attribute is returned by all location
* services and databases.
* @var array<string, string> An array map where the keys are locale codes
* and the values are names. This attribute is returned by all location
* services and databases.
*/
public readonly array $names;

/**
* @ignore
*
* @param array<string, mixed> $record
* @param list<string> $locales
*/
public function __construct(array $record, array $locales = ['en'])
{
Expand All @@ -37,6 +40,9 @@ public function __construct(array $record, array $locales = ['en'])
$this->name = null;
}

/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
$js = [];
Expand Down
6 changes: 6 additions & 0 deletions src/Record/AbstractPlaceRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ abstract class AbstractPlaceRecord extends AbstractNamedRecord

/**
* @ignore
*
* @param array<string, mixed> $record
* @param list<string> $locales
*/
public function __construct(array $record, array $locales = ['en'])
{
Expand All @@ -30,6 +33,9 @@ public function __construct(array $record, array $locales = ['en'])
$this->geonameId = $record['geoname_id'] ?? null;
}

/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
$js = parent::jsonSerialize();
Expand Down
6 changes: 6 additions & 0 deletions src/Record/Continent.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Continent extends AbstractNamedRecord

/**
* @ignore
*
* @param array<string, mixed> $record
* @param list<string> $locales
*/
public function __construct(array $record, array $locales = ['en'])
{
Expand All @@ -35,6 +38,9 @@ public function __construct(array $record, array $locales = ['en'])
$this->geonameId = $record['geoname_id'] ?? null;
}

/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
$js = parent::jsonSerialize();
Expand Down
6 changes: 6 additions & 0 deletions src/Record/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Country extends AbstractPlaceRecord

/**
* @ignore
*
* @param array<string, mixed> $record
* @param list<string> $locales
*/
public function __construct(array $record, array $locales = ['en'])
{
Expand All @@ -36,6 +39,9 @@ public function __construct(array $record, array $locales = ['en'])
$this->isoCode = $record['iso_code'] ?? null;
}

/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
$js = parent::jsonSerialize();
Expand Down
8 changes: 8 additions & 0 deletions src/Record/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class Location implements \JsonSerializable
*/
public readonly ?string $timeZone;

/**
* @ignore
*
* @param array<string, mixed> $record
*/
public function __construct(array $record)
{
$this->averageIncome = $record['average_income'] ?? null;
Expand All @@ -75,6 +80,9 @@ public function __construct(array $record)
$this->timeZone = $record['time_zone'] ?? null;
}

/**
* @return array<string, mixed>
*/
public function jsonSerialize(): array
{
$js = [];
Expand Down
Loading

0 comments on commit ae7bc7b

Please sign in to comment.