Skip to content

Commit a80e629

Browse files
authored
Merge pull request #95 from yiisoft/remove-php80
Raise minimum PHP version to `^8.1`
2 parents a3d584a + bda7e86 commit a80e629

14 files changed

+32
-28
lines changed

.github/workflows/bc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
os: >-
1212
['ubuntu-latest']
1313
php: >-
14-
['8.0']
14+
['8.1']

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
os: >-
2929
['ubuntu-latest', 'windows-latest']
3030
php: >-
31-
['8.0', '8.1']
31+
['8.1', '8.2', '8.3']

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

+1-1
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/static.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
os: >-
2929
['ubuntu-latest']
3030
php: >-
31-
['8.0', '8.1']
31+
['8.1', '8.2', '8.3']

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 5.2.1 under development
44

5-
- no changes in this release.
5+
- Enh #95: Raise minimum PHP version to `^8.1` and make all possible properties readonly (@xepozz)
66

77
## 5.2.0 September 25, 2023
88

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ request instance, dispatcher executes it and produces a response instance.
2121

2222
## Requirements
2323

24-
- PHP 8.0 or higher.
24+
- PHP 8.1 or higher.
2525

2626
## Installation
2727

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"source": "https://github.com/yiisoft/middleware-dispatcher"
1818
},
1919
"require": {
20-
"php": "^8.0",
20+
"php": "^8.1",
2121
"psr/container": "^1.0|^2.0",
2222
"psr/event-dispatcher": "^1.0",
2323
"psr/http-message": "^1.0|^2.0",
@@ -34,7 +34,7 @@
3434
"rector/rector": "^1.0.0",
3535
"roave/infection-static-analysis-plugin": "^1.18",
3636
"spatie/phpunit-watcher": "^1.23",
37-
"vimeo/psalm": "^4.30|^5.3",
37+
"vimeo/psalm": "^5.3",
3838
"yiisoft/test-support": "^1.3"
3939
},
4040
"autoload": {

rector.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
66
use Rector\Config\RectorConfig;
77
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
8+
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
89
use Rector\Set\ValueObject\LevelSetList;
910

1011
return static function (RectorConfig $rectorConfig): void {
@@ -18,10 +19,13 @@
1819

1920
// define sets of rules
2021
$rectorConfig->sets([
21-
LevelSetList::UP_TO_PHP_80,
22+
LevelSetList::UP_TO_PHP_81,
2223
]);
2324

2425
$rectorConfig->skip([
2526
ClassPropertyAssignToConstructorPromotionRector::class,
27+
FirstClassCallableRector::class => [
28+
__DIR__ . '/tests/*',
29+
],
2630
]);
2731
};

src/CompositeParametersResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class CompositeParametersResolver implements ParametersResolverInterface
1313
/**
1414
* @var ParametersResolverInterface[]
1515
*/
16-
private array $resolvers;
16+
private readonly array $resolvers;
1717

1818
public function __construct(ParametersResolverInterface ...$resolvers)
1919
{

src/Event/AfterMiddleware.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ final class AfterMiddleware
1717
* @param ResponseInterface|null $response Response generated by middleware or null in case there was an error.
1818
*/
1919
public function __construct(
20-
private MiddlewareInterface $middleware,
21-
private ?ResponseInterface $response
20+
private readonly MiddlewareInterface $middleware,
21+
private readonly ?ResponseInterface $response
2222
) {
2323
}
2424

src/Event/BeforeMiddleware.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ final class BeforeMiddleware
1717
* @param ServerRequestInterface $request Request to be passed to the middleware.
1818
*/
1919
public function __construct(
20-
private MiddlewareInterface $middleware,
21-
private ServerRequestInterface $request
20+
private readonly MiddlewareInterface $middleware,
21+
private readonly ServerRequestInterface $request
2222
) {
2323
}
2424

src/InvalidMiddlewareDefinitionException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
final class InvalidMiddlewareDefinitionException extends InvalidArgumentException implements FriendlyExceptionInterface
2424
{
25-
private string $definitionString;
25+
private readonly string $definitionString;
2626

2727
public function __construct(
2828
private mixed $definition

src/MiddlewareFactory.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ final class MiddlewareFactory
3333
* @param ContainerInterface $container Container to use for resolving definitions.
3434
*/
3535
public function __construct(
36-
private ContainerInterface $container,
37-
private ?ParametersResolverInterface $parametersResolver = null
36+
private readonly ContainerInterface $container,
37+
private readonly ?ParametersResolverInterface $parametersResolver = null
3838
) {
3939
}
4040

@@ -183,8 +183,8 @@ private function createCallableWrapper(callable $callback): MiddlewareInterface
183183

184184
public function __construct(
185185
callable $callback,
186-
private ContainerInterface $container,
187-
private ?ParametersResolverInterface $parametersResolver
186+
private readonly ContainerInterface $container,
187+
private readonly ?ParametersResolverInterface $parametersResolver
188188
) {
189189
$this->callback = $callback;
190190
$callback = Closure::fromCallable($callback);
@@ -240,12 +240,12 @@ private function createActionWrapper(string $class, string $method): MiddlewareI
240240
private array $actionParameters = [];
241241

242242
public function __construct(
243-
private ContainerInterface $container,
244-
private ?ParametersResolverInterface $parametersResolver,
243+
private readonly ContainerInterface $container,
244+
private readonly ?ParametersResolverInterface $parametersResolver,
245245
/** @var class-string */
246-
private string $class,
246+
private readonly string $class,
247247
/** @var non-empty-string */
248-
private string $method
248+
private readonly string $method
249249
) {
250250
$actionParameters = (new ReflectionClass($this->class))->getMethod($this->method)->getParameters();
251251
foreach ($actionParameters as $parameter) {

src/MiddlewareStack.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ final class MiddlewareStack implements RequestHandlerInterface
3131
* middleware events.
3232
*/
3333
public function __construct(
34-
private array $middlewares,
34+
private readonly array $middlewares,
3535
private RequestHandlerInterface $fallbackHandler,
36-
private ?EventDispatcherInterface $eventDispatcher = null
36+
private readonly ?EventDispatcherInterface $eventDispatcher = null
3737
) {
3838
if ($middlewares === []) {
3939
throw new RuntimeException('Stack is empty.');
@@ -69,13 +69,13 @@ private function build(): void
6969
private function wrap(Closure $middlewareFactory, RequestHandlerInterface $handler): RequestHandlerInterface
7070
{
7171
return new class ($middlewareFactory, $handler, $this->eventDispatcher) implements RequestHandlerInterface {
72-
private Closure $middlewareFactory;
72+
private readonly Closure $middlewareFactory;
7373
private ?MiddlewareInterface $middleware = null;
7474

7575
public function __construct(
7676
Closure $middlewareFactory,
77-
private RequestHandlerInterface $handler,
78-
private ?EventDispatcherInterface $eventDispatcher
77+
private readonly RequestHandlerInterface $handler,
78+
private readonly ?EventDispatcherInterface $eventDispatcher
7979
) {
8080
$this->middlewareFactory = $middlewareFactory;
8181
}

0 commit comments

Comments
 (0)