Skip to content

Commit cb5a5c3

Browse files
authored
Merge pull request #45 from Howriq/issue-44
Issue #44: Replace Psalm with PHPStan
2 parents 4e09c23 + 0956bc2 commit cb5a5c3

15 files changed

Lines changed: 130 additions & 66 deletions
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
- push
3+
4+
name: Run PHPStan checks
5+
6+
jobs:
7+
mutation:
8+
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.2"
19+
- "8.3"
20+
- "8.4"
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Install PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: "${{ matrix.php }}"
30+
coverage: pcov
31+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
32+
tools: composer:v2, cs2pr
33+
34+
- name: Determine composer cache directory
35+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
36+
37+
- name: Cache dependencies installed with composer
38+
uses: actions/cache@v4
39+
with:
40+
path: ${{ env.COMPOSER_CACHE_DIR }}
41+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
42+
restore-keys: |
43+
php${{ matrix.php }}-composer-
44+
45+
- name: Install dependencies with composer
46+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
47+
48+
- name: Run static analysis with PHPStan
49+
run: vendor/bin/phpstan analyse

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
# dot-geoip
22

3-
> [!IMPORTANT]
3+
Dotkernel component to provide geographical details about an IP address
4+
45
> dot-geoip is a wrapper on top of [maxmind/GeoIP2-php](https://github.com/maxmind/GeoIP2-php)
56
7+
## Documentation
8+
9+
Documentation is available at: https://docs.dotkernel.org/dot-geoip/.
10+
11+
## Badges
12+
613
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-geoip)
7-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.8.1)
14+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.9.0)
815

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

1421
[![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)
1522
[![codecov](https://codecov.io/gh/dotkernel/dot-geoip/graph/badge.svg?token=K473P7MDZ4)](https://codecov.io/gh/dotkernel/dot-geoip)
23+
[![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)
1624

1725
## Install
1826

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
"geoip2/geoip2": "^3.0",
2828
"guzzlehttp/guzzle": "^7.8",
2929
"laminas/laminas-filter": "^2.34",
30-
"psr/container": "^1.1",
30+
"psr/container": "^1.1 || ^2.0.0",
3131
"symfony/filesystem": "^7.0"
3232
},
3333
"require-dev": {
3434
"laminas/laminas-coding-standard": "^3.0",
3535
"mikey179/vfsstream": "^1.6.7",
36-
"phpunit/phpunit": "^10.5",
37-
"vimeo/psalm": "^6.0"
36+
"phpstan/phpstan": "^2.1",
37+
"phpstan/phpstan-phpunit": "^2.0",
38+
"phpunit/phpunit": "^10.2"
3839
},
3940
"autoload": {
4041
"psr-4": {
@@ -55,7 +56,6 @@
5556
"cs-check": "phpcs",
5657
"cs-fix": "phpcbf",
5758
"test": "phpunit --colors=always",
58-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
59-
"static-analysis": "psalm --shepherd --stats"
59+
"static-analysis": "phpstan analyse --memory-limit 1G"
6060
}
6161
}

docs/book/v3/overview.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
# Overview
22

3-
> dot-geoip is a wrapper on top of [dot-geoip](https://github.com/maxmind/GeoIP2-php)
3+
Dotkernel component to provide geographical details about an IP address.
4+
5+
> dot-geoip is a wrapper on top of [maxmind/GeoIP2-php](https://github.com/maxmind/GeoIP2-php)
6+
7+
## Badges
8+
9+
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-geoip)
10+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-geoip/3.9.0)
11+
12+
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/issues)
13+
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/network)
14+
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/stargazers)
15+
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-geoip)](https://github.com/dotkernel/dot-geoip/blob/3.0/LICENSE)
16+
17+
[![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)
18+
[![codecov](https://codecov.io/gh/dotkernel/dot-geoip/graph/badge.svg?token=HZKFRQWDSV)](https://codecov.io/gh/dotkernel/dot-geoip)
19+
[![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)

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
parameters:
4+
level: 5
5+
paths:
6+
- src
7+
- test
8+
treatPhpDocTypesAsCertain: false

psalm.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/Command/GeoIpCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testCreateCommand(): void
2929
$locationService = $this->createMock(LocationServiceInterface::class);
3030

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

3535
/**

test/Data/CityDataTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ public function testAccessors()
2323
{
2424
$cityData = new CityData();
2525
$cityData->setName($this->defaults['city']['name']);
26-
$this->assertInstanceOf(CityData::class, $cityData);
26+
$this->assertContainsOnlyInstancesOf(CityData::class, [$cityData]);
2727
$this->assertSame($cityData->getName(), $this->defaults['city']['name']);
2828
$cityData->setError($this->defaults['city']['error']);
29-
$this->assertInstanceOf(CityData::class, $cityData);
29+
$this->assertContainsOnlyInstancesOf(CityData::class, [$cityData]);
3030
$this->assertSame($cityData->getError(), $this->defaults['city']['error']);
3131
}
3232

3333
public function testExchangeArray()
3434
{
3535
$cityData = (new CityData())->exchangeArray($this->defaults['city']);
36-
$this->assertInstanceOf(CityData::class, $cityData);
36+
$this->assertContainsOnlyInstancesOf(CityData::class, [$cityData]);
3737
$this->assertSame($cityData->getName(), $this->defaults['city']['name']);
3838
$this->assertSame($cityData->getError(), $this->defaults['city']['error']);
3939
}

test/Data/ContinentDataTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ public function testAccessors(): void
2424
{
2525
$continentData = new ContinentData();
2626
$continentData->setCode($this->defaults['continent']['code']);
27-
$this->assertInstanceOf(ContinentData::class, $continentData);
27+
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
2828
$this->assertSame($continentData->getCode(), $this->defaults['continent']['code']);
2929
$continentData->setName($this->defaults['continent']['name']);
30-
$this->assertInstanceOf(ContinentData::class, $continentData);
30+
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
3131
$this->assertSame($continentData->getName(), $this->defaults['continent']['name']);
3232
$continentData->setError($this->defaults['continent']['error']);
33-
$this->assertInstanceOf(ContinentData::class, $continentData);
33+
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
3434
$this->assertSame($continentData->getError(), $this->defaults['continent']['error']);
3535
}
3636

3737
public function testExchangeArray(): void
3838
{
3939
$continentData = (new ContinentData())->exchangeArray($this->defaults['continent']);
40-
$this->assertInstanceOf(ContinentData::class, $continentData);
40+
$this->assertContainsOnlyInstancesOf(ContinentData::class, [$continentData]);
4141
$this->assertSame($continentData->getCode(), $this->defaults['continent']['code']);
4242
$this->assertSame($continentData->getName(), $this->defaults['continent']['name']);
4343
$this->assertSame($continentData->getError(), $this->defaults['continent']['error']);

test/Data/CountryDataTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ public function testAccessors(): void
2525
{
2626
$countryData = new CountryData();
2727
$countryData->setIsEuMember($this->defaults['country']['isEuMember']);
28-
$this->assertInstanceOf(CountryData::class, $countryData);
28+
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
2929
$this->assertSame($countryData->getIsEuMember(), $this->defaults['country']['isEuMember']);
3030
$countryData->setIsoCode($this->defaults['country']['isoCode']);
31-
$this->assertInstanceOf(CountryData::class, $countryData);
31+
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
3232
$this->assertSame($countryData->getIsoCode(), $this->defaults['country']['isoCode']);
3333
$countryData->setName($this->defaults['country']['name']);
34-
$this->assertInstanceOf(CountryData::class, $countryData);
34+
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
3535
$this->assertSame($countryData->getName(), $this->defaults['country']['name']);
3636
$countryData->setError($this->defaults['country']['error']);
37-
$this->assertInstanceOf(CountryData::class, $countryData);
37+
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
3838
$this->assertSame($countryData->getError(), $this->defaults['country']['error']);
3939
}
4040

4141
public function testExchangeArray(): void
4242
{
4343
$countryData = (new CountryData())->exchangeArray($this->defaults['country']);
44-
$this->assertInstanceOf(CountryData::class, $countryData);
44+
$this->assertContainsOnlyInstancesOf(CountryData::class, [$countryData]);
4545
$this->assertSame($countryData->getIsEuMember(), $this->defaults['country']['isEuMember']);
4646
$this->assertSame($countryData->getIsoCode(), $this->defaults['country']['isoCode']);
4747
$this->assertSame($countryData->getName(), $this->defaults['country']['name']);

0 commit comments

Comments
 (0)