Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Symfony 7 #18

Merged
merged 21 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,39 @@ 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:
MONGO_HOST: localhost
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
SYMFONY_REQUIRE: '6.4.*'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 12 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/End2End/AbstractMongoDbTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions tests/End2End/App/ObjectNormalizerDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<string, mixed> $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, [
Expand All @@ -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';
Expand All @@ -74,8 +75,9 @@ public function normalize($object, $format = null, array $context = [])
/**
* @param mixed $data
* @param string|null $format
* @param array<string, mixed> $context
*/
public function supportsNormalization($data, $format = null): bool
public function supportsNormalization($data, $format = null, array $context = []): bool
{
return $data instanceof FlattenException
|| $data instanceof RedeliveryStamp
Expand Down
26 changes: 2 additions & 24 deletions tests/End2End/App/SuppressDeprecationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, bool>
*/
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';
}
38 changes: 38 additions & 0 deletions tests/End2End/App/SuppressDeprecationNormalizer.php7.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Facile\MongoDbMessenger\Tests\End2End\App;

use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;

class SuppressDeprecationNormalizer extends ObjectNormalizerDecorator implements CacheableSupportsMethodInterface
{
public function hasCacheableSupportsMethod(): bool
{
return $this->objectNormalizer->hasCacheableSupportsMethod();
}

/**
* @param mixed $data Data to restore
* @param string $type
* @param string|null $format
* @param array<string, mixed>&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<string, mixed>&array{ignored_attributes?: string[]} $context
*
* @return array<mixed>|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = [])
{
return $this->doNormalize($object, $format, $context);
}
}
45 changes: 45 additions & 0 deletions tests/End2End/App/SuppressDeprecationNormalizer.php8.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Facile\MongoDbMessenger\Tests\End2End\App;

use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;

class SuppressDeprecationNormalizer extends ObjectNormalizerDecorator
{
/**
* @return array<string, bool>
*/
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<string, mixed>&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<string, mixed>&array{ignored_attributes?: string[]} $context
*
* @return array<mixed>|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);
}
}