Use dependency injection consistently

Created on 6 September 2022, almost 2 years ago
Updated 26 July 2023, 11 months ago

Problem/Motivation

We should not use \Drupal calls in OO code starting in the 2.x branch.

Steps to reproduce

Run PHPStan, using the following phpstan.neon file:

parameters:
  level: 2
  ignoreErrors:
    # new static() is a best practice in Drupal, so we cannot fix that.
    - "#^Unsafe usage of new static#"
    # Ignore PHPUnit Prophecy class reflection errors.
    - "#^Call to an undefined method Prophecy#"
  drupal:
    entityMapping:
      access_scheme:
        class: Drupal\workbench_access\Entity\AccessScheme
        storage: Drupal\Core\Entity\ContentEntityStorageBase
      section_association:
          class: Drupal\workbench_access\Entity\SectionAssociation
          storage: Drupal\workbench_access\SectionAssociationStorage

Proposed resolution

Fix the errors reported by PHPStan.

Remaining tasks

Fix the errors reported by PHPStan.

User interface changes

None

API changes

None

Data model changes

None

📌 Task
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

🇺🇸United States agentrickard Georgia (US)

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024