Skip to content

Commit 34600b1

Browse files
committed
chore: add support for PHP 8.4
BREAKING CHANGE: drop support for PHP < 8.1, requires psr/http-message ^2.0
1 parent b073a1e commit 34600b1

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ jobs:
1616
os:
1717
- ubuntu-latest
1818
php:
19-
- "7.4"
20-
- "8.0"
2119
- "8.1"
2220
- "8.2"
2321
- "8.3"
22+
- "8.4"
2423

2524
steps:
2625
- name: Checkout
@@ -38,7 +37,7 @@ jobs:
3837
echo "::set-output name=dir::$(composer config cache-files-dir)"
3938
4039
- name: Cache composer cache directory
41-
uses: actions/cache@v2
40+
uses: actions/cache@v4
4241
with:
4342
path: ${{ steps.composer-cache.outputs.dir }}
4443
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
55

66
## [Unreleased]
77

8+
### Added
9+
10+
- Add support for PHP 8.4
11+
12+
### Changed
13+
14+
- Drop support for PHP < 8.1
15+
816
## [2.0.1] - 2021-03-14
917

1018
### Fixed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# PHP Middleware Stack
2+
23
[![Build Status](https://github.com/idealo/php-middleware-stack/workflows/CI/badge.svg)](https://github.com/idealo/php-middleware-stack/actions?query=workflow%3Aci)
34
[![Maintainability](https://api.codeclimate.com/v1/badges/254d91c39447f58c7d44/maintainability)](https://codeclimate.com/github/idealo/php-middleware-stack/maintainability)
45
[![Test Coverage](https://api.codeclimate.com/v1/badges/254d91c39447f58c7d44/test_coverage)](https://codeclimate.com/github/idealo/php-middleware-stack/test_coverage)
56
[![Packagist](https://img.shields.io/packagist/v/idealo/php-middleware-stack)](https://packagist.org/packages/idealo/php-middleware-stack)
67

7-
This is an implementation of [PSR-15](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-15-request-handlers.md) using the proposed Interface packages [psr/http-server-middleware](https://github.com/php-fig/http-server-middleware) and [psr/http-server-handler](https://github.com/php-fig/http-server-handler) for PHP7+ runtime environment.
8+
This is an implementation of [PSR-15](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-15-request-handlers.md) using the proposed Interface packages [psr/http-server-middleware](https://github.com/php-fig/http-server-middleware)
9+
and [psr/http-server-handler](https://github.com/php-fig/http-server-handler) for PHP ^8.1 runtime environment.
810

911
It enables a sequential execution of middlewares that use a PSR-7 conform Response/Request implementation.
1012

@@ -14,9 +16,10 @@ It enables a sequential execution of middlewares that use a PSR-7 conform Respon
1416
composer require idealo/php-middleware-stack
1517
```
1618

17-
Note: use Version ^1.0 for PHP < 7.3
19+
Note: use Version ^2.0 for PHP < 8.1
1820

1921
## How to
22+
2023
```php
2124
use Idealo\Middleware\Stack;
2225

@@ -31,14 +34,19 @@ $stackResponse = $stack->handle($request);
3134
```
3235

3336
## Usage
34-
**idealo/php-middleware-stack** provides the ```Idealo\Middleware\Stack``` class. All it has to know in order to be instantiable is:
37+
38+
**idealo/php-middleware-stack** provides the ```Idealo\Middleware\Stack``` class. All it has to know in order to be
39+
instantiable is:
40+
3541
* an instance of ```Psr\Http\Message\ResponseInterface``` as the default response
3642
* and middlewares, that implement the ```Psr\Http\Server\MiddlewareInterface```
3743

3844
To perform a sequential processing of injected middlewares you have to call stack's ```handle``` method with:
45+
3946
* an instance of ```Psr\Http\Message\ServerRequestInterface```.
4047

41-
By default stack's ```handle``` method returns the injected response object. If any middleware decides to answer on it's own, than the response object of this certain middleware is returned.
48+
By default stack's ```handle``` method returns the injected response object. If any middleware decides to answer on it's
49+
own, than the response object of this certain middleware is returned.
4250

4351
Stack implements ```Psr\Http\Server\RequestHandlerInterface```.
4452

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
}
2424
],
2525
"require": {
26-
"php": ">=7.3",
27-
"psr/http-message": "^1.0",
26+
"php": "^8.1",
27+
"psr/http-message": "^2.0",
2828
"psr/http-server-middleware": "^1.0",
2929
"psr/http-server-handler": "^1.0"
3030
},
3131
"require-dev": {
32-
"phpunit/phpunit": "^9.5"
32+
"phpunit/phpunit": "^11.4"
3333
},
3434
"autoload": {
3535
"psr-4": {

src/Stack.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44

55
namespace Idealo\Middleware;
66

7-
use Psr\Http\Server\RequestHandlerInterface;
8-
use Psr\Http\Server\MiddlewareInterface;
97
use Psr\Http\Message\ResponseInterface;
108
use Psr\Http\Message\ServerRequestInterface;
9+
use Psr\Http\Server\MiddlewareInterface;
10+
use Psr\Http\Server\RequestHandlerInterface;
1111

1212
class Stack implements RequestHandlerInterface
1313
{
1414
/**
1515
* @var MiddlewareInterface[]
1616
*/
17-
protected $middlewares = [];
17+
protected array $middlewares = [];
1818

19-
/**
20-
* @var ResponseInterface
21-
*/
22-
protected $defaultResponse;
19+
protected ResponseInterface $defaultResponse;
2320

2421
public function __construct(ResponseInterface $response, MiddlewareInterface ...$middlewares)
2522
{

tests/StackTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testServerMiddlewareHandlingOrder()
106106
/**
107107
* @return MockObject|ResponseInterface
108108
*/
109-
private function getResponseMock()
109+
private function getResponseMock(): MockObject|ResponseInterface
110110
{
111111
return $this->getMockBuilder(ResponseInterface::class)
112112
->getMock();
@@ -115,7 +115,7 @@ private function getResponseMock()
115115
/**
116116
* @return MockObject|MiddlewareInterface
117117
*/
118-
private function getMiddlewareMock()
118+
private function getMiddlewareMock(): MiddlewareInterface|MockObject
119119
{
120120
return $this->getMockBuilder(MiddlewareInterface::class)
121121
->onlyMethods([
@@ -127,7 +127,7 @@ private function getMiddlewareMock()
127127
/**
128128
* @return MockObject|ServerRequestInterface
129129
*/
130-
private function getServerRequestMock()
130+
private function getServerRequestMock(): MockObject|ServerRequestInterface
131131
{
132132
return $this->getMockBuilder(ServerRequestInterface::class)
133133
->onlyMethods([

0 commit comments

Comments
 (0)