Converts the Drupal field structure to a JSON:API array structure

Created on 24 January 2022, almost 3 years ago
Updated 16 August 2024, 4 months ago

Problem/Motivation

Nested ternary expressions (without parentheses) deprecated in PHP 7.4. Targeting PHP 8.0.0.intelephense(1033)
array_shift

Shift an element off the beginning of array

function array_shift(array &$array): mixed { }
@param array &$array — The input array.

@return mixed|null
the shifted value, or null if array is empty or is not an array.

@link https://php.net/manual/en/function.array-shift.php

@meta

Shift an element off the beginning of array

array_shift( array $array ): array

function array_shift(array &$array): mixed
Shift an element off the beginning of array

Steps to reproduce

Drupal\jsonapi\Normalizer\DataNormalizer::normalize

class DataNormalizer and FieldNormalizer

Proposed resolution

Remaining tasks

Issue Summary Update
No code needed until that is done.

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Closed: won't fix

Version

11.0 🔥

Component
JSON API 

Last updated 6 days ago

Created by

🇮🇳India heni_deepak Jaipur, Rajasthan, India

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    The Issue Summary here is very difficult to understand. There is no proposed resolution to help guide the reviewer nor are there any tasks. I have added an Issue Summary update to the tasks to emphasize the need for it. See Write an issue summary for an existing issue for guidance.

    Adding tag for testing based on #9. I am setting this to needs work to complete the issue summary.

  • 🇩🇪Germany tobiasb Berlin

    I believe this is a false positive.

    $object->getCardinality() === 1
          ? array_shift($cacheable_normalizations) ?: CacheableNormalization::permanent(NULL)
          : CacheableNormalization::aggregate($cacheable_normalizations);
    

    Is the same example 1 ? 2 ?: 3 : 4 from https://wiki.php.net/rfc/ternary_associativity which should not make any problems.

  • 🇪🇸Spain jjsanz

    From the PHP documentation: Parentheses are also not required when nesting into the middle operand, as this is always unambiguous and not affected by associativity:

    1 ? 2 ? 3 : 4 : 5 // ok
    1 ? 2 ?: 3 : 4    // ok
    

    This case is a PHP example and is correct according to documentation.

  • Status changed to Closed: won't fix 4 months ago
Production build 0.71.5 2024