Verified Commit ca9f9beb authored by Andrei Mateescu's avatar Andrei Mateescu
Browse files

task: #3563533 Fix PHPStan missingType.generics for \ArrayObject not specifying its types

By: mondrake
By: smustgrave
parent bf1afdcf
Loading
Loading
Loading
Loading
Loading
−258

File changed.

Preview size limit exceeded, changes collapsed.

+12 −1
Changes for core/modules/jsonapi/src/Normalizer/DataNormalizer.php: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -13,7 +13,18 @@
class DataNormalizer extends NormalizerBase {

  /**
   * {@inheritdoc}
   * Normalizes data into a set of arrays/scalars.
   *
   * @param \Drupal\jsonapi\JsonApiResource\Data $object
   *   Data to normalize.
   * @param string|null $format
   *   Format the normalization result will be encoded as.
   * @param array<string, mixed> $context
   *   Context options for the normalizer.
   *
   * @return array|string|int|float|bool|\ArrayObject<mixed, mixed>|null
   *   \ArrayObject is used to make sure an empty object is encoded as an
   *   object not an array.
   */
  public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
    assert($object instanceof Data);
+12 −1
Changes for core/modules/jsonapi/src/Normalizer/EntityDenormalizerBase.php: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -72,7 +72,18 @@ public function supportsNormalization($data, ?string $format = NULL, array $cont
  }

  /**
   * {@inheritdoc}
   * Normalizes data into a set of arrays/scalars.
   *
   * @param mixed $object
   *   Data to normalize.
   * @param string|null $format
   *   Format the normalization result will be encoded as.
   * @param array<string, mixed> $context
   *   Context options for the normalizer.
   *
   * @return array|string|int|float|bool|\ArrayObject<mixed, mixed>|null
   *   \ArrayObject is used to make sure an empty object is encoded as an
   *   object not an array.
   */
  public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
    throw new \LogicException('This method should never be called.');
+12 −1
Changes for core/modules/jsonapi/src/Normalizer/EntityReferenceFieldNormalizer.php: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -25,7 +25,18 @@
class EntityReferenceFieldNormalizer extends FieldNormalizer {

  /**
   * {@inheritdoc}
   * Normalizes data into a set of arrays/scalars.
   *
   * @param \Drupal\Core\Field\EntityReferenceFieldItemListInterface $field
   *   Data to normalize.
   * @param string|null $format
   *   Format the normalization result will be encoded as.
   * @param array<string, mixed> $context
   *   Context options for the normalizer.
   *
   * @return array|string|int|float|bool|\ArrayObject<mixed, mixed>|null
   *   \ArrayObject is used to make sure an empty object is encoded as an
   *   object not an array.
   */
  public function normalize($field, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
    assert($field instanceof EntityReferenceFieldItemListInterface);
+12 −1
Changes for core/modules/jsonapi/src/Normalizer/FieldItemNormalizer.php: 12 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -52,12 +52,23 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager) {
  }

  /**
   * {@inheritdoc}
   * Normalizes data into a set of arrays/scalars.
   *
   * This normalizer leaves JSON:API normalizer land and enters the land of
   * Drupal core's serialization system. That system was never designed with
   * cacheability in mind, and hence bubbles cacheability out of band. This must
   * catch it, and pass it to the value object that JSON:API uses.
   *
   * @param \Drupal\Core\Field\FieldItemInterface $object
   *   Data to normalize.
   * @param string|null $format
   *   Format the normalization result will be encoded as.
   * @param array<string, mixed> $context
   *   Context options for the normalizer.
   *
   * @return array|string|int|float|bool|\ArrayObject<mixed, mixed>|null
   *   \ArrayObject is used to make sure an empty object is encoded as an
   *   object not an array.
   */
  public function doNormalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
    assert($object instanceof FieldItemInterface);
Loading