Skip to content

Commit 5a40757

Browse files
authored
Merge pull request dotkernel#46 from Howriq/Issue-#45
Issue#45: Replace Psalm with PHPStan
2 parents f8529ba + b7d8cdf commit 5a40757

File tree

9 files changed

+93
-28
lines changed

9 files changed

+93
-28
lines changed
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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ This is Dotkernel's controller package that can be use like middleware inside Do
44
It provides base classes for action based controllers similar to Laminas controller component.
55
It is more lightweight though, but supports controller plugins and event listeners.
66

7+
## Documentation
8+
9+
Documentation is available at: https://docs.dotkernel.org/dot-controller/.
10+
11+
## Badges
12+
713
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-controller)
8-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/4.0.1)
14+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/4.1.0)
915

1016
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/issues)
1117
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/network)
@@ -14,6 +20,7 @@ It is more lightweight though, but supports controller plugins and event listene
1420

1521
[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml)
1622
[![codecov](https://codecov.io/gh/dotkernel/dot-controller/graph/badge.svg?token=VUBG5LM4CK)](https://codecov.io/gh/dotkernel/dot-controller)
23+
[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml)
1724

1825
## Installation
1926

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
"require-dev": {
2929
"laminas/laminas-coding-standard": "^3.0",
3030
"laminas/laminas-diactoros": "^3.0",
31-
"phpunit/phpunit": "^10.2",
32-
"vimeo/psalm": "^6.0"
31+
"phpstan/phpstan": "^2.1",
32+
"phpstan/phpstan-phpunit": "^2.0",
33+
"phpunit/phpunit": "^10.2"
3334
},
3435
"autoload": {
3536
"psr-4": {
@@ -50,8 +51,7 @@
5051
"cs-check": "phpcs",
5152
"cs-fix": "phpcbf",
5253
"test": "phpunit --colors=always",
53-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
54-
"static-analysis": "psalm --shepherd --stats"
54+
"static-analysis": "phpstan analyse --memory-limit 1G"
5555
},
5656
"config": {
5757
"sort-packages": true,

docs/book/v4/overview.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@
33
`dot-controller` is Dotkernel's controller package that can be use like middleware inside Dotkernel or Mezzio application.
44
It provides base classes for action based controllers similar to Laminas controller component.
55
It is more lightweight though, but supports controller plugins and event listeners.
6+
7+
## Badges
8+
9+
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-controller)
10+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/4.1.0)
11+
12+
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/issues)
13+
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/network)
14+
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/stargazers)
15+
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/blob/4.0/LICENSE.md)
16+
17+
[![Build Static](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/continuous-integration.yml)
18+
[![codecov](https://codecov.io/gh/dotkernel/dot-controller/graph/badge.svg?token=VUBG5LM4CK)](https://codecov.io/gh/dotkernel/dot-controller)
19+
[![PHPStan](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml)

phpstan.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
includes:
2+
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
parameters:
4+
level: 5
5+
paths:
6+
- src
7+
- test
8+
treatPhpDocTypesAsCertain: false
9+
ignoreErrors:
10+
- message: '#Call to an undefined method .*::somePlugin\(\)\.#'
11+
path: test/AbstractControllerTest.php
12+
- message: '#Call to an undefined method .*::callablePlugin\(\)\.#'
13+
path: test/AbstractControllerTest.php

psalm.xml

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

test/AbstractActionControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testNonExistingActionWillReturnResponse(): void
2828
};
2929

3030
$response = $subject->process($request, $handler);
31-
$this->assertInstanceOf(ResponseInterface::class, $response);
31+
$this->assertContainsOnlyInstancesOf(ResponseInterface::class, [$response]);
3232
}
3333

3434
/**
@@ -49,6 +49,6 @@ public function indexAction(): ResponseInterface
4949
};
5050

5151
$response = $subject->process($request, $handler);
52-
$this->assertInstanceOf(ResponseInterface::class, $response);
52+
$this->assertContainsOnlyInstancesOf(ResponseInterface::class, [$response]);
5353
}
5454
}

test/Factory/ControllerEventListenersInitializerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,5 @@ public function testAttachControllerListeners(): void
7373
->with($this->isInstanceOf(ControllerEventListenerInterface::class), 1);
7474

7575
$this->subject->attachControllerListeners($this->container, $this->controller);
76-
77-
$this->assertTrue(true);
7876
}
7977
}

test/Factory/PluginManagerFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testInvokeWithUrlHelper(): void
6060

6161
$pluginManager = $this->subject->__invoke($this->container);
6262

63-
$this->assertInstanceOf(PluginManager::class, $pluginManager);
63+
$this->assertContainsOnlyInstancesOf(PluginManager::class, [$pluginManager]);
6464
$this->assertTrue($pluginManager->has('url'));
6565
$this->assertFalse($pluginManager->has('template'));
6666
$this->assertInstanceOf(UrlHelperPlugin::class, $pluginManager->get('url'));
@@ -91,7 +91,7 @@ public function testInvokeWithTemplateRenderer(): void
9191

9292
$pluginManager = $this->subject->__invoke($this->container);
9393

94-
$this->assertInstanceOf(PluginManager::class, $pluginManager);
94+
$this->assertContainsOnlyInstancesOf(PluginManager::class, [$pluginManager]);
9595
$this->assertTrue($pluginManager->has('template'));
9696
$this->assertFalse($pluginManager->has('url'));
9797
$this->assertInstanceOf(TemplatePlugin::class, $pluginManager->get('template'));

0 commit comments

Comments
 (0)