Wrong type in phpdoc for setContainerParameter

Created on 13 January 2024, 11 months ago
Updated 2 February 2024, 11 months ago

Problem/Motivation

In https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

/**
   * Changes parameters in the services.yml file.
   *
   * @param string $name
   *   The name of the parameter.
   * @param string $value
   *   The value of the parameter.
   */
  protected function setContainerParameter($name, $value) {
    $filename = $this->siteDirectory . '/services.yml';
    chmod($filename, 0666);

    $services = Yaml::decode(file_get_contents($filename));
    $services['parameters'][$name] = $value;
    file_put_contents($filename, Yaml::encode($services));

    // Ensure that the cache is deleted for the yaml file loader.
    $file_cache = FileCacheFactory::get('container_yaml_loader');
    $file_cache->delete($filename);
  }

The $value type is string, but it can be anything and most of the time it is already an array that is passed. Example:

https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/syste...

// Enable debug, rebuild the service container, and clear all caches.
    $parameters = $this->container->getParameter('twig.config');
    $parameters['debug'] = TRUE;
    $this->setContainerParameter('twig.config', $parameters);

Proposed resolution

Fix the type to be mixed or array|string?

Remaining tasks

- Decide of a solution
- Implement it

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Documentation 

Last updated 1 day ago

No maintainer
Created by

🇫🇷France Grimreaper France 🇫🇷

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024