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 inFile,ComputedFileUrl,FileFieldItemList,FileItem,FileWidget,FileAccessControlHandler,ManagedFile,FormFileUploaderandFileUsageBase.$container->get()calls in thecreate()methods ofFileVideoFormatter,FileUploadResourceand 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
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
Comment #3
kim.pepperComment #4
kim.pepper