Skip to content

Commit aaec8ea

Browse files
authored
Merge pull request #38 from Howriq/issue-#37
Issue #37: Replace Psalm with PHPStan
2 parents 1626451 + 4e75633 commit aaec8ea

23 files changed

Lines changed: 116 additions & 68 deletions
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: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# dot-navigation
22

3+
`dot-navigation` is Dotkernel's component that allows you to easily define and parse menus inside templates, using a configuration based approach.
4+
5+
## Documentation
6+
7+
Documentation is available at: https://docs.dotkernel.org/dot-navigation/.
8+
9+
## Badges
10+
311
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-navigation)
4-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-navigation/4.0.2)
12+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-navigation/4.1.0)
513

614
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-navigation)](https://github.com/dotkernel/dot-navigation/issues)
715
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-navigation)](https://github.com/dotkernel/dot-navigation/network)
@@ -10,8 +18,7 @@
1018

1119
[![Build Static](https://github.com/dotkernel/dot-navigation/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-navigation/actions/workflows/continuous-integration.yml)
1220
[![codecov](https://codecov.io/gh/dotkernel/dot-navigation/graph/badge.svg?token=AI9WFYDDX9)](https://codecov.io/gh/dotkernel/dot-navigation)
13-
14-
Allows you to easily define and parse menus inside templates, configuration based approach.
21+
[![PHPStan](https://github.com/dotkernel/dot-navigation/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-navigation/actions/workflows/static-analysis.yml)
1522

1623
## Installation
1724

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
},
3636
"require-dev": {
3737
"laminas/laminas-coding-standard": "^3.0.0",
38-
"phpunit/phpunit": "^10.4.2",
39-
"vimeo/psalm": "^6.0"
38+
"phpstan/phpstan": "^2.1",
39+
"phpstan/phpstan-phpunit": "^2.0",
40+
"phpunit/phpunit": "^10.4.2"
4041
},
4142
"autoload": {
4243
"psr-4": {
@@ -57,7 +58,6 @@
5758
"cs-check": "phpcs",
5859
"cs-fix": "phpcbf",
5960
"test": "phpunit --colors=always",
60-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
61-
"static-analysis": "psalm --shepherd --stats"
61+
"static-analysis": "phpstan analyse --memory-limit 1G"
6262
}
6363
}

docs/book/v4/overview.md

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

33
`dot-navigation` is Dotkernel's component that allows you to easily define and parse menus inside templates, using a configuration based approach.
4+
5+
## Badges
6+
7+
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-navigation)
8+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-navigation/4.1.0)
9+
10+
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-navigation)](https://github.com/dotkernel/dot-navigation/issues)
11+
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-navigation)](https://github.com/dotkernel/dot-navigation/network)
12+
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-navigation)](https://github.com/dotkernel/dot-navigation/stargazers)
13+
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-navigation)](https://github.com/dotkernel/dot-navigation/blob/4.0/LICENSE.md)
14+
15+
[![Build Static](https://github.com/dotkernel/dot-navigation/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-navigation/actions/workflows/continuous-integration.yml)
16+
[![codecov](https://codecov.io/gh/dotkernel/dot-navigation/graph/badge.svg?token=AI9WFYDDX9)](https://codecov.io/gh/dotkernel/dot-navigation)
17+
[![PHPStan](https://github.com/dotkernel/dot-navigation/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-navigation/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 & 13 deletions
This file was deleted.

psalm.xml

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

src/View/AbstractNavigationRenderer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ protected function getContainer(string|NavigationContainer $container): Navigati
9898
{
9999
if (is_string($container)) {
100100
return $this->navigation->getContainer($container);
101-
} elseif (! $container instanceof NavigationContainer) {
101+
} elseif ($container instanceof NavigationContainer) {
102+
return $container;
103+
} else {
102104
throw new RuntimeException('Container must be a string or an instance of ' . NavigationContainer::class);
103105
}
104-
105-
return $container;
106106
}
107107

108108
protected function cleanAttributes(array $input, array $valid): array

test/Exception/InvalidArgumentExceptionTest.php

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

test/Exception/RuntimeExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function setUp(): void
1818
public function testWillReturnCorrectInstances(): void
1919
{
2020
$exception = new RuntimeException('test');
21-
$this->assertInstanceOf(RuntimeException::class, $exception);
22-
$this->assertInstanceOf(ExceptionInterface::class, $exception);
21+
$this->assertSame(RuntimeException::class, $exception::class);
22+
$this->assertContainsOnlyInstancesOf(ExceptionInterface::class, [$exception]);
2323
}
2424
}

0 commit comments

Comments
 (0)