Fix \Drupal calls should be avoided in classes, use dependency injection

Created on 16 February 2025, about 2 months ago

Problem/Motivation

PHPStan reports (and currently is forced to ignore) many \Drupal calls should be avoided in classes, use dependency injection instead warning. If possible these should be fixed and then removed from phpstan-baseline-to-fix.neon

Or if not possible to fix, then the ignoreError should be moved into the phpstan-baseline.neon file of permanently ignored warnings.

Remaining tasks

As at issue creation (16 Feb 2025) the phpstan custom summary script reports the following

---------------------------------------------------------------------------
Summary of PHPStan messages in phpstan-baseline-to-fix.neon
---------------------------------------------------------------------------
Drupal calls should be avoided in classes, use dependency injection instead
36 occurrence(s) in 12 file(s)
   scheduler_rules_integration/src/Plugin/Condition/PublishingIsEnabled.php
   scheduler_rules_integration/src/Plugin/Condition/UnpublishingIsEnabled.php
   scheduler_rules_integration/src/Plugin/RulesAction/RemovePublishingDate.php
   scheduler_rules_integration/src/Plugin/RulesAction/RemoveUnpublishingDate.php
   scheduler_rules_integration/src/Plugin/RulesAction/SchedulerRulesActionBase.php
   scheduler_rules_integration/src/Plugin/RulesAction/SetPublishingDate.php
   scheduler_rules_integration/src/Plugin/RulesAction/SetUnpublishingDate.php
   src/Plugin/Validation/Constraint/SchedulerPublishOnConstraintValidator.php
   src/Plugin/Validation/Constraint/SchedulerUnpublishOnConstraintValidator.php
   src/Routing/SchedulerRouteSubscriber.php
   src/SchedulerManager.php
   src/Theme/SchedulerThemeNegotiator.php
---------------------------------------------------------------------------
Number of messages by file
   17 in src/SchedulerManager.php
   4 in src/Plugin/Validation/Constraint/SchedulerUnpublishOnConstraintValidator.php
   3 in src/Plugin/Validation/Constraint/SchedulerPublishOnConstraintValidator.php
   3 in src/Theme/SchedulerThemeNegotiator.php
   2 in scheduler_rules_integration/src/Plugin/RulesAction/SchedulerRulesActionBase.php
   1 in scheduler_rules_integration/src/Plugin/Condition/PublishingIsEnabled.php
   1 in scheduler_rules_integration/src/Plugin/Condition/UnpublishingIsEnabled.php
   1 in scheduler_rules_integration/src/Plugin/RulesAction/RemovePublishingDate.php
   1 in scheduler_rules_integration/src/Plugin/RulesAction/RemoveUnpublishingDate.php
   1 in scheduler_rules_integration/src/Plugin/RulesAction/SetPublishingDate.php
   1 in scheduler_rules_integration/src/Plugin/RulesAction/SetUnpublishingDate.php
   1 in src/Routing/SchedulerRouteSubscriber.php
---------------------------------------------------------------------------
Different types of message: 1
Total number of messages: 36
---------------------------------------------------------------------------
📌 Task
Status

Active

Version

2.0

Component

Coding Standards

Created by

🇬🇧United Kingdom jonathan1055

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024