inject dependencies

Created on 27 May 2025, 12 days ago

Problem/Motivation

phpstan reports, among other things,

------ ------------------------------------------------------------------------------
Line src/DataParserPluginBase.php
------ ------------------------------------------------------------------------------
77 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ -------------------------------------------------------------------------------------------------------------------------------------
Line src/Plugin/migrate/process/DomStrReplace.php
------ -------------------------------------------------------------------------------------------------------------------------------------
215 Method Drupal\migrate_plus\Plugin\migrate\process\DomStrReplace::getSubject() should return string but return statement is missing.
231 Method Drupal\migrate_plus\Plugin\migrate\process\DomStrReplace::getSearch() should return string but return statement is missing.
245 Method Drupal\migrate_plus\Plugin\migrate\process\DomStrReplace::getReplace() should return string but return statement is missing.
------ -------------------------------------------------------------------------------------------------------------------------------------

------ ----------------------------------------------------------------------------------------------------------------------------------------------
Line src/Plugin/migrate/process/EntityGenerate.php
------ ----------------------------------------------------------------------------------------------------------------------------------------------
92 Method Drupal\migrate_plus\Plugin\migrate\process\EntityGenerate::generateEntity() should return int|string but return statement is missing.
------ ----------------------------------------------------------------------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/migrate/source/Url.php
------ ------------------------------------------------------------------------------
64 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------
Line src/Plugin/migrate_plus/data_fetcher/Http.php
------ ------------------------------------------------------------------------------
64 \Drupal calls should be avoided in classes, use dependency injection instead
81 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------

Steps to reproduce

phpstan analyse -l0 migrate_plus

Proposed resolution

  • Leave DataParserPluginBase and Url alone, on the assumption that the pattern is intentional.
  • In DomStrReplace and EntityGenerate, return an empty string rather than NULL to satisfy the definition.
  • In Http, use the available create() method instead of __construct().

Remaining tasks

make a MR

πŸ“Œ Task
Status

Active

Version

6.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States BenStallings

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