Skip to content

Commit 93a6b85

Browse files
authored
Merge pull request #15 from Jurj-Bogdan/3.0
added phpunit, laminas coding standard, psalm and tests
2 parents cb1c964 + bf12dbf commit 93a6b85

23 files changed

Lines changed: 1001 additions & 252 deletions

.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-tests.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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
MIT License
22

3-
Copyright (c) 2020 Apidemia
3+
Copyright (c) 2023 Apidemia
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
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.

OSSMETADATA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
osslifecycle=active
1+
osslifecycle=active

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
Logging Error Handler for DotKernel
44

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

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

13+
[![SymfonyInsight](https://insight.symfony.com/projects/cf1f8d89-f230-4157-bc8b-7cce20c75454/big.svg)](https://insight.symfony.com/projects/cf1f8d89-f230-4157-bc8b-7cce20c75454)
14+
15+
1316
## Adding the error handler
1417

1518
* Add the composer package:

composer.json

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,48 @@
1919
"mezzio",
2020
"service-manager"
2121
],
22+
"config": {
23+
"sort-packages": true,
24+
"allow-plugins": {
25+
"dealerdirect/phpcodesniffer-composer-installer": true
26+
}
27+
},
2228
"require": {
23-
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
24-
"dotkernel/dot-log": "^3.2.0",
25-
"laminas/laminas-diactoros": "^2.8.0",
26-
"psr/http-message": "^1.0.1",
29+
"php": "~8.1.0 || ~8.2.0",
30+
"dotkernel/dot-log": "^3.3.0",
31+
"laminas/laminas-diactoros": "^2.25.2",
32+
"laminas/laminas-stratigility": "^3.10.0",
33+
"mezzio/mezzio": "^3.17.0",
34+
"psr/http-message": "^1.1",
35+
"psr/http-server-middleware": "^1.0.2",
2736
"psr/container": "^1.1.2"
2837
},
38+
"require-dev": {
39+
"laminas/laminas-coding-standard": "^2.5",
40+
"mikey179/vfsstream": "^1.6",
41+
"phpunit/phpunit": "^10.2.3",
42+
"vimeo/psalm": "^5.13"
43+
},
2944
"autoload": {
3045
"psr-4": {
3146
"Dot\\ErrorHandler\\": "src/"
3247
}
3348
},
34-
"minimum-stability": "stable"
49+
"autoload-dev": {
50+
"psr-4": {
51+
"DotTest\\ErrorHandler\\": "test/"
52+
}
53+
},
54+
"minimum-stability": "stable",
55+
"scripts": {
56+
"check": [
57+
"@cs-check",
58+
"@test"
59+
],
60+
"cs-check": "phpcs",
61+
"cs-fix": "phpcbf",
62+
"test": "phpunit --colors=always",
63+
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
64+
"static-analysis": "psalm --shepherd --stats"
65+
}
3566
}

config/error-handling.global.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ return [
1313
'loggerEnabled' => true,
1414
'logger' => 'dot-log.default_logger'
1515
]
16-
];
16+
];

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>

0 commit comments

Comments
 (0)