Problem/Motivation

Currently, all core service definitions put their arguments on one long line:

arguments: ['@something', '@something.else', '@another_one', '@getting_long', '@cheaper', '@by.the.dozen']

In reviewing #3041885: Display relevant Security Advisories data for Drupal, @larowlan pointed out that sometimes, with services that have many dependencies, these lines are harder to read, and might be better if we used the list format:

arguments:
  - '@something'
  - '@something.else'
  - '@another_one'
  - '@getting_long'
  - '@cheaper'
  - '@by.the.dozen'

At his suggestion, I'm opening this issue to decide when, if ever, service arguments should span multiple lines, instead of one long line.

Benefits

Increased readability and reduces the need for side scrolling.

Three supporters required

  1. https://www.drupal.org/u/borisson_ (2025-08-22)
  2. https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)
  3. https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)

Proposed changes

Current text
Proposed text
Notes

Remaining tasks

  1. Create this issue in the Coding Standards queue, using the defined template
  2. Add supporters
  3. Create a Change Record
  4. Review by the Coding Standards Committee
  5. Coding Standards Committee takes action as required
  6. Discussed by the Core Committer Committee, if it impacts Drupal Core
  7. Final review by Coding Standards Committee
  8. Documentation updates
    1. Edit all pages
    2. Publish change record
    3. Remove 'Needs documentation edits' tag
  9. If applicable, create follow-up issues for PHPCS rules/sniffs changes

For a full explanation of these steps see the Coding Standards project page
upstream work on a sniff, https://github.com/slevomat/coding-standard/issues/1684

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

For whatever my opinion is worth on this: I always use the extended multi-line format in my own projects, as I find it more readable in all cases, and it eliminates the possibility of horizontal scrolling. But that's just me.

larowlan’s picture

Same, even when it doesn't wrap

Also, yellow

longwave’s picture

We don't seem to have any explicit standards for YAML files but https://www.drupal.org/docs/develop/standards/coding-standards#linelength is a good place to start.

In general, all lines of code should not be longer than 80 characters.

Not sure if we can enforce this standard using any existing tools, maybe Coder could be extended to handle this though.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Project: Drupal core » Coding Standards

Moving to the coding standards project in the hopes of some discussion.

quietone’s picture

Version: 11.x-dev »
Component: other » Coding Standards

This needs the coding standards template

borisson_’s picture

Issue summary: View changes

I agree, I also prefer to always use the extended format.

Added template