Skip to content

Commit dd29662

Browse files
authored
Merge branch 'master' into solution
2 parents b5e5ddf + ea53acc commit dd29662

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1037
-233
lines changed

.github/workflows/bc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
os: >-
3131
['ubuntu-latest']
3232
php: >-
33-
['8.0']
33+
['8.1']

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
os: >-
3232
['ubuntu-latest', 'windows-latest']
3333
php: >-
34-
['8.0', '8.1', '8.2', '8.3']
34+
['8.1', '8.2', '8.3', '8.4']

.github/workflows/composer-require-checker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
os: >-
3232
['ubuntu-latest']
3333
php: >-
34-
['8.0', '8.1', '8.2', '8.3']
34+
['8.1', '8.2', '8.3', '8.4']

.github/workflows/rector.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
os: >-
2222
['ubuntu-latest']
2323
php: >-
24-
['8.3']
24+
['8.4']

.github/workflows/static.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,4 @@ jobs:
2929
os: >-
3030
['ubuntu-latest']
3131
php: >-
32-
['8.1', '8.2', '8.3']
33-
psalm80:
34-
uses: yiisoft/actions/.github/workflows/psalm.yml@master
35-
with:
36-
psalm-config: psalm80.xml
37-
os: >-
38-
['ubuntu-latest']
39-
php: >-
40-
['8.0']
32+
['8.1', '8.2', '8.3', '8.4']

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ Thumbs.db
1616
composer.phar
1717
composer.lock
1818

19-
# phpunit itself is not needed
20-
phpunit.phar
21-
# local phpunit config
19+
# PHPUnit
20+
/phpunit.phar
2221
/phpunit.xml
23-
# phpunit cache
24-
.phpunit.result.cache
22+
/.phpunit.cache

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
# Yii Error Handler Change Log
22

3-
## 3.4.0 under development
3+
## 4.1.1 under development
44

5+
- no changes in this release.
6+
7+
## 4.1.0 April 18, 2025
8+
9+
- New #145: Add `Yiisoft\ErrorHandler\ThrowableResponseFactory` that provides a response for `Throwable` object with
10+
renderer provider usage (@vjik)
11+
- Chg #145: Mark `Yiisoft\ErrorHandler\Factory\ThrowableResponseFactory` as deprecated (@vjik)
12+
- Enh #145: Set content type header in renderers (@vjik)
13+
- Bug #142: Fix dark mode argument display issues (@pamparam83)
14+
15+
## 4.0.0 February 05, 2025
16+
17+
- Chg #137: Add separate parameters for each of `HtmlRenderer` settings in constructor. Mark `$settings` parameter as
18+
deprecated (@vjik)
19+
- Chg #139: Change PHP constraint in `composer.json` to `~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0` (@vjik)
520
- Enh #125: Add error code & show function arguments (@xepozz)
621
- Enh #130: Pass exception message instead of rendered exception to logger in `ErrorHandler` (@olegbaturin)
7-
- Enh #133: Extract response generator from `ErrorCatcher` middleware into separate `ThrowableResponseFactory` class (@olegbaturin)
22+
- Enh #133: Extract response generator from `ErrorCatcher` middleware into separate `ThrowableResponseFactory`
23+
class (@olegbaturin)
24+
- Enh #138, #139: Raise the minimum PHP version to 8.1 and minor refactoring (@vjik)
25+
- Bug #139: Explicitly mark nullable parameters (@vjik)
826

927
## 3.3.0 July 11, 2024
1028

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ The package provides advanced error handling. The features are:
2929

3030
## Requirements
3131

32-
- PHP 8.0 or higher.
32+
- PHP 8.1 or higher.
3333
- `DOM` PHP extension.
34-
- `JSON` PHP extension.
3534
- `mbstring` PHP extension.
3635

3736
## Installation
@@ -123,10 +122,11 @@ For more information about creating your own renders and examples of rendering e
123122

124123
### Using a factory to create a response
125124

126-
`Yiisoft\ErrorHandler\Factory\ThrowableResponseFactory` renders `Throwable` object and produces a response according to the content type provided by the client.
125+
`Yiisoft\ErrorHandler\ThrowableResponseFactory` renders `Throwable` object and produces a response according to the content type provided by the client.
127126

128127
```php
129-
use Yiisoft\ErrorHandler\Factory\ThrowableResponseFactory;
128+
use Yiisoft\ErrorHandler\RendererProvider;
129+
use Yiisoft\ErrorHandler\ThrowableResponseFactory;
130130

131131
/**
132132
* @var \Throwable $throwable
@@ -136,27 +136,27 @@ use Yiisoft\ErrorHandler\Factory\ThrowableResponseFactory;
136136
* @var \Yiisoft\ErrorHandler\ErrorHandler $errorHandler
137137
*/
138138

139-
$throwableResponseFactory = new ThrowableResponseFactory($responseFactory, $errorHandler, $container);
139+
$throwableResponseFactory = new ThrowableResponseFactory(
140+
$responseFactory,
141+
$errorHandler,
142+
new RendererProvider\CompositeRendererProvider(
143+
new RendererProvider\HeadRendererProvider(),
144+
new RendererProvider\ContentTypeRendererProvider($container),
145+
),
146+
);
140147

141148
// Creating an instance of the `Psr\Http\Message\ResponseInterface` with error information.
142149
$response = $throwableResponseFactory->create($throwable, $request);
143150
```
144151

145-
`Yiisoft\ErrorHandler\Factory\ThrowableResponseFactory` chooses how to render an exception based on accept HTTP header.
146-
If it's `text/html` or any unknown content type, it will use the error or exception HTML template to display errors.
147-
For other mime types, the error handler will choose different renderer that is registered within the error catcher.
148-
By default, JSON, XML and plain text are supported. You can change this behavior as follows:
152+
`Yiisoft\ErrorHandler\ThrowableResponseFactory` chooses how to render an exception by renderer provider. Providers
153+
available out of the box:
149154

150-
```php
151-
// Returns a new instance without renderers by the specified content types.
152-
$throwableResponseFactory = $throwableResponseFactory->withoutRenderers('application/xml', 'text/xml');
153-
154-
// Returns a new instance with the specified content type and renderer class.
155-
$throwableResponseFactory = $throwableResponseFactory->withRenderer('my/format', new MyRenderer());
156-
157-
// Returns a new instance with the specified force content type to respond with regardless of request.
158-
$throwableResponseFactory = $throwableResponseFactory->forceContentType('application/json');
159-
```
155+
- `HeadRendererProvider` - renders error into HTTP headers. It is used for HEAD requests.
156+
- `ContentTypeRendererProvider` - renders error based on accept HTTP header. By default, JSON, XML and plain text are
157+
supported.
158+
- `ClosureRendererProvider` - allows you to create your own renderer provider using closures.
159+
- `CompositeRendererProvider` - allows you to combine several renderer providers.
160160

161161
### Using a middleware for catching unhandled errors
162162

composer.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
}
3232
],
3333
"require": {
34-
"php": "^8.0",
34+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
3535
"ext-dom": "*",
36-
"ext-json": "*",
3736
"ext-mbstring": "*",
3837
"alexkart/curl-builder": "^1.0",
3938
"cebe/markdown": "^1.2",
@@ -48,16 +47,16 @@
4847
"yiisoft/injector": "^1.0"
4948
},
5049
"require-dev": {
51-
"httpsoft/http-message": "^1.0.9",
52-
"maglnet/composer-require-checker": "^4.4",
53-
"phpunit/phpunit": "^9.5",
50+
"bamarni/composer-bin-plugin": "^1.8.2",
51+
"httpsoft/http-message": "^1.1.6",
52+
"phpunit/phpunit": "^10.5.45",
5453
"psr/event-dispatcher": "^1.0",
55-
"rector/rector": "^2.0",
56-
"roave/infection-static-analysis-plugin": "^1.16",
57-
"spatie/phpunit-watcher": "^1.23",
58-
"vimeo/psalm": "^4.30|^5.25",
59-
"yiisoft/di": "^1.1",
60-
"yiisoft/test-support": "^3.0"
54+
"rector/rector": "^2.0.11",
55+
"roave/infection-static-analysis-plugin": "^1.35",
56+
"spatie/phpunit-watcher": "^1.24",
57+
"vimeo/psalm": "^5.26.1 || ^6.9.1",
58+
"yiisoft/di": "^1.3",
59+
"yiisoft/test-support": "^3.0.2"
6160
},
6261
"autoload": {
6362
"psr-4": {
@@ -70,6 +69,11 @@
7069
}
7170
},
7271
"extra": {
72+
"bamarni-bin": {
73+
"bin-links": true,
74+
"target-directory": "tools",
75+
"forward-command": true
76+
},
7377
"config-plugin-options": {
7478
"source-directory": "config"
7579
},
@@ -81,8 +85,9 @@
8185
"config": {
8286
"sort-packages": true,
8387
"allow-plugins": {
84-
"infection/extension-installer": true,
85-
"composer/package-versions-deprecated": true
88+
"bamarni/composer-bin-plugin": true,
89+
"composer/package-versions-deprecated": true,
90+
"infection/extension-installer": true
8691
}
8792
},
8893
"scripts": {

phpunit.xml.dist

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit bootstrap="vendor/autoload.php"
4-
colors="true"
5-
verbose="true"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
requireCoverageMetadata="false"
7+
beStrictAboutCoverageMetadata="true"
8+
beStrictAboutOutputDuringTests="true"
9+
executionOrder="random"
610
failOnRisky="true"
711
failOnWarning="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
12+
failOnDeprecation="true"
1113
stopOnFailure="false"
12-
executionOrder="random"
13-
resolveDependencies="true"
14+
colors="true"
15+
displayDetailsOnPhpunitDeprecations="true"
1416
>
1517
<php>
16-
<ini name="error_reporting" value="-1"/>
18+
<ini name="error_reporting" value="-1" />
1719
</php>
1820

1921
<testsuites>
@@ -22,9 +24,9 @@
2224
</testsuite>
2325
</testsuites>
2426

25-
<coverage>
27+
<source>
2628
<include>
27-
<directory>./src</directory>
29+
<directory suffix=".php">./src</directory>
2830
</include>
29-
</coverage>
31+
</source>
3032
</phpunit>

0 commit comments

Comments
 (0)