Problem/Motivation
A new `phpstan` job was recently added to GitLab configuration for contrib modules.
Upon further investigation, it seems like it's happening since we're using Drupal core 9.5.11 for running CI jobs which doesn't have phpstan composer dependency.
Steps to reproduce
Check the latest pipeline logs.
Remaining tasks
- Update gitlab CI config according to the core's one.
- Fix code issues reported by phpstan, if there are any.
Issue fork symfony_mailer-3401293
Show commands
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
bohartHere are the current `phpstan` job results ([ERROR] Found 43 errors):
https://git.drupalcode.org/project/symfony_mailer/-/jobs/322855
The Drupal core `phpstan` configuration has been applied:
https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/phpstan.neo...
Here are the current results ([ERROR] Found 8 errors):
https://git.drupalcode.org/issue/symfony_mailer-3401293/-/jobs/323458
@Adam, could you please review the current changes and commit them if everything looks okay?
Then, we will process with the rest (to avoid huge MRs).
____
The rest of the errors are related to using methods/classes from 3rd party modules (like simplenews, commerce, etc).
I assume the best way is to have submodules (with the appropriate dependencies) like symfony_mailer_simplenews, symfony_mailer_commerce and move everything related to those modules into them. In this case, we will be able better to control the dependencies / tests / phpstan errors.
@Adam, what do you think?
Thanks!
Comment #4
adamps commentedThanks for your enthusiasm to improve this module. I see phpstan in the same category as grammar checkers in word processors. Sometimes it can help, but also it can have a lot of wrong ideas😃.
I see a mixture of:
issetoremptyThis would add quite a lot of complexity and be difficult for back-compatibility of existing sites. What is the benefit - it seems only to cover limitations in a tool, and the tool anyway isn't that important. It seems like a clear no to me.
It feels to me that we should fix the missing use statements, and probably not most of the rest.
Comment #5
adamps commentedI am willing to compromise. In some cases although the change to code isn't necessary also it is harmless, so we could change it. However I don't agree to make the code worse or wrong just because the tool doesn't understand - maybe we could add a comment to disable the check of the specific line?? If you are interested then let's discuss it.
Comment #7
adamps commentedI committed the 2 use statements which are of course real bugs - thanks😃
Comment #9
adamps commentedThanks @bohart . I found a compromise that avoids making the code worse yet removes the warnings.