Problem/Motivation
PHPStan reports 13 dependency-injection findings in the image formatters, caption service and hook classes: stored entity-storage dependencies and global service calls.
Steps to reproduce
- Run PHPStan with the Drupal extension against the current
1.0.xsource. - Observe the dependency-injection findings in the formatters, caption service and hooks.
Proposed resolution
Inject the entity type manager and retrieve entity storage when needed. Inject the existing hook services and build image-style options through the injected manager. Preserve formatter settings and rendering behavior.
This follows the merged coding cleanup in #3628803. The separate serialization fix in #3628779 remains unchanged.
Equivalent video-module issue: #3628876.
Kernel tests pass on Drupal 10 and 11 for style options, rendering, dependencies, cache tags and service wiring. All 13 findings are resolved. Compatibility with the pending MRs has been checked.
Remaining tasks
Review and merge the MR.
API changes
Formatter constructors and protected storage properties change to use EntityTypeManagerInterface. The caption service gains an entity type manager argument, and hook classes gain service arguments. Custom instantiation or subclasses using these must be updated.
Issue fork glightbox-3628879
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
nick hope commentedComment #6
levmyshkinComment #8
levmyshkin