Skip to content

Commit

Permalink
Require PHP 8.1+
Browse files Browse the repository at this point in the history
Signed-off-by: Luís Cobucci <[email protected]>
  • Loading branch information
lcobucci committed Aug 9, 2022
1 parent 23708c4 commit 13afa48
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
dependencies:
- "locked"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/composer-json-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
dependencies:
- "highest"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
dependencies:
- "locked"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
- "locked"
- "development"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
dependencies:
- "locked"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"fig/http-message-util": "^1.1",
"psr/http-factory": "^1.0",
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

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

10 changes: 5 additions & 5 deletions src/ContentTypeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ final class ContentTypeMiddleware implements MiddlewareInterface
{
/** @param Formatter[] $formatters */
public function __construct(
private MiddlewareInterface $negotiator,
private array $formatters,
private StreamFactoryInterface $streamFactory,
private readonly MiddlewareInterface $negotiator,
private readonly array $formatters,
private readonly StreamFactoryInterface $streamFactory,
) {
}

Expand Down Expand Up @@ -54,9 +54,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}

$contentType = $this->extractContentType($response->getHeaderLine('Content-Type'));
$formatter = $this->formatters[$contentType] ?? new NotAcceptable();

return $formatter->format($response, $this->streamFactory);
return ($this->formatters[$contentType] ?? new NotAcceptable())
->format($response, $this->streamFactory);
}

private function extractContentType(string $contentType): string
Expand Down
6 changes: 4 additions & 2 deletions src/Formatter/JmsSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

final class JmsSerializer extends ContentOnly
{
public function __construct(private SerializerInterface $serializer, private string $format)
{
public function __construct(
private readonly SerializerInterface $serializer,
private readonly string $format,
) {
}

/** {@inheritdoc} */
Expand Down
2 changes: 1 addition & 1 deletion src/Formatter/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Json extends ContentOnly
{
private const DEFAULT_FLAGS = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_UNESCAPED_SLASHES;

public function __construct(private int $flags = self::DEFAULT_FLAGS)
public function __construct(private readonly int $flags = self::DEFAULT_FLAGS)
{
}

Expand Down
6 changes: 4 additions & 2 deletions src/Formatter/Plates.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ final class Plates extends ContentOnly
{
private const DEFAULT_ATTRIBUTE = 'template';

public function __construct(private Engine $engine, private string $attributeName = self::DEFAULT_ATTRIBUTE)
{
public function __construct(
private readonly Engine $engine,
private readonly string $attributeName = self::DEFAULT_ATTRIBUTE,
) {
}

/** {@inheritdoc} */
Expand Down
4 changes: 2 additions & 2 deletions src/Formatter/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ final class Twig extends ContentOnly
private const DEFAULT_ATTRIBUTE = 'template';

public function __construct(
private Environment $environment,
private string $attributeName = self::DEFAULT_ATTRIBUTE,
private readonly Environment $environment,
private readonly string $attributeName = self::DEFAULT_ATTRIBUTE,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/UnformattedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ final class UnformattedResponse implements ResponseInterface
{
/** @param array<string, mixed> $attributes */
public function __construct(
private ResponseInterface $decoratedResponse,
private mixed $unformattedContent,
private array $attributes = [],
private readonly ResponseInterface $decoratedResponse,
private readonly mixed $unformattedContent,
private readonly array $attributes = [],
) {
}

Expand Down
4 changes: 1 addition & 3 deletions tests/Formatter/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ public function jsonSerialize(): mixed

private function formatContent(mixed $content): string
{
$formatter = new Json();

return $formatter->formatContent($content);
return (new Json())->formatContent($content);
}
}
2 changes: 1 addition & 1 deletion tests/PersonDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

final class PersonDto
{
public function __construct(public int $id, public string $name)
public function __construct(public readonly int $id, public readonly string $name)
{
}
}

0 comments on commit 13afa48

Please sign in to comment.