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
49 changes: 49 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
- push

name: Run PHPStan checks

jobs:
mutation:
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.2"
- "8.3"
- "8.4"

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
coverage: pcov
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
tools: composer:v2, cs2pr

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run static analysis with PHPStan
run: vendor/bin/phpstan analyse
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# dot-geoip

> [!IMPORTANT]
Dotkernel component to provide geographical details about an IP address

> dot-geoip is a wrapper on top of [maxmind/GeoIP2-php](https://github.com/maxmind/GeoIP2-php)

## Documentation

Documentation is available at: https://docs.dotkernel.org/dot-geoip/.

## Badges

![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-geoip)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.8.1)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.9.0)

[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/network)
Expand All @@ -13,6 +20,7 @@

[![Build Static](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/dot-geoip/graph/badge.svg?token=K473P7MDZ4)](https://codecov.io/gh/dotkernel/dot-geoip)
[![PHPStan](https://github.com/dotkernel/dot-geoip/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-geoip/actions/workflows/static-analysis.yml)

## Install

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
"geoip2/geoip2": "^3.0",
"guzzlehttp/guzzle": "^7.8",
"laminas/laminas-filter": "^2.34",
"psr/container": "^1.1",
"psr/container": "^1.1 || ^2.0.0",
"symfony/filesystem": "^7.0"
},
"require-dev": {
"laminas/laminas-coding-standard": "^3.0",
"mikey179/vfsstream": "^1.6.7",
"phpunit/phpunit": "^10.5",
"vimeo/psalm": "^6.0"
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^10.2"
},
"autoload": {
"psr-4": {
Expand All @@ -55,7 +56,6 @@
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"static-analysis": "psalm --shepherd --stats"
"static-analysis": "phpstan analyse --memory-limit 1G"
}
}
18 changes: 17 additions & 1 deletion docs/book/v3/overview.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Overview

> dot-geoip is a wrapper on top of [dot-geoip](https://github.com/maxmind/GeoIP2-php)
Dotkernel component to provide geographical details about an IP address.

> dot-geoip is a wrapper on top of [maxmind/GeoIP2-php](https://github.com/maxmind/GeoIP2-php)

## Badges

![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-geoip)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.9.0)

[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/network)
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/stargazers)
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/blob/3.0/LICENSE)

[![Build Static](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/dot-geoip/graph/badge.svg?token=HZKFRQWDSV)](https://codecov.io/gh/dotkernel/dot-geoip)
[![PHPStan](https://github.com/dotkernel/dot-geoip/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-geoip/actions/workflows/static-analysis.yml)
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
level: 5
paths:
- src
- test
treatPhpDocTypesAsCertain: false
17 changes: 0 additions & 17 deletions psalm.xml

This file was deleted.

2 changes: 1 addition & 1 deletion test/Command/GeoIpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testCreateCommand(): void
$locationService = $this->createMock(LocationServiceInterface::class);

$command = new GeoIpCommand($locationService);
$this->assertInstanceOf(GeoIpCommand::class, $command);
$this->assertContainsOnlyInstancesOf(GeoIpCommand::class, [$command]);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/Data/CityDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ public function testAccessors()
{
$cityData = new CityData();
$cityData->setName($this->defaults['city']['name']);
$this->assertInstanceOf(CityData::class, $cityData);
$this->assertContainsOnlyInstancesOf(CityData::class, [$cityData]);
$this->assertSame($cityData->getName(), $this->defaults['city']['name']);
$cityData->setError($this->defaults['city']['error']);
$this->assertInstanceOf(CityData::class, $cityData);
$this->assertContainsOnlyInstancesOf(CityData::class, [$cityData]);
$this->assertSame($cityData->getError(), $this->defaults['city']['error']);
}

public function testExchangeArray()
{
$cityData = (new CityData())->exchangeArray($this->defaults['city']);
$this->assertInstanceOf(CityData::class, $cityData);
$this->assertContainsOnlyInstancesOf(CityData::class, [$cityData]);
$this->assertSame($cityData->getName(), $this->defaults['city']['name']);
$this->assertSame($cityData->getError(), $this->defaults['city']['error']);
}
Expand Down
8 changes: 4 additions & 4 deletions test/Data/ContinentDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ public function testAccessors(): void
{
$continentData = new ContinentData();
$continentData->setCode($this->defaults['continent']['code']);
$this->assertInstanceOf(ContinentData::class, $continentData);
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
$this->assertSame($continentData->getCode(), $this->defaults['continent']['code']);
$continentData->setName($this->defaults['continent']['name']);
$this->assertInstanceOf(ContinentData::class, $continentData);
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
$this->assertSame($continentData->getName(), $this->defaults['continent']['name']);
$continentData->setError($this->defaults['continent']['error']);
$this->assertInstanceOf(ContinentData::class, $continentData);
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
$this->assertSame($continentData->getError(), $this->defaults['continent']['error']);
}

public function testExchangeArray(): void
{
$continentData = (new ContinentData())->exchangeArray($this->defaults['continent']);
$this->assertInstanceOf(ContinentData::class, $continentData);
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
$this->assertSame($continentData->getCode(), $this->defaults['continent']['code']);
$this->assertSame($continentData->getName(), $this->defaults['continent']['name']);
$this->assertSame($continentData->getError(), $this->defaults['continent']['error']);
Expand Down
10 changes: 5 additions & 5 deletions test/Data/CountryDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ public function testAccessors(): void
{
$countryData = new CountryData();
$countryData->setIsEuMember($this->defaults['country']['isEuMember']);
$this->assertInstanceOf(CountryData::class, $countryData);
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
$this->assertSame($countryData->getIsEuMember(), $this->defaults['country']['isEuMember']);
$countryData->setIsoCode($this->defaults['country']['isoCode']);
$this->assertInstanceOf(CountryData::class, $countryData);
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
$this->assertSame($countryData->getIsoCode(), $this->defaults['country']['isoCode']);
$countryData->setName($this->defaults['country']['name']);
$this->assertInstanceOf(CountryData::class, $countryData);
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
$this->assertSame($countryData->getName(), $this->defaults['country']['name']);
$countryData->setError($this->defaults['country']['error']);
$this->assertInstanceOf(CountryData::class, $countryData);
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
$this->assertSame($countryData->getError(), $this->defaults['country']['error']);
}

public function testExchangeArray(): void
{
$countryData = (new CountryData())->exchangeArray($this->defaults['country']);
$this->assertInstanceOf(CountryData::class, $countryData);
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
$this->assertSame($countryData->getIsEuMember(), $this->defaults['country']['isEuMember']);
$this->assertSame($countryData->getIsoCode(), $this->defaults['country']['isoCode']);
$this->assertSame($countryData->getName(), $this->defaults['country']['name']);
Expand Down
16 changes: 8 additions & 8 deletions test/Data/LocationDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ public function testAccessors(): void
{
$locationData = new LocationData();
$locationData->setContinent(new ContinentData());
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertInstanceOf(ContinentData::class, $locationData->getContinent());
$locationData->setCountry(new CountryData());
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertInstanceOf(CountryData::class, $locationData->getCountry());
$locationData->setCity(new CityData());
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertInstanceOf(CityData::class, $locationData->getCity());
$locationData->setOrganization(new OrganizationData());
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertInstanceOf(OrganizationData::class, $locationData->getOrganization());
$locationData->setLatitude($this->defaults['latitude']);
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertSame($locationData->getLatitude(), $this->defaults['latitude']);
$locationData->setLongitude($this->defaults['longitude']);
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertSame($locationData->getLongitude(), $this->defaults['longitude']);
$locationData->setTimeZone($this->defaults['timeZone']);
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertSame($locationData->getTimeZone(), $this->defaults['timeZone']);
}

Expand All @@ -65,7 +65,7 @@ public function testExchangeArray(): void
'longitude' => $this->defaults['longitude'],
'timeZone' => $this->defaults['timeZone'],
]);
$this->assertInstanceOf(LocationData::class, $locationData);
$this->assertContainsOnlyInstancesOf(LocationData::class, [$locationData]);
$this->assertInstanceOf(ContinentData::class, $locationData->getContinent());
$this->assertInstanceOf(CountryData::class, $locationData->getCountry());
$this->assertInstanceOf(CityData::class, $locationData->getCity());
Expand Down
8 changes: 4 additions & 4 deletions test/Data/OrganizationDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ public function testAccessors(): void
{
$organizationData = new OrganizationData();
$organizationData->setAsn($this->defaults['organization']['asn']);
$this->assertInstanceOf(OrganizationData::class, $organizationData);
$this->assertContainsOnlyInstancesOf(OrganizationData::class, [$organizationData]);
$this->assertSame($organizationData->getAsn(), $this->defaults['organization']['asn']);
$organizationData->setName($this->defaults['organization']['name']);
$this->assertInstanceOf(OrganizationData::class, $organizationData);
$this->assertContainsOnlyInstancesOf(OrganizationData::class, [$organizationData]);
$this->assertSame($organizationData->getName(), $this->defaults['organization']['name']);
$organizationData->setError($this->defaults['organization']['error']);
$this->assertInstanceOf(OrganizationData::class, $organizationData);
$this->assertContainsOnlyInstancesOf(OrganizationData::class, [$organizationData]);
$this->assertSame($organizationData->getError(), $this->defaults['organization']['error']);
}

public function testExchangeArray(): void
{
$organizationData = (new OrganizationData())->exchangeArray($this->defaults['organization']);
$this->assertInstanceOf(OrganizationData::class, $organizationData);
$this->assertContainsOnlyInstancesOf(OrganizationData::class, [$organizationData]);
$this->assertSame($organizationData->getAsn(), $this->defaults['organization']['asn']);
$this->assertSame($organizationData->getName(), $this->defaults['organization']['name']);
$this->assertSame($organizationData->getError(), $this->defaults['organization']['error']);
Expand Down
2 changes: 1 addition & 1 deletion test/Factory/GeoIpCommandFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ public function testFactoryWillCreateCommand(): void
]);

$command = (new GeoIpCommandFactory())($container);
$this->assertInstanceOf(GeoIpCommand::class, $command);
$this->assertContainsOnlyInstancesOf(GeoIpCommand::class, [$command]);
}
}
2 changes: 1 addition & 1 deletion test/Factory/LocationServiceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public function testCreateService(): void
]);

$service = (new LocationServiceFactory())($container);
$this->assertInstanceOf(LocationService::class, $service);
$this->assertContainsOnlyInstancesOf(LocationService::class, [$service]);
}
}
Loading