Skip to content

Commit

Permalink
Merge pull request #334 from lcobucci/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
lcobucci authored Oct 31, 2021
2 parents 46c0cf6 + e8a3f57 commit 27e1bb4
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 77 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "development"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"

Expand Down Expand Up @@ -62,7 +63,7 @@ jobs:
run: "make phpunit"

phpunit-rc:
name: "PHPUnit tests on PHP 8"
name: "PHPUnit tests on nightly"

runs-on: ${{ matrix.operating-system }}

Expand All @@ -71,7 +72,7 @@ jobs:
dependencies:
- "locked"
php-version:
- "8.1"
- "8.2"
operating-system:
- "ubuntu-latest"

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"php": "^8.0",
"ext-json": "*",
"fig/http-message-util": "^1.1",
"lcobucci/content-negotiation-middleware": "^3.0",
"lcobucci/content-negotiation-middleware": "^3.1",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
Expand All @@ -28,7 +28,7 @@
"require-dev": {
"infection/infection": "^0.25",
"laminas/laminas-diactoros": "^2.8",
"lcobucci/coding-standard": "^7.0",
"lcobucci/coding-standard": "^8.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
Expand Down
65 changes: 30 additions & 35 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions src/ErrorConversionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@ final class ErrorConversionMiddleware implements MiddlewareInterface

private const STATUS_URL = 'https://httpstatuses.com/';

private ResponseFactoryInterface $responseFactory;
private DebugInfoStrategy $debugInfoStrategy;
private StatusCodeExtractionStrategy $statusCodeExtractor;

public function __construct(
ResponseFactoryInterface $responseFactory,
DebugInfoStrategy $debugInfoStrategy,
StatusCodeExtractionStrategy $statusCodeExtractor
private ResponseFactoryInterface $responseFactory,
private DebugInfoStrategy $debugInfoStrategy,
private StatusCodeExtractionStrategy $statusCodeExtractor,
) {
$this->responseFactory = $responseFactory;
$this->debugInfoStrategy = $debugInfoStrategy;
$this->statusCodeExtractor = $statusCodeExtractor;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
Expand All @@ -49,7 +42,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return new UnformattedResponse(
$response,
$this->extractData($error, $response),
['error' => $error]
['error' => $error],
);
}
}
Expand All @@ -66,7 +59,7 @@ private function generateResponse(ServerRequestInterface $request, Throwable $er

return $response->withAddedHeader(
'Content-Type',
self::CONTENT_TYPE_CONVERSION[$accept] . '; charset=' . $request->getHeaderLine('Accept-Charset')
self::CONTENT_TYPE_CONVERSION[$accept] . '; charset=' . $request->getHeaderLine('Accept-Charset'),
);
}

Expand Down
5 changes: 1 addition & 4 deletions src/ErrorLoggingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@

final class ErrorLoggingMiddleware implements MiddlewareInterface
{
private LoggerInterface $logger;

public function __construct(LoggerInterface $logger)
public function __construct(private LoggerInterface $logger)
{
$this->logger = $logger;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/StatusCodeExtractionStrategy/ClassMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ final class ClassMap implements StatusCodeExtractionStrategy
Problem\ServiceUnavailable::class => StatusCodeInterface::STATUS_SERVICE_UNAVAILABLE,
];

/** @var array<string, int> */
private array $conversionMap;

/** @param array<string, int> $conversionMap */
public function __construct(array $conversionMap = self::DEFAULT_MAP)
public function __construct(private array $conversionMap = self::DEFAULT_MAP)
{
$this->conversionMap = $conversionMap;
}

public function extractStatusCode(Throwable $error): int
Expand Down
10 changes: 5 additions & 5 deletions tests/DebugInfoStrategy/NoTraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function extractDebugInfoShouldConvertExceptionInfoWithoutTheTrace(): voi
'file' => __FILE__,
'line' => __LINE__ + 2,
],
$strategy->extractDebugInfo(new RuntimeException('Testing', 11))
$strategy->extractDebugInfo(new RuntimeException('Testing', 11)),
);
}

Expand Down Expand Up @@ -77,10 +77,10 @@ public function extractDebugInfoShouldAlsoReturnPreviousExceptions(): void
new InvalidArgumentException(
'Oh no!',
25,
new LogicException('Bummer')
)
)
)
new LogicException('Bummer'),
),
),
),
);
}
}
16 changes: 8 additions & 8 deletions tests/ErrorConversionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function processShouldJustReturnTheResponseWhenEverythingIsAlright(): voi
$middleware = new ErrorConversionMiddleware(
$this->responseFactory,
new NoDebugInfo(),
$this->statusCodeExtractor
$this->statusCodeExtractor,
);

self::assertSame($response, $middleware->process(new ServerRequest(), $handler));
Expand All @@ -75,7 +75,7 @@ public function processShouldJustReturnTheResponseWhenEverythingIsAlright(): voi
public function processShouldConvertTheExceptionIntoAnUnformattedResponseWithTheProblemDetails(
Throwable $error,
int $expectedStatusCode,
array $expectedData
array $expectedData,
): void {
$response = $this->handleProcessWithError(new ServerRequest(), $error);

Expand All @@ -100,7 +100,7 @@ public function possibleConversions(): iterable
yield 'typed exceptions' => [
new SampleProblem\Typed(
'Your current balance is 30, but that costs 50.',
StatusCodeInterface::STATUS_FORBIDDEN
StatusCodeInterface::STATUS_FORBIDDEN,
),
StatusCodeInterface::STATUS_FORBIDDEN,
[
Expand All @@ -113,7 +113,7 @@ public function possibleConversions(): iterable
yield 'titled exceptions' => [
new SampleProblem\Titled(
'Your current balance is 30, but that costs 50.',
StatusCodeInterface::STATUS_FORBIDDEN
StatusCodeInterface::STATUS_FORBIDDEN,
),
StatusCodeInterface::STATUS_FORBIDDEN,
[
Expand All @@ -126,7 +126,7 @@ public function possibleConversions(): iterable
yield 'detailed exceptions' => [
new SampleProblem\Detailed(
'Your current balance is 30, but that costs 50.',
StatusCodeInterface::STATUS_FORBIDDEN
StatusCodeInterface::STATUS_FORBIDDEN,
),
StatusCodeInterface::STATUS_FORBIDDEN,
[
Expand All @@ -141,7 +141,7 @@ public function possibleConversions(): iterable
yield 'typed+titled+detailed exceptions' => [
new SampleProblem\All(
'Your current balance is 30, but that costs 50.',
StatusCodeInterface::STATUS_FORBIDDEN
StatusCodeInterface::STATUS_FORBIDDEN,
),
StatusCodeInterface::STATUS_FORBIDDEN,
[
Expand Down Expand Up @@ -229,12 +229,12 @@ public function processShouldModifyTheContentTypeHeaderForXml(): void
private function handleProcessWithError(
ServerRequestInterface $request,
Throwable $error,
?DebugInfoStrategy $debugInfoStrategy = null
?DebugInfoStrategy $debugInfoStrategy = null,
): ResponseInterface {
$middleware = new ErrorConversionMiddleware(
$this->responseFactory,
$debugInfoStrategy ?? new NoDebugInfo(),
$this->statusCodeExtractor
$this->statusCodeExtractor,
);

$handler = $this->createMock(RequestHandlerInterface::class);
Expand Down
Loading

0 comments on commit 27e1bb4

Please sign in to comment.