Skip to content

[phpstan] \Drupal calls should be avoided in classes, use dependency injection instead #9

Description

@kylehuynh205

To reproduce:

  • Run phpstan
php ../../../../vendor/bin/phpstan.phar analyse --memory-limit=256M .

- Output:

image

Diagnose:
Calling directly Drupal service is not Drupal code standard, Need to change the code to Dependency injection to pass phpstan.

Example: https://www.drupal.org/files/issues/2022-07-14/Drupal-calls-should-be-avoided-in-classes-3296033-2.patch

Resource:
https://drupalize.me/topic/dependency-injection

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions