Skip to content

Commit

Permalink
bump minimum PHP version to 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
1ma committed Jun 23, 2023
1 parent dbe4572 commit af6402f
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
name: Run tests
runs-on: ubuntu-latest
container: 1maa/php-dev:8.1
container: 1maa/php-dev:8.2
steps:
- name: Checkout
uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "library",
"license": "MIT",
"require": {
"php": "~8.1.0 || ~8.2.0",
"php": "~8.2.0",
"nikic/fast-route": "^1.3",
"nyholm/psr7-server": "^1.0",
"psr/container": "^2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/Handlers/StaticResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Psr\Http\Message;
use Psr\Http\Server;

final class StaticResponse implements Server\RequestHandlerInterface
final readonly class StaticResponse implements Server\RequestHandlerInterface
{
private readonly Message\ResponseInterface $response;
private Message\ResponseInterface $response;

public function __construct(Message\ResponseInterface $response)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Internal/ExecutionStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
/**
* @internal
*/
final class ExecutionStack implements Server\RequestHandlerInterface
final readonly class ExecutionStack implements Server\RequestHandlerInterface
{
private readonly Server\MiddlewareInterface $middleware;
private readonly Server\RequestHandlerInterface $next;
private Server\MiddlewareInterface $middleware;
private Server\RequestHandlerInterface $next;

public static function compose(Server\RequestHandlerInterface $core, Server\MiddlewareInterface ...$layers): Server\RequestHandlerInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/RequestHandlerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
/**
* @internal
*/
final class RequestHandlerResolver
final readonly class RequestHandlerResolver
{
private readonly FastRoute\Dispatcher $router;
private FastRoute\Dispatcher $router;

public function __construct(FastRoute\DataGenerator $routeCollection)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Jelly.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use function implode;
use function sprintf;

final class Jelly implements Server\RequestHandlerInterface
final readonly class Jelly implements Server\RequestHandlerInterface
{
/**
* The default behaviour is emitting the response in chunks of at most 8 MiB at a time.
Expand All @@ -31,9 +31,9 @@ final class Jelly implements Server\RequestHandlerInterface
*/
private const DEFAULT_CHUNK_SIZE = 8 * (1024 ** 2);

private readonly ContainerInterface $container;
private readonly Internal\MiddlewareChainResolver $chainResolver;
private readonly Internal\RouteCollection $routes;
private ContainerInterface $container;
private Internal\MiddlewareChainResolver $chainResolver;
private Internal\RouteCollection $routes;

/**
* @throws LogicException If the container is missing any of the mandatory services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
* A reusable middleware for stopping the propagation of uncontrolled
* exceptions and optionally send their stack traces in the HTTP response.
*/
final class CrashFailSafe implements Server\MiddlewareInterface
final readonly class CrashFailsafe implements Server\MiddlewareInterface
{
private readonly Message\ResponseInterface $baseResponse;
private readonly Message\StreamFactoryInterface $streamFactory;
private readonly bool $hide;
private Message\ResponseInterface $staticResponse;
private Message\ResponseFactoryInterface $responseFactory;
private bool $hide;

public function __construct(
Message\ResponseInterface $baseResponse,
Message\StreamFactoryInterface $streamFactory,
bool $hide = true
Message\ResponseInterface $staticResponse,
Message\ResponseFactoryInterface $responseFactory,
bool $hide = true
)
{
$this->baseResponse = $baseResponse;
$this->streamFactory = $streamFactory;
$this->staticResponse = $staticResponse;
$this->responseFactory = $responseFactory;
$this->hide = $hide;
}

Expand All @@ -38,10 +38,10 @@ public function process(Message\ServerRequestInterface $request, Server\RequestH
error_log((string)$t);

return $this->hide ?
$this->baseResponse :
$this->baseResponse
$this->staticResponse :
$this->responseFactory->createResponse(500)
->withHeader('Content-Type', 'text/plain')
->withBody($this->streamFactory->createStream((string)$t));
->withBody($this->responseFactory->createStream((string)$t));
}
}
}
4 changes: 2 additions & 2 deletions src/Middlewares/SecurityHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* @see https://www.owasp.org/index.php/REST_Security_Cheat_Sheet
* @see https://paramdeo.com/blog/opting-your-website-out-of-googles-floc-network
*/
final class SecurityHeaders implements Server\MiddlewareInterface
final readonly class SecurityHeaders implements Server\MiddlewareInterface
{
private readonly int $maxAge;
private int $maxAge;

public function __construct(int $maxAge = 30)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Middlewares/ServerCloak.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* the response and overwrites Server with the value given
* at construction time.
*/
final class ServerCloak implements Server\MiddlewareInterface
final readonly class ServerCloak implements Server\MiddlewareInterface
{
private readonly string $serverName;
private string $serverName;

public function __construct(string $serverName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace Jelly\Tests\Unit\Middlewares;

use Jelly\Handlers\StaticResponse;
use Jelly\Middlewares\CrashFailSafe;
use Jelly\Middlewares\CrashFailsafe;
use Jelly\Tests\Fixtures\BrokenHandler;
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7\Response;
use Nyholm\Psr7\ServerRequest;
use PHPUnit\Framework\TestCase;

final class CrashFailSafeTest extends TestCase
final class CrashFailsafeTest extends TestCase
{
private string $errorLog;

Expand All @@ -28,7 +28,7 @@ protected function tearDown(): void

public function testSuccessfulRun(): void
{
$sut = new CrashFailSafe(new Response(500), new Psr17Factory(), true);
$sut = new CrashFailsafe(new Response(500), new Psr17Factory(), true);

$response = $sut->process(new ServerRequest('GET', '/hello'), new StaticResponse(new Response(204)));

Expand All @@ -37,7 +37,7 @@ public function testSuccessfulRun(): void

public function testExceptionInProdMode(): void
{
$sut = new CrashFailSafe(new Response(500), new Psr17Factory(), true);
$sut = new CrashFailsafe(new Response(500), new Psr17Factory(), true);

$response = $sut->process(new ServerRequest('GET', '/hello'), new BrokenHandler());

Expand All @@ -48,7 +48,7 @@ public function testExceptionInProdMode(): void

public function testExceptionInDevelopmentMode(): void
{
$sut = new CrashFailSafe(new Response(500), new Psr17Factory(), false);
$sut = new CrashFailsafe(new Response(500), new Psr17Factory(), false);

$response = $sut->process(new ServerRequest('GET', '/hello'), $handler = new BrokenHandler());

Expand Down

0 comments on commit af6402f

Please sign in to comment.