Skip to content

Commit f127cbf

Browse files
committed
readonly properties
1 parent 2e78791 commit f127cbf

14 files changed

+35
-32
lines changed

src/Application.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
final class Application implements RequestHandlerInterface
1717
{
18-
private PipeMiddleware $pipeMiddleware;
18+
private readonly PipeMiddleware $pipeMiddleware;
1919

2020
/**
2121
* @param array<MiddlewareInterface> $middlewares
2222
*/
2323
public function __construct(
2424
array $middlewares,
25-
private RequestHandlerInterface $routeRequestHandler = new RouteRequestHandler(),
26-
private EmitterInterface $emitter = new Emitter()
25+
private readonly RequestHandlerInterface $routeRequestHandler = new RouteRequestHandler(),
26+
private readonly EmitterInterface $emitter = new Emitter()
2727
) {
2828
$this->pipeMiddleware = new PipeMiddleware($middlewares);
2929
}

src/Middleware/ExceptionMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ final class ExceptionMiddleware implements MiddlewareInterface
163163
</html>
164164
EOT;
165165

166-
private LoggerInterface $logger;
166+
private readonly LoggerInterface $logger;
167167

168168
public function __construct(
169-
private ResponseFactoryInterface $responseFactory,
170-
private bool $debug = false,
169+
private readonly ResponseFactoryInterface $responseFactory,
170+
private readonly bool $debug = false,
171171
?LoggerInterface $logger = null
172172
) {
173173
$this->logger = $logger ?? new NullLogger();

src/Middleware/LazyMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
final class LazyMiddleware implements MiddlewareInterface
1414
{
15-
public function __construct(private ContainerInterface $container, private string $id) {}
15+
public function __construct(private readonly ContainerInterface $container, private readonly string $id) {}
1616

1717
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
1818
{

src/Middleware/MiddlewareRequestHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
final class MiddlewareRequestHandler implements RequestHandlerInterface
1313
{
14-
public function __construct(private MiddlewareInterface $middleware, private RequestHandlerInterface $handler) {}
14+
public function __construct(private readonly MiddlewareInterface $middleware, private readonly RequestHandlerInterface $handler) {}
1515

1616
public function handle(ServerRequestInterface $request): ResponseInterface
1717
{

src/Middleware/PipeMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class PipeMiddleware implements MiddlewareInterface
1414
/**
1515
* @var array<MiddlewareInterface>
1616
*/
17-
private array $middlewares;
17+
private readonly array $middlewares;
1818

1919
/**
2020
* @param array<MiddlewareInterface> $middlewares

src/Middleware/RouteMatcherMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
final class RouteMatcherMiddleware implements MiddlewareInterface
1414
{
15-
public function __construct(private RouteMatcherInterface $routeMatcher) {}
15+
public function __construct(private readonly RouteMatcherInterface $routeMatcher) {}
1616

1717
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
1818
{

src/Middleware/SlimCallbackMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class SlimCallbackMiddleware implements MiddlewareInterface
1919
*/
2020
private $slimCallable;
2121

22-
public function __construct(callable $slimCallable, private ResponseFactoryInterface $responseFactory)
22+
public function __construct(callable $slimCallable, private readonly ResponseFactoryInterface $responseFactory)
2323
{
2424
$this->slimCallable = $slimCallable;
2525
}

src/Middleware/SlimLazyMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
final class SlimLazyMiddleware implements MiddlewareInterface
1515
{
1616
public function __construct(
17-
private ContainerInterface $container,
18-
private string $id,
19-
private ResponseFactoryInterface $responseFactory
17+
private readonly ContainerInterface $container,
18+
private readonly string $id,
19+
private readonly ResponseFactoryInterface $responseFactory
2020
) {}
2121

2222
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface

src/RequestHandler/LazyRequestHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
final class LazyRequestHandler implements RequestHandlerInterface
1313
{
14-
public function __construct(private ContainerInterface $container, private string $id) {}
14+
public function __construct(private readonly ContainerInterface $container, private readonly string $id) {}
1515

1616
public function handle(ServerRequestInterface $request): ResponseInterface
1717
{

src/RequestHandler/SlimCallbackRequestHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class SlimCallbackRequestHandler implements RequestHandlerInterface
1818
*/
1919
private $slimCallable;
2020

21-
public function __construct(callable $slimCallable, private ResponseFactoryInterface $responseFactory)
21+
public function __construct(callable $slimCallable, private readonly ResponseFactoryInterface $responseFactory)
2222
{
2323
$this->slimCallable = $slimCallable;
2424
}

0 commit comments

Comments
 (0)