Fatal due to mismatch of normalizer/denormalizer class function signatures

Created on 27 January 2023, almost 2 years ago
Updated 29 January 2023, almost 2 years ago

After updating a site from Drupal 9 to 10 with php 8.1, there are these fatal errors:

PHP Fatal error: Declaration of Drupal\smart_date\Normalizer\SmartDateNormalizer::denormalize($data, $class, $format = null, array $context = []) must be compatible with Drupal\serialization\Normalizer\TimestampNormalizer::denormalize($data, $class, $format = null, array $context = []): mixed in /app/web/modules/contrib/smart_date/src/Normalizer/SmartDateNormalizer.php on line 23

and

PHP Fatal error: Declaration of Drupal\smart_date\Normalizer\SmartDateItemNormalizer::normalize($object, $format = null, array $context = []) must be compatible with Drupal\serialization\Normalizer\TimestampItemNormalizer::normalize($object, $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null in /app/web/modules/contrib/smart_date/src/Normalizer/SmartDateItemNormalizer.php on line 28

SmartDateNormalizer has
public function denormalize($data, $class, $format = NULL, array $context = [])

compared to TimestampNormalizer with
public function denormalize($data, $class, $format = NULL, array $context = []): mixed

and SmartDateItemNormalizer has
public function normalize($object, $format = NULL, array $context = [])

compared to TimestampItemNormalizer with
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL

Patch to follow that adds the return types and prevents this fatal error.

πŸ› Bug report
Status

Fixed

Version

3.7

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ransomweaver

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024