Skip to content

Commit c0064a1

Browse files
authored
Merge pull request #27 from OnitaAndrei/issue-26
implemented psalm, cs-check, static analysis & added tests
2 parents 032b1f3 + c258d75 commit c0064a1

39 files changed

+1185
-384
lines changed

.github/workflows/cs-tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
on:
2+
- push
3+
4+
name: Run phpcs checks
5+
6+
jobs:
7+
mutation:
8+
name: PHP ${{ 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+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: "${{ matrix.php }}"
29+
tools: composer:v2, cs2pr
30+
coverage: none
31+
32+
- name: Determine composer cache directory
33+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
34+
35+
- name: Cache dependencies installed with composer
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ env.COMPOSER_CACHE_DIR }}
39+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: |
41+
php${{ matrix.php }}-composer-
42+
- name: Install dependencies with composer
43+
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
44+
45+
- name: Run phpcs checks
46+
run: vendor/bin/phpcs
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
on:
2+
- push
3+
4+
name: Run static analysis
5+
6+
jobs:
7+
mutation:
8+
name: PHP ${{ 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+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: "${{ matrix.php }}"
29+
tools: composer:v2, cs2pr
30+
coverage: none
31+
32+
- name: Determine composer cache directory
33+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
34+
35+
- name: Cache dependencies installed with composer
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ env.COMPOSER_CACHE_DIR }}
39+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: |
41+
php${{ matrix.php }}-composer-
42+
- name: Install dependencies with composer
43+
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
44+
45+
- name: Run static analysis
46+
run: vendor/bin/psalm --no-cache --output-format=github --show-info=false --threads=4

.github/workflows/unit-test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
on:
2+
- push
3+
4+
name: Run PHPUnit tests
5+
6+
jobs:
7+
mutation:
8+
name: PHP ${{ 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+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: "${{ matrix.php }}"
29+
tools: composer:v2, cs2pr
30+
coverage: none
31+
32+
- name: Determine composer cache directory
33+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
34+
35+
- name: Cache dependencies installed with composer
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ env.COMPOSER_CACHE_DIR }}
39+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
40+
restore-keys: |
41+
php${{ matrix.php }}-composer-
42+
43+
- name: Install dependencies with composer
44+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
45+
46+
- name: Run PHPUnit tests
47+
run: vendor/bin/phpunit --colors=always

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
clover.xml
22
coveralls-upload.json
3-
phpunit.xml
3+
.phpunit.result.cache
4+
.phpcs-cache
45

56
# Created by .ignore support plugin (hsz.mobi)
67
### JetBrains template
@@ -36,4 +37,4 @@ composer.phar
3637

3738
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
3839
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
39-
composer.lock
40+
composer.lock

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
66

77
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
88

9-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
This package contains controller like middleware to be used inside a DotKernel or Mezzio application. It provides base classes for action based controllers similar to Laminas controller component. It is more lightweight though, but supports controller plugins.
44

55
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-controller)
6-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.2.0)
6+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-controller/3.4.0)
77

88
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/issues)
99
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/network)
1010
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/stargazers)
1111
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-controller)](https://github.com/dotkernel/dot-controller/blob/3.0/LICENSE.md)
1212

13+
[![Build Static](https://github.com/dotkernel/dot-auth-social/actions/workflows/static-analysis.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-controller/actions/workflows/static-analysis.yml)
14+
15+
[![SymfonyInsight](https://insight.symfony.com/projects/c4aac671-40d7-4590-b1fa-b3e46a1e3f43/big.svg)](https://insight.symfony.com/projects/c4aac671-40d7-4590-b1fa-b3e46a1e3f43)
16+
1317
## Installation
1418

1519
Run the following composer command in your project directory
@@ -86,8 +90,3 @@ Although these are optional, if a package is missing, the controller will not ha
8690

8791
- `template` wraps TemplateInterface provided by Mezzio, to make template engine accessible to any controller
8892
- `url` wraps the UrlHelper class provided by Laminas helpers package. Used to generate URIs from routes
89-
90-
91-
## Controller Events
92-
93-
// @TODO

composer.json

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^7.4 || ~8.0.0 || ~8.1.0",
21+
"php": "~8.1.0 || ~8.2.0",
2222
"psr/http-message": "^1.0.1",
2323
"laminas/laminas-servicemanager": "^3.11.2",
24-
"dotkernel/dot-event": "^3.2.0"
24+
"dotkernel/dot-event": "^3.2.0",
25+
"mezzio/mezzio-template": "^2.4.0",
26+
"mezzio/mezzio-helpers": "^5.8.0"
2527
},
2628
"require-dev": {
27-
"mezzio/mezzio-template": "^2.4.0",
28-
"mezzio/mezzio-helpers": "^5.8.0",
29-
"phpunit/phpunit": "^9.5.20",
30-
"squizlabs/php_codesniffer": "^3.6.2"
29+
"phpunit/phpunit": "^10.2",
30+
"vimeo/psalm": "^5.13",
31+
"laminas/laminas-coding-standard": "^2.5",
32+
"laminas/laminas-diactoros": "^3.0"
3133
},
3234
"autoload": {
3335
"psr-4": {
@@ -38,5 +40,22 @@
3840
"psr-4": {
3941
"DotTest\\Controller\\": "test/"
4042
}
43+
},
44+
"scripts": {
45+
"check": [
46+
"@cs-check",
47+
"@test"
48+
],
49+
"cs-check": "phpcs",
50+
"cs-fix": "phpcbf",
51+
"test": "phpunit --colors=always",
52+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
53+
"static-analysis": "psalm --shepherd --stats"
54+
},
55+
"config": {
56+
"sort-packages": true,
57+
"allow-plugins": {
58+
"dealerdirect/phpcodesniffer-composer-installer": true
59+
}
4160
}
4261
}

phpcs.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
4+
5+
<arg name="basepath" value="."/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
<arg name="extensions" value="php"/>
9+
<arg name="parallel" value="80"/>
10+
11+
<!-- Show progress -->
12+
<arg value="p"/>
13+
14+
<!-- Paths to check -->
15+
<file>src</file>
16+
<file>test</file>
17+
18+
<!-- Include all rules from the Laminas Coding Standard -->
19+
<rule ref="LaminasCodingStandard"/>
20+
</ruleset>

phpunit.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true">
3+
<testsuites>
4+
<testsuite name="dot-controller Test Suite">
5+
<directory>./test</directory>
6+
</testsuite>
7+
</testsuites>
8+
<coverage/>
9+
<source>
10+
<include>
11+
<directory suffix=".php">./src</directory>
12+
</include>
13+
</source>
14+
</phpunit>

psalm.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="4"
4+
resolveFromConfigFile="true"
5+
findUnusedCode="false"
6+
findUnusedBaselineEntry="true"
7+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8+
xmlns="https://getpsalm.org/schema/config"
9+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
10+
>
11+
<projectFiles>
12+
<directory name="src" />
13+
<ignoreFiles>
14+
<directory name="vendor" />
15+
</ignoreFiles>
16+
</projectFiles>
17+
</psalm>

0 commit comments

Comments
 (0)