Explicitly require no space before colon for return types

Created on 30 September 2024, 2 months ago

Problem/Motivation

Currently we don't explicitly describe how return types should be formatted. Such formatting can be enforced by SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing.

Benefits

If we adopted this change, the Drupal Project would benefit by having consistency.

Three supporters required

  1. https://www.drupal.org/u/ {userid} (yyyy-mm-dd they added support)
  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

Provide all proposed changes to the Drupal Coding standards . Give a link to each section that will be changed, and show the current text and proposed text as in the following layout:

1. Parameter and return type hinting

Beginning with Drupal 9, parameter and return type hints should be used wherever possible. Example function definition using parameter and return type hints:

public function myMethod(MyClass $myClass, string $id): array {
  // Method code here.
}

Beginning with Drupal 9, parameter and return type hints should be used wherever possible. Example function definition using parameter and return type hints:

public function myMethod(MyClass $myClass, string $id): array {
  // Method code here.
}

There should be no space between the closing parentheses and the colon, and one space after the colon before the return type.

Remaining tasks

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

For a full explanation of these steps see the Coding Standards project page

Feature request
Status

Active

Component

Coding Standards

Created by

🇦🇺Australia mstrelan

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

Comments & Activities

Production build 0.71.5 2024