Fix PHPStan per https://project.pages.drupalcode.org/gitlab_templates/jobs/phpstan/

Note that we have our own PHPStan config, set at level 2.

# Configuration file for PHPStan static code checking, see https://phpstan.org.
includes:
  - phar://phpstan.phar/conf/bleedingEdge.neon
  - phpstan-baseline.neon

parameters:
  level: 2
  paths:
    - .
  ignoreErrors:
    # new static() is a best practice in Drupal, so we cannot fix that.
    - "#^Unsafe usage of new static#"
CommentFileSizeAuthor
#12 DomainCommands.patch16.56 KBagentrickard

Issue fork domain-3458055

Command icon 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

agentrickard created an issue. See original summary.

webflo changed the visibility of the branch 3458055-phpstan to hidden.

webflo changed the visibility of the branch 3458055-phpstan to active.

webflo changed the visibility of the branch 3458055-phpstan to hidden.

webflo changed the visibility of the branch 3458055-phpstan to active.

agentrickard’s picture

I think I am going to dial back to level 1 PHPStan for now.

Just seeing @webflo's updates. So lets see how that goes.

I added reportUnmatchedIgnoredErrors: false to mask these:

No error to ignore is reported on line 65.

I also accidentally broke tests.

webflo’s picture

I think level 2 is achievable. We should create a baseline and refactor it step by step. Maybe one submodule after another.

agentrickard’s picture

Yes. I fixed my earlier problems and have been fixing things in reverse alphabetical order. Trying to finish up domain_config_ui today.

davps made their first commit to this issue’s fork.

agentrickard’s picture

Priority: Normal » Major
Status: Active » Needs review

This is all looking good. I have moved the remaining issues into phpstan-baseline.neon.

@webflo -- I think those can be fixed in a separate issue.

This could use a real-world test, but if it works for you, then I feel good about the state of the code and adding new maintainers.

agentrickard’s picture

StatusFileSize
new16.56 KB

We fixed everything except Drush, which should be a separate issue.

The attached patch did not work as documented here -- https://www.drush.org/12.x/dependency-injection/#create-method -- using Druah 12.4 on PHP 8.3.

That can be a separate issue.

  • webflo committed 877f662c on 2.0.x authored by agentrickard
    Issue #3458055 by agentrickard, webflo: Configure and fix PHPStan issues
    
webflo’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.