Skip to content

Commit 1d37592

Browse files
committed
v1.1
1 parent d66a0cd commit 1d37592

File tree

5 files changed

+106
-156
lines changed

5 files changed

+106
-156
lines changed

.github/workflows/acceptance.yml

Lines changed: 61 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -3,141 +3,91 @@ name: Acceptance
33
on: [push, pull_request]
44

55
jobs:
6-
test-7-2:
7-
runs-on: ubuntu-latest
8-
name: Test PHP 7.2
9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v3
12-
- name: Set up PHP 7.2
13-
uses: shivammathur/setup-php@v2
14-
with:
15-
php-version: '7.2'
16-
- name: Composer
17-
run: make deps-install
18-
- name: Test
19-
run: make test
206

21-
test-7-3:
7+
test:
8+
strategy:
9+
matrix:
10+
php-versions: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
2211
runs-on: ubuntu-latest
23-
name: Test PHP 7.3
12+
name: Unit test
2413
steps:
2514
- name: Checkout
26-
uses: actions/checkout@v3
27-
- name: Set up PHP 7.3
15+
uses: actions/checkout@v4
16+
- name: Set up PHP
2817
uses: shivammathur/setup-php@v2
2918
with:
30-
php-version: '7.3'
31-
- name: Composer
32-
run: make deps-install
33-
- name: Test
34-
run: make test
35-
36-
test-7-4:
37-
runs-on: ubuntu-latest
38-
name: Test PHP 7.4
39-
steps:
40-
- name: Checkout
41-
uses: actions/checkout@v3
42-
- name: Set up PHP 7.4
43-
uses: shivammathur/setup-php@v2
44-
with:
45-
php-version: '7.4'
46-
- name: Composer
47-
run: make deps-install
48-
- name: Test
49-
run: make test
50-
51-
test-8-0:
52-
runs-on: ubuntu-latest
53-
name: Test PHP 8.0
54-
steps:
55-
- name: Checkout
56-
uses: actions/checkout@v3
57-
- name: Set up PHP 8.0
58-
uses: shivammathur/setup-php@v2
59-
with:
60-
php-version: '8.0'
61-
- name: Composer
62-
run: make deps-install
63-
- name: Test
64-
run: make test
65-
66-
test-8-1:
67-
runs-on: ubuntu-latest
68-
name: Test PHP 8.1
69-
steps:
70-
- name: Checkout
71-
uses: actions/checkout@v3
72-
- name: Set up PHP 8.1
73-
uses: shivammathur/setup-php@v2
74-
with:
75-
php-version: '8.1'
76-
extensions: pdo, pdo-sqlite
77-
- name: Composer
78-
run: make deps-install
79-
- name: Test
80-
run: make test
81-
82-
test-8-2:
83-
runs-on: ubuntu-latest
84-
name: Test PHP 8.2
85-
steps:
86-
- name: Checkout
87-
uses: actions/checkout@v3
88-
- name: Set up PHP 8.2
89-
uses: shivammathur/setup-php@v2
90-
with:
91-
php-version: '8.2'
92-
- name: Composer
93-
run: make deps-install
94-
- name: Test
95-
run: make test
96-
97-
test-8-3:
98-
runs-on: ubuntu-latest
99-
name: Test PHP 8.3
100-
steps:
101-
- name: Checkout
102-
uses: actions/checkout@v3
103-
- name: Set up PHP 8.3
104-
uses: shivammathur/setup-php@v2
19+
php-version: ${{ matrix.php-versions }}
20+
coverage: none
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
- name: Get composer cache directory
24+
id: composer-cache
25+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
26+
- name: Cache dependencies
27+
uses: actions/cache@v4
10528
with:
106-
php-version: '8.3'
107-
- name: Composer
108-
run: make deps-install
29+
path: ${{ steps.composer-cache.outputs.dir }}
30+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
31+
restore-keys: ${{ runner.os }}-composer-
32+
- name: Install dependencies
33+
run: composer install --prefer-dist
10934
- name: Test
110-
run: make test
35+
run: vendor/bin/phpunit
11136

11237
cs-check:
11338
runs-on: ubuntu-latest
11439
name: Code standard
11540
steps:
11641
- name: Checkout
117-
uses: actions/checkout@v3
118-
- name: Set up PHP 8.2
42+
uses: actions/checkout@v4
43+
- name: Set up PHP
11944
uses: shivammathur/setup-php@v2
12045
with:
121-
php-version: '8.2'
122-
- name: Composer
123-
run: make deps-install
46+
php-version: "8.3"
47+
coverage: none
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
- name: Get composer cache directory
51+
id: composer-cache
52+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
53+
- name: Cache dependencies
54+
uses: actions/cache@v4
55+
with:
56+
path: ${{ steps.composer-cache.outputs.dir }}
57+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
58+
restore-keys: ${{ runner.os }}-composer-
59+
- name: Install dependencies
60+
run: composer install --prefer-dist
12461
- name: Code standard
125-
run: make cs-check
62+
run: vendor/bin/phpcs --standard=PSR1,PSR12 --encoding=UTF-8 --report=full --colors src tests
12663

12764
coverage:
12865
runs-on: ubuntu-latest
12966
name: Code coverage
13067
steps:
13168
- name: Checkout
132-
uses: actions/checkout@v3
133-
- name: Set up PHP 8.0
69+
uses: actions/checkout@v4
70+
- name: Set up PHP
13471
uses: shivammathur/setup-php@v2
13572
with:
136-
php-version: '8.0'
137-
extensions: xdebug
138-
- name: Composer
139-
run: make deps-install
140-
- name: Code coverage
73+
php-version: "8.3"
74+
coverage: xdebug
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
- name: Get composer cache directory
78+
id: composer-cache
79+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
80+
- name: Cache dependencies
81+
uses: actions/cache@v4
82+
with:
83+
path: ${{ steps.composer-cache.outputs.dir }}
84+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
85+
restore-keys: ${{ runner.os }}-composer-
86+
- name: Install dependencies
87+
run: composer install --prefer-dist
88+
- name: Code coverage build
89+
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-clover build/logs/clover.xml
90+
- name: Code coverage upload
14191
env:
14292
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143-
run: make coverage
93+
run: vendor/bin/php-coveralls -v

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,5 @@ Phrity\Util\ErrorHandler {
143143

144144
| Version | PHP | |
145145
| --- | --- | --- |
146+
| `1.1` | `^7.4\|^8.0` | Some improvements |
146147
| `1.0` | `^7.2\|^8.0` | Initial version |

composer.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
2-
"name": "phrity/util-errorhandler",
3-
"type": "library",
4-
"description": "Inline error handler; catch and resolve errors for code block.",
5-
"homepage": "https://phrity.sirn.se/util-errorhandler",
6-
"keywords": ["error", "warning"],
7-
"license": "MIT",
8-
"authors": [
9-
{
10-
"name": "Sören Jensen",
11-
"email": "[email protected]",
12-
"homepage": "https://phrity.sirn.se"
2+
"name": "phrity/util-errorhandler",
3+
"type": "library",
4+
"description": "Inline error handler; catch and resolve errors for code block.",
5+
"homepage": "https://phrity.sirn.se/util-errorhandler",
6+
"keywords": ["error", "warning"],
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Sören Jensen",
11+
"email": "[email protected]",
12+
"homepage": "https://phrity.sirn.se"
13+
}
14+
],
15+
"autoload": {
16+
"psr-4": {
17+
"": "src/"
18+
}
19+
},
20+
"autoload-dev": {
21+
"psr-4": {
22+
"": "tests/"
23+
}
24+
},
25+
"require": {
26+
"php": "^7.4 | ^8.0"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "^9.0 | ^10.0 | ^11.0",
30+
"php-coveralls/php-coveralls": "^2.0",
31+
"squizlabs/php_codesniffer": "^3.5"
1332
}
14-
],
15-
"autoload": {
16-
"psr-4": {
17-
"": "src/"
18-
}
19-
},
20-
"autoload-dev": {
21-
"psr-4": {
22-
"": "tests/"
23-
}
24-
},
25-
"require": {
26-
"php": "^7.2|^8.0"
27-
},
28-
"require-dev": {
29-
"phpunit/phpunit": "^8.0|^9.0|^10.0",
30-
"php-coveralls/php-coveralls": "^2.0",
31-
"squizlabs/php_codesniffer": "^3.5"
32-
}
3333
}

phpunit.xml.dist

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

src/Phrity/Util/ErrorHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ public function with(callable $callback, $handling = null, int $levels = E_ALL)
6060
$result = $callback();
6161
} catch (ErrorException $e) {
6262
$error = $this->handle($handling, $e);
63+
} finally {
64+
$this->restore();
6365
}
64-
$this->restore();
6566
return $error ?: $result;
6667
}
6768

0 commit comments

Comments
 (0)