diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8c32fe2..0aef543 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,36 +29,31 @@ jobs: php: ['8.3'] mongodb: ['1.17.2'] include: - # TODO - Symfony 7 -# - description: Tests - Symfony 6.4 -# php: 8.3 -# symfony-version: '7.*' -# mongodb: '1.17.2' # latest - description: Tests - Symfony 6.4 - php: 8.2 + php: '8.2' symfony-version: '6.4.*' mongodb: '1.15.3' # 1.15 introduced PHP 8.2 support - description: Tests - Symfony 5.4 - php: 8.1 + php: '8.1' symfony-version: '5.4.*' mongodb: '1.12.1' # 1.12 introduced PHP 8.1 support - description: Tests - Symfony 5.4 - php: 8.0 + php: '8.0' symfony-version: '5.4.*' - description: Tests - Symfony 4.4 - php: 7.4 - mongodb: ['1.9.2'] + php: '7.4' + mongodb: '1.9.2' # 1.9.0 introduced PHP 8.0 support symfony-version: '4.4.*' - description: Prefer lowest composer: 'composer:v1' dependencies: 'lowest' - php: 7.4 + php: '7.4' symfony-version: '^4.4.1' mongodb: '1.2.0' deprecations: disabled - description: Infection - mongodb: ['1.9.2'] - php: 7.4 + mongodb: '1.9.2' + php: '7.4' symfony-version: '4.4.*' env: diff --git a/CHANGELOG.md b/CHANGELOG.md index b85806e..76a9cb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 1.4.0 (TBA) +* Allow Symfony 7 ([#18](https://github.com/facile-it/mongodb-messenger-transport/issues/18)) + ## 1.3.2 (2022-05-16) -* Allow Symfony 6.0 ([#14](https://github.com/facile-it/mongodb-messenger-transport/issues/14)) +* Allow Symfony 6 ([#14](https://github.com/facile-it/mongodb-messenger-transport/issues/14)) ## 1.3.1 (2022-02-07) * Fix handling of headers during serialization ([#13](https://github.com/facile-it/mongodb-messenger-transport/issues/13)); this unlocks the possibility of using JSON serialization, i.e. with the Symfony Serializer diff --git a/Makefile b/Makefile index 43e56fa..11f2eee 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,6 @@ lock-symfony-%: docker-compose run --no-deps --rm php composer config extra.symfony.require "${SYMFONY_VERSION}.*" docker-compose run --no-deps --rm php composer install --prefer-dist --no-interaction ${COMPOSER_FLAGS} -test-composer-install: lock-symfony-3.4 lock-symfony-4.4 lock-symfony-5.0 lock-symfony-6.0 +test-composer-install: lock-symfony-3.4 lock-symfony-4.4 lock-symfony-5.0 lock-symfony-6.0 lock-symfony-7.0 pre-commit-checks: cs-fix phpstan test infection diff --git a/composer.json b/composer.json index 0f3bce8..2630a0f 100644 --- a/composer.json +++ b/composer.json @@ -18,30 +18,30 @@ ], "require": { "php": "^7.4 || ^8.0", - "ext-mongodb": "^1.1.5", - "facile-it/mongodb-bundle": "^0.6 || ^1.0.0", - "mongodb/mongodb": "^1.1.0", - "symfony/deprecation-contracts": "^2.1", - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/messenger": "^4.4 || ^5.0 || ^6.0" + "ext-mongodb": "^1.6", + "facile-it/mongodb-bundle": "^1.6", + "mongodb/mongodb": "^1.5", + "symfony/deprecation-contracts": "^2.1 || ^3.0", + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/messenger": "^4.4 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { "facile-it/facile-coding-standard": "^1.2", "facile-it/symfony-functional-testcase": "^1.0", - "infection/infection": ">=0.18", + "infection/infection": ">=0.23", "jangregor/phpstan-prophecy": "^1.0", "phpspec/prophecy-phpunit": "^2.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "1.10.62", "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5.2", + "phpunit/phpunit": "^9.6.13", "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0", "symfony/flex": "^1.21.6 || ^2.0", - "symfony/phpunit-bridge": "^5.2.4", - "symfony/property-access": "^4.4 || ^5.0 || ^6.0", - "symfony/property-info": "^4.4 || ^5.0 || ^6.0", - "symfony/serializer": "^4.4 || ^5.0 || ^6.0", - "symfony/yaml": "^4.4 || ^5.0 || ^6.0" + "symfony/phpunit-bridge": "^7.0", + "symfony/property-access": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/property-info": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/serializer": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/yaml": "^4.4 || ^5.0 || ^6.0 || ^7.0" }, "minimum-stability": "stable", "autoload": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c007d9b..64467dc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -46,15 +46,25 @@ parameters: path: src/Util/RedeliveryStampExtractor.php - - message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\ObjectNormalizerDecorator\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" + message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\ObjectNormalizerDecorator\\:\\:doNormalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" count: 1 path: tests/End2End/App/ObjectNormalizerDecorator.php - - message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\ObjectNormalizerDecorator\\:\\:normalize\\(\\) should return \\(ArrayObject&iterable\\)\\|bool\\|float\\|int\\|string\\|null but returns array\\|ArrayObject\\|bool\\|float\\|int\\|string\\|null\\.$#" + message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\ObjectNormalizerDecorator\\:\\:doNormalize\\(\\) should return \\(ArrayObject&iterable\\)\\|bool\\|float\\|int\\|string\\|null but returns array\\|ArrayObject\\|bool\\|float\\|int\\|string\\|null\\.$#" count: 1 path: tests/End2End/App/ObjectNormalizerDecorator.php + - + message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\SuppressDeprecationNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" + count: 1 + path: tests/End2End/App/SuppressDeprecationNormalizer.php7.php + + - + message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\SuppressDeprecationNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" + count: 1 + path: tests/End2End/App/SuppressDeprecationNormalizer.php8.php + - message: "#^Parameter \\#1 \\$id of method Facile\\\\MongoDbMessenger\\\\Transport\\\\MongoDbUnresettableTransport\\:\\:find\\(\\) expects MongoDB\\\\BSON\\\\ObjectId\\|string, mixed given\\.$#" count: 1 diff --git a/tests/End2End/AbstractMongoDbTransportTest.php b/tests/End2End/AbstractMongoDbTransportTest.php index 99a6b6f..dd38a30 100644 --- a/tests/End2End/AbstractMongoDbTransportTest.php +++ b/tests/End2End/AbstractMongoDbTransportTest.php @@ -165,6 +165,7 @@ private function getOneEnvelope(MongoDbUnresettableTransport $transport): Envelo { $envelopes = $transport->get(); $this->assertIsArray($envelopes); + $this->assertNotEmpty($envelopes, 'No Envelope found'); $fetchedEnvelope = current($envelopes); $this->assertInstanceOf(Envelope::class, $fetchedEnvelope); diff --git a/tests/End2End/App/ObjectNormalizerDecorator.php b/tests/End2End/App/ObjectNormalizerDecorator.php index 56a2464..f38d93a 100644 --- a/tests/End2End/App/ObjectNormalizerDecorator.php +++ b/tests/End2End/App/ObjectNormalizerDecorator.php @@ -29,7 +29,7 @@ public function __construct() * * @return mixed */ - public function denormalize($data, $type, $format = null, array $context = []) + protected function doDenormalize($data, $type, $format = null, array $context = []) { // inside RedeliveryStamp $context[ObjectNormalizer::IGNORED_ATTRIBUTES][] = 'exceptionMessage'; @@ -45,8 +45,9 @@ public function denormalize($data, $type, $format = null, array $context = []) * @param mixed $data * @param string $type * @param string|null $format + * @param array $context */ - public function supportsDenormalization($data, $type, $format = null): bool + public function supportsDenormalization($data, $type, $format = null, array $context = []): bool { return class_exists($type) && in_array($type, [ @@ -62,7 +63,7 @@ public function supportsDenormalization($data, $type, $format = null): bool * * @return mixed[]|string|int|float|bool|\ArrayObject|null */ - public function normalize($object, $format = null, array $context = []) + protected function doNormalize($object, $format = null, array $context = []) { // inside RedeliveryStamp $context[ObjectNormalizer::IGNORED_ATTRIBUTES][] = 'exceptionMessage'; @@ -74,8 +75,9 @@ public function normalize($object, $format = null, array $context = []) /** * @param mixed $data * @param string|null $format + * @param array $context */ - public function supportsNormalization($data, $format = null): bool + public function supportsNormalization($data, $format = null, array $context = []): bool { return $data instanceof FlattenException || $data instanceof RedeliveryStamp diff --git a/tests/End2End/App/SuppressDeprecationNormalizer.php b/tests/End2End/App/SuppressDeprecationNormalizer.php index 76bc83c..a431789 100644 --- a/tests/End2End/App/SuppressDeprecationNormalizer.php +++ b/tests/End2End/App/SuppressDeprecationNormalizer.php @@ -4,30 +4,8 @@ namespace Facile\MongoDbMessenger\Tests\End2End\App; -use Symfony\Component\ErrorHandler\Exception\FlattenException; -use Symfony\Component\Messenger\Stamp\RedeliveryStamp; -use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface; - if (\Symfony\Component\HttpKernel\Kernel::VERSION_ID >= 6_03_00) { - class SuppressDeprecationNormalizer extends ObjectNormalizerDecorator - { - /** - * @return array - */ - public function getSupportedTypes(?string $format): array - { - return [ - FlattenException::class => true, - RedeliveryStamp::class => true, - ]; - } - } + require_once __DIR__ . '/SuppressDeprecationNormalizer.php8.php'; } else { - class SuppressDeprecationNormalizer extends ObjectNormalizerDecorator implements CacheableSupportsMethodInterface - { - public function hasCacheableSupportsMethod(): bool - { - return $this->objectNormalizer->hasCacheableSupportsMethod(); - } - } + require_once __DIR__ . '/SuppressDeprecationNormalizer.php7.php'; } diff --git a/tests/End2End/App/SuppressDeprecationNormalizer.php7.php b/tests/End2End/App/SuppressDeprecationNormalizer.php7.php new file mode 100644 index 0000000..4219c4d --- /dev/null +++ b/tests/End2End/App/SuppressDeprecationNormalizer.php7.php @@ -0,0 +1,38 @@ +objectNormalizer->hasCacheableSupportsMethod(); + } + + /** + * @param mixed $data Data to restore + * @param string $type + * @param string|null $format + * @param array&array{ignored_attributes?: string[]} $context + */ + public function denormalize($data, $type, $format = null, array $context = []) + { + return parent::doDenormalize($data, $type, $format, $context); // TODO: Change the autogenerated stub + } + + /** + * @param mixed $object + * @param string|null $format + * @param array&array{ignored_attributes?: string[]} $context + * + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []) + { + return $this->doNormalize($object, $format, $context); + } +} diff --git a/tests/End2End/App/SuppressDeprecationNormalizer.php8.php b/tests/End2End/App/SuppressDeprecationNormalizer.php8.php new file mode 100644 index 0000000..25fe780 --- /dev/null +++ b/tests/End2End/App/SuppressDeprecationNormalizer.php8.php @@ -0,0 +1,45 @@ + + */ + public function getSupportedTypes(?string $format): array + { + return [ + FlattenException::class => true, + RedeliveryStamp::class => true, + ]; + } + + /** + * @param mixed $data Data to restore + * @param string $type + * @param string|null $format + * @param array&array{ignored_attributes?: string[]} $context + */ + public function denormalize($data, $type, $format = null, array $context = []): mixed + { + return parent::doDenormalize($data, $type, $format, $context); // TODO: Change the autogenerated stub + } + + /** + * @param mixed $object + * @param string|null $format + * @param array&array{ignored_attributes?: string[]} $context + * + * @return array|string|int|float|bool|\ArrayObject|null + */ + public function normalize($object, $format = null, array $context = []): \ArrayObject|array|string|int|float|bool|null + { + return $this->doNormalize($object, $format, $context); + } +}