Skip to content

Commit 722e463

Browse files
authored
Merge pull request #14 from middlewares/issue/13
Issue #13 + dev improvements
2 parents f551894 + 5d20543 commit 722e463

File tree

10 files changed

+61
-49
lines changed

10 files changed

+61
-49
lines changed

.github/workflows/main.yaml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: "testing"
22

33
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
88

99
jobs:
1010
qa:
@@ -13,19 +13,19 @@ jobs:
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717

1818
- name: Validate composer.json and composer.lock
1919
run: composer validate
2020

2121
- name: Cache Composer packages
2222
id: composer-cache
23-
uses: actions/cache@v2
23+
uses: actions/cache@v4
2424
with:
25-
path: vendor
26-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
27-
restore-keys: |
28-
${{ runner.os }}-php-
25+
path: vendor
26+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
27+
restore-keys: |
28+
${{ runner.os }}-php-
2929
3030
- name: Install dependencies
3131
if: steps.composer-cache.outputs.cache-hit != 'true'
@@ -40,25 +40,27 @@ jobs:
4040

4141
strategy:
4242
matrix:
43-
php:
44-
- 7.2
45-
- 7.3
46-
- 7.4
47-
- 8.0
48-
- 8.1
49-
- 8.2
43+
php:
44+
- 7.2
45+
- 7.3
46+
- 7.4
47+
- 8.0
48+
- 8.1
49+
- 8.2
50+
- 8.3
51+
- 8.4
5052

5153
steps:
5254
- name: Checkout
53-
uses: actions/checkout@v2
55+
uses: actions/checkout@v4
5456

5557
- name: Install PHP
5658
uses: shivammathur/setup-php@v2
5759
with:
5860
php-version: ${{ matrix.php }}
5961

6062
- name: Cache PHP dependencies
61-
uses: actions/cache@v2
63+
uses: actions/cache@v4
6264
with:
6365
path: vendor
6466
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
@@ -69,6 +71,3 @@ jobs:
6971

7072
- name: Tests
7173
run: composer test
72-
73-
- name: Tests coverage
74-
run: composer coverage

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
.idea
12
vendor
23
composer.lock
34
coverage
45
*.cache
6+
kit
File renamed without changes.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [2.0.3] - 2024-03-21
8+
### Added / Fixed
9+
- Support for PHP 8.3 and PHP 8.4 (removed deprecation notices)
10+
711
## [2.0.3] - 2024-03-21
812
### Fixed
913
- Allow middlewares/utils 4.0
@@ -86,6 +90,7 @@ First version
8690
[#7]: https://github.com/middlewares/whoops/issues/7
8791
[#11]: https://github.com/middlewares/whoops/issues/11
8892

93+
[2.0.3]: https://github.com/middlewares/whoops/compare/v2.0.3...v2.0.4
8994
[2.0.3]: https://github.com/middlewares/whoops/compare/v2.0.2...v2.0.3
9095
[2.0.2]: https://github.com/middlewares/whoops/compare/v2.0.1...v2.0.2
9196
[2.0.1]: https://github.com/middlewares/whoops/compare/v2.0.0...v2.0.1

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019
3+
Copyright (c) 2019-2025
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@
1818
},
1919
"require": {
2020
"php": "^7.2 || ^8.0",
21-
"filp/whoops": "^2.5",
21+
"filp/whoops": "^2.17",
2222
"middlewares/utils": "^3.0 || ^4.0",
2323
"psr/http-server-middleware": "^1.0",
2424
"psr/container": "^1.0 || ^2.0"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^8|^9",
28-
"laminas/laminas-diactoros": "^2.2",
29-
"friendsofphp/php-cs-fixer": "^2.0",
30-
"squizlabs/php_codesniffer": "^3.0",
31-
"oscarotero/php-cs-fixer-config": "^1.0",
32-
"eloquent/phony-phpunit": "^5.0 || ^7.0",
33-
"phpstan/phpstan": "^0.12"
27+
"phpunit/phpunit": "^8 || ^9",
28+
"laminas/laminas-diactoros": "^2 || ^3",
29+
"friendsofphp/php-cs-fixer": "^3",
30+
"squizlabs/php_codesniffer": "^3.11",
31+
"oscarotero/php-cs-fixer-config": "^1 || ^2",
32+
"phpstan/phpstan": "^1 || ^2"
3433
},
3534
"autoload": {
3635
"psr-4": {
@@ -44,7 +43,7 @@
4443
},
4544
"scripts": {
4645
"cs": "phpcs",
47-
"cs-fix": "php-cs-fixer fix",
46+
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix",
4847
"phpstan": "phpstan analyse",
4948
"test": "phpunit",
5049
"coverage": "phpunit --coverage-text",

phpstan.neon.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src
5+
- tests

src/Whoops.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class Whoops implements MiddlewareInterface
4242
* Set the whoops instance.
4343
*/
4444
public function __construct(
45-
Run $whoops = null,
46-
ResponseFactoryInterface $responseFactory = null
45+
?Run $whoops = null,
46+
?ResponseFactoryInterface $responseFactory = null
4747
) {
4848
$this->whoops = $whoops;
4949
$this->responseFactory = $responseFactory ?: Factory::getResponseFactory();

tests/HandlerTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace Middlewares\Tests;
55

6-
use Eloquent\Phony\Phpunit\Phony;
76
use Middlewares\Utils\Dispatcher;
87
use Middlewares\Utils\Factory;
98
use Middlewares\Whoops;
@@ -12,15 +11,17 @@
1211

1312
class HandlerTest extends TestCase
1413
{
15-
private static function getContainer()
14+
private static function getContainer(): WhoopsHandlerContainer
1615
{
17-
$container = Phony::partialMock(WhoopsHandlerContainer::class)->get();
18-
Phony::onStatic($container)->isCli->returns(false);
19-
20-
return $container;
16+
return new class() extends WhoopsHandlerContainer {
17+
protected static function isCli(): bool
18+
{
19+
return false;
20+
}
21+
};
2122
}
2223

23-
public function testJson()
24+
public function testJson(): void
2425
{
2526
$request = Factory::createServerRequest('GET', '/')->withHeader('Accept', 'application/json');
2627

@@ -35,7 +36,7 @@ function () {
3536
$this->assertEquals('application/json', $response->getHeaderLine('Content-Type'));
3637
}
3738

38-
public function testXml()
39+
public function testXml(): void
3940
{
4041
$request = Factory::createServerRequest('GET', '/')->withHeader('Accept', 'text/xml');
4142

@@ -50,7 +51,7 @@ function () {
5051
$this->assertEquals('text/xml', $response->getHeaderLine('Content-Type'));
5152
}
5253

53-
public function testPlain()
54+
public function testPlain(): void
5455
{
5556
$request = Factory::createServerRequest('GET', '/')->withHeader('Accept', 'text/plain');
5657

@@ -65,7 +66,7 @@ function () {
6566
$this->assertEquals('text/plain', $response->getHeaderLine('Content-Type'));
6667
}
6768

68-
public function testHtml()
69+
public function testHtml(): void
6970
{
7071
$request = Factory::createServerRequest('GET', '/')->withHeader('Accept', 'text/html');
7172

@@ -80,7 +81,7 @@ function () {
8081
$this->assertEquals('text/html', $response->getHeaderLine('Content-Type'));
8182
}
8283

83-
public function testDefault()
84+
public function testDefault(): void
8485
{
8586
$request = Factory::createServerRequest('GET', '/')->withHeader('Accept', 'foo/bar');
8687

@@ -95,7 +96,7 @@ function () {
9596
$this->assertEquals('text/html', $response->getHeaderLine('Content-Type'));
9697
}
9798

98-
public function testEmptyAccept()
99+
public function testEmptyAccept(): void
99100
{
100101
$response = Dispatcher::run([
101102
(new Whoops())->handlerContainer(self::getContainer()),

tests/WhoopsTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class WhoopsTest extends TestCase
1111
{
12-
public function testError()
12+
public function testError(): void
1313
{
1414
$response = Dispatcher::run([
1515
new Whoops(),
@@ -23,13 +23,14 @@ function () {
2323
$this->assertNotFalse(strpos((string) $response->getBody(), 'Error Processing Request'));
2424
}
2525

26-
public function testStandardError()
26+
public function testStandardError(): void
2727
{
2828
error_reporting(E_ALL);
2929

3030
$response = Dispatcher::run([
3131
new Whoops(),
3232
function () {
33+
/** @phpstan-ignore variable.undefined */
3334
$a = $b; //undefined variable
3435
},
3536
]);
@@ -39,7 +40,7 @@ function () {
3940
$this->assertNotFalse(strpos((string) $response->getBody(), 'Undefined variable'));
4041
}
4142

42-
public function testNotError()
43+
public function testNotError(): void
4344
{
4445
$response = Dispatcher::run([
4546
new Whoops(),

0 commit comments

Comments
 (0)