Use strict mode for "in_array()" functions in "\Drupal\serialization\Normalizer\NormalizerBase" for verifying supported types for (de-)normalization

Created on 27 March 2017, over 7 years ago
Updated 19 February 2024, 9 months ago

Follow up for #2863778-19: Clean up \Drupal\hal\Normalizer\NormalizerBase: duplicate less from the parent class \Drupal\serialization\Normalizer\NormalizerBase β†’ :

@BR0kEN - it's the lack of the third argument and it not being TRUE that scares me. Pretty much people always want in_array($needle, $haystack, TRUE) and not in_array($needle, $haystack) - see https://3v4l.org/sr29Y

Problem/Motivation

Normalizer could define type(s) of data which they wants to normalize using supportedInterfaceOrClass property of \Drupal\serialization\Normalizer\NormalizerBase. The same available for request types, which are accepted by normalizer (using format property).

In both cases these properties will be casted to an array to be handled by in_array() function to find the matches and, in both cases, this will happen without strict data comparison which could cause potential inconsistences.

Proposed resolution

  1. Add tests
πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
SerializationΒ  β†’

Last updated 12 days ago

Created by

πŸ‡ΊπŸ‡¦Ukraine BR0kEN Dnipro

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

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.

Production build 0.71.5 2024