Add return type to the update function to comply with modern standards

Created on 26 March 2024, 3 months ago
Updated 13 May 2024, about 2 months ago

Problem/Motivation

Modern PHP standards recommend that we add return type to methods and functions, especially if the function returns something.

The update function generated by this module returns a string, but no return type is supplied to the function.

function {{ update_hook_name }}() {
  /** @var \Drupal\update_helper\Updater $updater */
  $updater = \Drupal::service('update_helper.updater');

  // Execute configuration update definitions with logging of success.
  $updater->executeUpdate('{{ module }}', '{{ update_hook_name }}');

  // Output logged messages to related channel of update execution.
  return $updater->logger()->output();
}

This is recurrently being reported as an issue by PHPStan in our pipeline, forcing us to fix it manually.

Proposed resolution

The solution is simply add the return type to the function in the Twig template. This would save us some time and energy πŸ₯Ή

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

✨ Feature request
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil tregismoreira

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024