Verified Commit 61189f33 authored by Dave Long's avatar Dave Long
Browse files

Issue #3557055 by alexpott, andypost:...

Issue #3557055 by alexpott, andypost: \Drupal\Core\Config\Schema\Mapping::getDynamicallyValidKeys() triggers a deprecation on PHP 8.5

(cherry picked from commit c5aeab53)
parent 59721e98
Loading
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -180,22 +180,21 @@ public function getDynamicallyValidKeys(): array {
    // ("statically") valid. Not all types have a fallback type.
    // @see \Drupal\Core\Config\TypedConfigManager::getDefinitionWithReplacements()
    $fallback_type = $typed_data_manager->findFallback($original_mapping_type);
    $valid_keys_everywhere = array_intersect_key(
      $valid_keys_per_type,
      [$fallback_type => NULL],
    );
    assert(count($valid_keys_everywhere) <= 1);
    if ($fallback_type !== NULL && isset($valid_keys_per_type[$fallback_type])) {
      $valid_keys_everywhere = [$fallback_type => $valid_keys_per_type[$fallback_type]];
      $statically_required_keys = NestedArray::mergeDeepArray($valid_keys_everywhere);

    // Now that statically valid keys are known, determine which valid keys are
    // only valid in *some* cases: remove the statically valid keys from every
    // per-type array of valid keys.
    $valid_keys_some = array_diff_key($valid_keys_per_type, $valid_keys_everywhere);
    $valid_keys_some_processed = array_map(
      // Now that statically valid keys are known, determine which valid keys
      // are only valid in *some* cases: remove the statically valid keys from
      // every per-type array of valid keys.
      unset($valid_keys_per_type[$fallback_type]);
      $valid_keys_per_type = array_map(
        fn (array $keys) => array_values(array_filter($keys, fn (string $key) => !in_array($key, $statically_required_keys, TRUE))),
      $valid_keys_some
        $valid_keys_per_type
      );
    return $valid_keys_some_processed;
    }

    return $valid_keys_per_type;
  }

  /**