diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d067a2e..64467dc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -57,8 +57,13 @@ parameters: - message: "#^Method Facile\\\\MongoDbMessenger\\\\Tests\\\\End2End\\\\App\\\\SuppressDeprecationNormalizer\\:\\:normalize\\(\\) return type with generic class ArrayObject does not specify its types\\: TKey, TValue$#" - count: 2 - path: tests/End2End/App/SuppressDeprecationNormalizer.php + 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\\.$#" diff --git a/tests/End2End/App/SuppressDeprecationNormalizer.php b/tests/End2End/App/SuppressDeprecationNormalizer.php index bb4b29d..a431789 100644 --- a/tests/End2End/App/SuppressDeprecationNormalizer.php +++ b/tests/End2End/App/SuppressDeprecationNormalizer.php @@ -4,76 +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, - ]; - } - - /** - * @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); - } - } + require_once __DIR__ . '/SuppressDeprecationNormalizer.php8.php'; } else { - 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&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); - } - } + 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); + } +}