Skip to content

Commit

Permalink
Support Sf 7+ & make Symfony 6.4 a requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek- committed Aug 5, 2024
1 parent 714f278 commit b1cf753
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Versions
|---------|--------------|---------------|-----------------|-------------|---------------------------------|
| 1.x | Unmaintained | [v1][v1-doc] | >= 3.3 && <5 | >= 7.1 | |
| 2.x | Maintained | [v2][v2-doc] | >= 4.3 | >= 7.4 | |
| 3.x | Latest | [v3][v3-doc] | >= 5.4 | >= 8.1 | See [UPGRADE](v3-upgrade) guide |
| 3.x | Latest | [v3][v3-doc] | >= 6.4 | >= 8.1 | See [UPGRADE](v3-upgrade) guide |

[v1-doc]: https://github.com/swagindustries/doctrine-domain-events/tree/v1.5.2/docs
[v2-doc]: https://github.com/swagindustries/doctrine-domain-events/tree/v2.3.3/docs
Expand Down
14 changes: 5 additions & 9 deletions Tests/Symfony/Serializer/DomainDenormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;

class DomainDenormalizerTest extends TestCase
{
use ProphecyTrait;

/**
* @var ObjectNormalizer
* @var ObjectNormalizer|ObjectProphecy
*/
private $decorated;

Expand All @@ -28,7 +30,8 @@ class DomainDenormalizerTest extends TestCase

public function setUp(): void
{
$this->decorated = $this->prophesize(ObjectNormalizer::class);
$this->decorated = $this->prophesize(NormalizerInterface::class);
$this->decorated->willImplement(DenormalizerInterface::class);
$this->dispatcher = new DomainEventDispatcher();
}

Expand Down Expand Up @@ -66,11 +69,4 @@ public function testDenormalize()
$denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher);
$denormalizer->denormalize([], FakeModel::class, null, []);
}

public function testItIsAnInstanceOfCacheableSupportsMethodInterface()
{
$denormalizer = new DomainDenormalizer($this->decorated->reveal(), $this->dispatcher);
$this->assertInstanceOf(CacheableSupportsMethodInterface::class, $denormalizer);
$this->assertTrue($denormalizer->hasCacheableSupportsMethod());
}
}
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"require": {
"php": ">=8.1",
"symfony/event-dispatcher": "^5.4|^6.0|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0",
"doctrine/doctrine-bundle": "^1.8|^2.0",
"doctrine/orm": "^2.18.3|^3.0"
},
Expand All @@ -18,16 +18,16 @@
"phpunit/phpunit": "^9.5 || ^10",
"doctrine/orm": "^2.18.3",
"friendsofphp/php-cs-fixer": "^3.49.0",
"symfony/framework-bundle": "^5.0 || ^6.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"phpspec/prophecy-phpunit": "^2.0.1",
"monolog/monolog": "^2.8.0 || ^3.2.0",
"symfony/var-dumper": "^5.0 || ^6.0",
"symfony/serializer": "^5.0 || ^6.0",
"symfony/asset": "^5.0 || ^6.0",
"symfony/form": "^5.0 || ^6.0",
"symfony/property-access": "^5.0 || ^6.0",
"symfony/var-dumper": "^6.4 || ^7.0",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/asset": "^6.4 || ^7.0",
"symfony/form": "^6.4 || ^7.0",
"symfony/property-access": "^6.4 || ^7.0",
"symfony/debug-pack": "^1.0",
"symfony/yaml": "^5.0 || ^6.0"
"symfony/yaml": "^6.4 || ^7.0"
},
"conflict": {
"doctrine/orm": "<2.6.3"
Expand Down
14 changes: 5 additions & 9 deletions src/Integration/Symfony/Serializer/DomainDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Biig\Component\Domain\Event\DomainEventDispatcherInterface;
use Biig\Component\Domain\Model\ModelInterface;
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
Expand All @@ -14,7 +13,7 @@
/**
* Class DomainDenormalizer.
*/
final class DomainDenormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
final class DomainDenormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
{
/**
* @var ObjectNormalizer
Expand All @@ -32,7 +31,7 @@ public function __construct(NormalizerInterface $decorated, DomainEventDispatche
$this->dispatcher = $dispatcher;
}

public function denormalize($data, $class, $format = null, array $context = [])
public function denormalize($data, $class, $format = null, array $context = []): mixed
{
$domain = $this->decorated->denormalize($data, $class, $format, $context);

Expand All @@ -48,10 +47,7 @@ public function supportsDenormalization($data, $type, $format = null, array $con
return $this->decorated->supportsDenormalization($data, $type, $format, $context);
}

/**
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
return $this->decorated->normalize($object, $format, $context);
}
Expand All @@ -68,8 +64,8 @@ public function setSerializer(SerializerInterface $serializer): void
}
}

public function hasCacheableSupportsMethod(): bool
public function getSupportedTypes(?string $format): array
{
return true;
return $this->decorated->getSupportedTypes($format);
}
}

0 comments on commit b1cf753

Please sign in to comment.