Generated with the help of an LLM.

Problem/Motivation

Outside its tests, the file module fetches 42 services by string ID. Every one of those services has a class or interface alias. #3049525: Enable service autowiring by adding interface aliases to core service definitions added the aliases for core services and #3325557: Enable more service autowiring by adding interface aliases to core modules added them for module services. Since #3490713: Return the correct typehint when Drupal::service() is called with a class string, \Drupal::service() returns the correct type when you pass it a class name. With a string ID, IDEs can't follow the reference and PHPStan can't check the type.

Steps to reproduce

Proposed resolution

Change the string IDs to the alias class constants in these places:

  • \Drupal::service() calls in File, ComputedFileUrl, FileFieldItemList, FileItem, FileWidget, FileAccessControlHandler, ManagedFile, FormFileUploader and FileUsageBase.
  • $container->get() calls in the create() methods of FileVideoFormatter, FileUploadResource and five constraint validators.

For example, \Drupal::service('file.usage') becomes \Drupal::service(FileUsageInterface::class).

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3637858

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kim.pepper created an issue. See original summary.

kim.pepper’s picture

Status: Active » Needs review
kim.pepper’s picture

Issue summary: View changes