Skip to content

Commit c9fe642

Browse files
authored
Merge pull request #21 from Howriq/issue-#20
Issue #20: Replace Psalm with PHPStan
2 parents a043b83 + 6e7cc18 commit c9fe642

9 files changed

Lines changed: 92 additions & 57 deletions

File tree

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

README.md

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

3-
Authorization base package defining interfaces for authorization services to be used with Dotkernel applications.
3+
Dotkernel authorization service abstractions.
4+
5+
`dot-authorization` is Dotkernel's authorization base package which define interfaces for authorization services to be used with Dotkernel applications.
6+
7+
## Documentation
8+
9+
Documentation is available at: https://docs.dotkernel.org/dot-authorization/.
10+
11+
## Badges
412

513
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-authorization)
6-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-authorization/3.6.1)
14+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-authorization/3.7.0)
715

816
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/issues)
917
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/network)
@@ -12,6 +20,7 @@ Authorization base package defining interfaces for authorization services to be
1220

1321
[![Build Static](https://github.com/dotkernel/dot-authorization/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-authorization/actions/workflows/continuous-integration.yml)
1422
[![codecov](https://codecov.io/gh/dotkernel/dot-authorization/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-authorization)
23+
[![PHPStan](https://github.com/dotkernel/dot-authorization/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-authorization/actions/workflows/static-analysis.yml)
1524

1625
## Installation
1726

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
},
2121
"require-dev": {
2222
"laminas/laminas-coding-standard": "^3.0",
23-
"phpunit/phpunit": "10.2",
24-
"vimeo/psalm": "^6.0"
23+
"phpstan/phpstan": "^2.1",
24+
"phpstan/phpstan-phpunit": "^2.0",
25+
"phpunit/phpunit": "10.2"
2526
},
2627
"autoload": {
2728
"psr-4": {
@@ -48,7 +49,6 @@
4849
"cs-check": "phpcs",
4950
"cs-fix": "phpcbf",
5051
"test": "phpunit --colors=always",
51-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
52-
"static-analysis": "psalm --shepherd --stats"
52+
"static-analysis": "phpstan analyse --memory-limit 1G"
5353
}
5454
}

docs/book/v3/overview.md

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

3+
Dotkernel authorization service abstractions.
4+
35
`dot-authorization` is Dotkernel's authorization base package which define interfaces for authorization services to be used with Dotkernel applications.
6+
7+
## Badges
8+
9+
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-authorization)
10+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-authorization/3.7.0)
11+
12+
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/issues)
13+
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/network)
14+
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/stargazers)
15+
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-authorization)](https://github.com/dotkernel/dot-authorization/blob/3.0/LICENSE.md)
16+
17+
[![Build Static](https://github.com/dotkernel/dot-authorization/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-authorization/actions/workflows/continuous-integration.yml)
18+
[![codecov](https://codecov.io/gh/dotkernel/dot-authorization/graph/badge.svg?token=ZBZDEA3LY8)](https://codecov.io/gh/dotkernel/dot-authorization)
19+
[![PHPStan](https://github.com/dotkernel/dot-authorization/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-authorization/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-baseline.xml

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

psalm.xml

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

test/Exception/ForbiddenExceptionTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66

77
use Dot\Authorization\Exception\ExceptionInterface;
88
use Dot\Authorization\Exception\ForbiddenException;
9-
use PHPUnit\Framework\MockObject\Exception;
109
use PHPUnit\Framework\MockObject\MockObject;
1110
use PHPUnit\Framework\TestCase;
1211

1312
class ForbiddenExceptionTest extends TestCase
1413
{
1514
protected ForbiddenException|MockObject $forbiddenExceptionMock;
1615

17-
/**
18-
* @throws Exception
19-
*/
2016
public function setUp(): void
2117
{
2218
$this->forbiddenExceptionMock = $this->createMock(ForbiddenException::class);
@@ -25,6 +21,6 @@ public function setUp(): void
2521
public function testCreate(): void
2622
{
2723
$this->assertInstanceOf(ForbiddenException::class, $this->forbiddenExceptionMock);
28-
$this->assertInstanceOf(ExceptionInterface::class, $this->forbiddenExceptionMock);
24+
$this->assertContainsOnlyInstancesOf(ExceptionInterface::class, [$this->forbiddenExceptionMock]);
2925
}
3026
}

test/Exception/RuntimeExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RuntimeExceptionTest extends TestCase
1313
public function testInstances(): void
1414
{
1515
$exception = new RuntimeException('test');
16-
$this->assertInstanceOf(RuntimeException::class, $exception);
17-
$this->assertInstanceOf(ExceptionInterface::class, $exception);
16+
$this->assertSame(RuntimeException::class, $exception::class);
17+
$this->assertContainsOnlyInstancesOf(ExceptionInterface::class, [$exception]);
1818
}
1919
}

0 commit comments

Comments
 (0)