Skip to content

Commit

Permalink
minor #2169 [CI] Add tests on PHP8.4 (smnandre)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.x branch.

Discussion
----------

[CI] Add tests on PHP8.4

Replaces #2078

Commits
-------

8510b65 [CI] Add tests on PHP8.4
  • Loading branch information
smnandre committed Sep 15, 2024
2 parents f719d65 + 8510b65 commit 7c244fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.3']
php-version: ['8.1', '8.3', '8.4']
include:
- php-version: '8.1'
dependency-version: 'lowest'
- php-version: '8.3'
dependency-version: 'highest'
- php-version: '8.4'
dependency-version: 'highest'
component: ${{ fromJson(needs.tests-php-components.outputs.components )}}
exclude:
- component: Map # does not support PHP 8.1
Expand Down Expand Up @@ -141,5 +143,5 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --immutable
- run: yarn playwright install
- run: yarn playwright install
- run: yarn test
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ public function __construct(private ManagerRegistry $doctrine)
{
}

public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
{
[, $id] = \explode(':', $data);
[, $id] = explode(':', $data);

return $this->doctrine->getRepository(Entity2::class)->find($id);
}

public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
{
return Entity2::class === $type;
}

public function normalize(mixed $object, string $format = null, array $context = []): float|array|\ArrayObject|bool|int|string|null
public function normalize(mixed $object, ?string $format = null, array $context = []): float|array|\ArrayObject|bool|int|string|null
{
return 'entity2:'.$object->id;
}

public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $data instanceof Entity2;
}
Expand Down
14 changes: 7 additions & 7 deletions src/LiveComponent/tests/Fixtures/Serializer/MoneyNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@

final class MoneyNormalizer implements NormalizerInterface, DenormalizerInterface
{
public function denormalize(mixed $data, string $type, string $format = null, array $context = []): Money
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): Money
{
return new Money(...\explode('|', $data));
return new Money(...explode('|', $data));
}

public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
{
return Money::class === $type;
}

public function normalize(mixed $object, string $format = null, array $context = []): float|array|\ArrayObject|bool|int|string|null
public function normalize(mixed $object, ?string $format = null, array $context = []): float|array|\ArrayObject|bool|int|string|null
{
return \implode('|', [$object->amount, $object->currency]);
return implode('|', [$object->amount, $object->currency]);
}

public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $data instanceof Money;
}

public function getSupportedTypes(string $format = null): array
public function getSupportedTypes(?string $format = null): array
{
return [Money::class => true];
}
Expand Down

0 comments on commit 7c244fb

Please sign in to comment.