Closed (fixed)
Project:
Admin Toolbar
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
5 Apr 2025 at 04:04 UTC
Updated:
19 Apr 2025 at 04:44 UTC
Jump to comment: Most recent
Currently, the module uses the default Gitlab CI templates for the PHPSTAN job:
https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/as...
With the lowest rule level: 0, which only does very basic PHP code validation.
We would like to enforce stricter a validation of the module's code base, see the PHPSTAN rules levels:
https://phpstan.org/user-guide/rule-levels
Run locally:
./vendor/bin/phpstan analyze web/modules/contrib/admin_toolbar/ -l 6
Many errors will be displayed.
Fix all validation errors and add a phpstan.neon configuration file to set the rule level to 6 for the job on Gitlab CI.
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
dydave commentedQuick follow-up on this issue:
Starting from level 3, I gradually raised the level and each time fixed all the errors prompted by PHPSTAN, until reaching level 6.
Fixed all validation errors, mostly:
@vartypes definitions.Added project's
phpstan.neonfile to raise validation level to 6 and ignore certain error messages.Very few lines of code with very minor changes were impacted in the merge request.
Since the Tests of the MR all passed 🟢, I went ahead and merged the changes above at #3.
The configuration change was made on Gitlab CI by adding the file: phpstan.neon, forcing rule level to
6.This should be helpful keeping module's code properly maintained with the evolution of the different Core versions, APIs and PHP versions.
PHPSTAN validation is currently not required to merge.
Marking issue as Fixed for now.
Thanks!