Inject dependencies

Created on 18 September 2025, 25 days ago

Problem/Motivation

phpstan reports,

------ ----------------------------------------------------------------------
Line src/Access/CSRFTokenAccessCheck.php
------ ----------------------------------------------------------------------
54 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Controller/Services.php
------ ----------------------------------------------------------------------
107 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Entity/ServicesEntityCreateAccessCheck.php
------ ----------------------------------------------------------------------
44 \Drupal calls should be avoided in classes, use dependency injection
instead
66 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ -----------------------------------------------------------------------
Line src/Form/ServiceEndpointForm.php
------ -----------------------------------------------------------------------
96 Method Drupal\services\Form\ServiceEndpointForm::save() should return
int but return statement is missing.
------ -----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Form/ServiceResourceConfigForm.php
------ ----------------------------------------------------------------------
59 Method Drupal\services\Form\ServiceResourceConfigForm::save() should
return int but return statement is missing.
------ ----------------------------------------------------------------------
------ -------------------------------------------------------------------------
Line src/Plugin/ServiceDefinition/EntityDelete.php
------ -------------------------------------------------------------------------
36 Method
Drupal\services\Plugin\ServiceDefinition\EntityDelete::processRequest()
should return array but return statement is missing.
------ -------------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Plugin/ServiceDefinition/EntityView.php
------ ----------------------------------------------------------------------
107 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Plugin/ServiceDefinition/VocabularyTreeGet.php
------ ----------------------------------------------------------------------
54 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Routing/ServiceEndpoint.php
------ ----------------------------------------------------------------------
20 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------

Steps to reproduce

see https://git.drupalcode.org/project/services/-/jobs/1759210

Proposed resolution

  • in CSRFTokenAccessCheck and ServicesEntityCreateAccessCheck, pass the dependency via services.yml.
  • in Services, EntityView, and VocabularyTreeGet, add to the existing create() method.
  • in ServiceEndpointForm, ServiceResourceConfigForm, and EntityDelete, add a return statement.
  • I'm not sure what to do with ServiceEndpoint.

Remaining tasks

make a 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

Comments & Activities

Not all content is available!

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

No activities found.

Production build 0.71.5 2024