Closed (fixed)
Project:
Project Browser
Version:
1.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 Apr 2024 at 07:21 UTC
Updated:
6 May 2024 at 17:24 UTC
Jump to comment: Most recent
PHPStan is reporting a number of errors due to \Drupal calls from classes.
I believe all PHPStan issues were fixed during the GitLabCI migration, and these lines seem to have been added before it, so it could be a change to the PHPStan rules in GitLabCI:
------ --------------------------------------------------------------------------------------------------------
Line modules/project_browser_source_example/src/Plugin/ProjectBrowserSource/ProjectBrowserSourceExample.php
------ --------------------------------------------------------------------------------------------------------
47 \Drupal calls should be avoided in classes, use dependency injection
instead
------ --------------------------------------------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Commands/UpdateFixtureCommands.php
------ ----------------------------------------------------------------------
87 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Plugin/ProjectBrowserSource/DrupalCore.php
------ ----------------------------------------------------------------------
180 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/Plugin/ProjectBrowserSource/MockDrupalDotOrg.php
------ ----------------------------------------------------------------------
328 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line src/ProjectBrowserFixtureHelper.php
------ ----------------------------------------------------------------------
386 \Drupal calls should be avoided in classes, use dependency injection
instead
521 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line tests/modules/project_browser_test/src/Datetime/TestTime.php
------ ----------------------------------------------------------------------
37 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
------ ----------------------------------------------------------------------
Line tests/modules/project_browser_test/src/DrupalOrgClientMiddleware.php
------ ----------------------------------------------------------------------
94 \Drupal calls should be avoided in classes, use dependency injection
instead
------ ----------------------------------------------------------------------
[ERROR] Found 8 errors Check a GitLabCI run of PHPStan, such as: https://git.drupalcode.org/issue/project_browser-3437721/-/jobs/1345914
Replace \Drupal calls with dependency injection.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
fjgarlin commentedI made some comments in the MR about forcing services into all plugins. It's great that the base class implements the dependency injection interface., but I think that unless the base plugin needs a service, it shouldn't be included. Then each plugin will bring the services that would be needed instead.
Comment #4
lostcarpark commentedI have changed all
\Drupalcalls with dependency injections, and PHPStan is now passing.Moving to Needs Review.
Comment #5
fjgarlin commentedI left a comment in the MR. Hopefully it makes sense.
Good work so far.
Comment #6
lostcarpark commentedI don't think the constructor is needed, because there's already one in one of the inherited classes. I have added a
createfunction.Comment #7
fjgarlin commentedThe changes look good to me, the phpstan job is now green and testing via DrupalPod works as expected.
Thanks!
Comment #10
chrisfromredfinThank you for this!