Closed (fixed)
Project:
Scheduler
Version:
2.x-dev
Component:
Coding Standards
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2023 at 17:53 UTC
Updated:
20 Jan 2025 at 16:39 UTC
Jump to comment: Most recent
PHPStan is now being run on GitLab CI. There are many messages and the pipeline job ends with an 'amber' warning.
Here is the Gitlab_templates issue where PHPStan was added and a follow-up for improvements
Matt Glamman has written a blog post about it.
Some asic Drupal.org documentation
https://www.drupal.org/docs/develop/development-tools/phpstan/getting-st...
PHPStan User guide and config reference
https://phpstan.org/user-guide/getting-started
https://phpstan.org/config-reference
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 #4
jonathan1055 commentedNow commit the easy fixes.
Comment #10
jonathan1055 commentedI wrote a script to summarise PHPstan messages in a baseline file. Right at the start we had:
After splitting out the first set of legacy messages and following Core's ignore of
Unsafe usage of new static()the result was:Then after doing all the easy fixes we had
Comment #14
jonathan1055 commentedCurrent 8.x-1.x branch PHPStan job shows 46 errors
https://git.drupalcode.org/project/scheduler/-/jobs/687380
Using the three initial files, taken directly from 2.x with no changes, we get 41 errors
https://git.drupalcode.org/project/scheduler/-/jobs/695715
Many of these are because there are more messages in the 'ignore' files than are actuallly found in the code.
Comment #15
jonathan1055 commentedAfter removing the extra ignored messages, we are left with 15 that need to be fixed.
Comment #20
jonathan1055 commentedPHPStan is now running on 2.x and 8.x-1.x and all the easy fixes have been done.
Legacy code messages are permanently ignored in the
phpstan-baseline-ok.neonfile.The remainder are "temporarily" ignored in the
phpstan-baseline-to-fix.neon. These can (and should) be fixed in due course.2.x
---------------------------------------------------------------------------
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
---------------------------------------------------------------------------
Call to deprecated method loadRevision\(\) of class Drupal\Core\Entity\EntityStorageInterface\:
1 occurrence(s) in 1 file(s)
src/SchedulerManager.php
---------------------------------------------------------------------------
Number of messages by file
18 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: 2
Total number of messages: 37
---------------------------------------------------------------------------
8.x-1.x
---------------------------------------------------------------------------
Summary of PHPStan messages in phpstan-baseline-to-fix.neon
---------------------------------------------------------------------------
Drupal calls should be avoided in classes, use dependency injection instead
23 occurrence(s) in 11 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/SetPublishingDate.php
scheduler_rules_integration/src/Plugin/RulesAction/SetUnpublishingDate.php
src/Plugin/Validation/Constraint/SchedulerPublishOnConstraintValidator.php
src/Plugin/Validation/Constraint/SchedulerUnpublishOnConstraintValidator.php
src/Plugin/views/access/Scheduler.php
src/SchedulerManager.php
src/Theme/SchedulerThemeNegotiator.php
---------------------------------------------------------------------------
Variable \$unpublish_on in empty\(\) always exists and is not falsy\.
1 occurrence(s) in 1 file(s)
src/SchedulerManager.php
---------------------------------------------------------------------------
Number of messages by file
3 in scheduler_rules_integration/src/Plugin/RulesAction/RemovePublishingDate.php
3 in scheduler_rules_integration/src/Plugin/RulesAction/RemoveUnpublishingDate.php
3 in scheduler_rules_integration/src/Plugin/RulesAction/SetPublishingDate.php
3 in scheduler_rules_integration/src/Plugin/RulesAction/SetUnpublishingDate.php
3 in src/SchedulerManager.php
2 in src/Plugin/Validation/Constraint/SchedulerPublishOnConstraintValidator.php
2 in src/Plugin/Validation/Constraint/SchedulerUnpublishOnConstraintValidator.php
2 in src/Theme/SchedulerThemeNegotiator.php
1 in scheduler_rules_integration/src/Plugin/Condition/PublishingIsEnabled.php
1 in scheduler_rules_integration/src/Plugin/Condition/UnpublishingIsEnabled.php
1 in src/Plugin/views/access/Scheduler.php
---------------------------------------------------------------------------
Different types of message: 2
Total number of messages: 24
---------------------------------------------------------------------------
Comment #23
jonathan1055 commented