use dependency injection

Created on 6 May 2025, 3 months ago

Problem/Motivation

phpstan reports,

------ ------------------------------------------------------------------------------
Line src/Controller/ServerListBuilder.php
------ ------------------------------------------------------------------------------
43 \Drupal calls should be avoided in classes, use dependency injection instead
51 \Drupal calls should be avoided in classes, use dependency injection instead
59 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/GraphQL/Execution/Executor.php
------ ------------------------------------------------------------------------------
320 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php
------ ------------------------------------------------------------------------------
102 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/GraphQL/DataProducer/EntityDefinition/EntityDefinition.php
------ ------------------------------------------------------------------------------
110 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/GraphQL/DataProducer/User/PasswordReset.php
------ ------------------------------------------------------------------------------
106 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

Steps to reproduce

phpstan analyse -l0 graphql

Proposed resolution

  • in ServerListBuilder, use the $instance = parent::createInstance() pattern
  • in the other classes, add to the existing create() function

Remaining tasks

make an MR

📌 Task
Status

Active

Version

5.0

Component

Code

Created by

🇺🇸United States BenStallings

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

Merge Requests

Comments & Activities

  • Issue created by @BenStallings
  • Merge request !37use dependency injection → (Merged) created by BenStallings
  • Pipeline finished with Failed
    3 months ago
    Total: 308s
    #490654
  • Pipeline finished with Failed
    3 months ago
    Total: 418s
    #490652
  • Pipeline finished with Success
    3 months ago
    Total: 344s
    #490660
  • Pipeline finished with Canceled
    3 months ago
    Total: 279s
    #492590
  • Pipeline finished with Success
    3 months ago
    Total: 204s
    #492595
  • Pipeline finished with Success
    3 months ago
    Total: 195s
    #492602
  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Thanks, can you also fix examples/graphql_example/src/Wrappers/QueryConnection.php and cleanup up phpstan.neon so that all \Drupal ignores and the comment is removed?

  • Issue was unassigned.
  • Status changed to Needs work 20 days ago
  • First commit to issue fork.
  • Pipeline finished with Failed
    20 days ago
    Total: 156s
    #549826
  • Pipeline finished with Failed
    20 days ago
    Total: 339s
    #549830
  • Pipeline finished with Failed
    20 days ago
    Total: 207s
    #549839
  • 🇮🇳India ankitv18

    Raised one issue to fix the composer pipeline separately.

  • 🇮🇳India ankitv18

    Once this issue: https://www.drupal.org/project/graphql/issues/3536497 📌 composer pipeline is failing with D11.2.2 Active is merged then we can rebase and pipeline will work as expected.

  • Pipeline finished with Failed
    20 days ago
    Total: 169s
    #549883
  • 🇦🇹Austria klausi 🇦🇹 Vienna

    Merging in the 5.x branch fixed the composer fail.

    Merged, thanks!

Production build 0.71.5 2024