ddev-drupal-contrib icon indicating copy to clipboard operation
ddev-drupal-contrib copied to clipboard

PHPStan baseline files generated

Open weitzman opened this issue 8 months ago • 2 comments

Preliminary checklist

  • [x] I am using the latest stable version of DDEV
  • [x] I am using the latest stable version of this add-on

Expected Behavior

After running ddev phpstan, no new files appear

Actual Behavior

After running ddev phpstan, I have untracked files in my checkout? Lets give maintainers guidance about how to handle them.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	phpstan-baseline.neon
	phpstan.neon
	recipes/

Steps To Reproduce

No response

Anything else?

No response

weitzman avatar Jul 04 '25 16:07 weitzman

One option is to keep track of whether the files existed before the run, and only clean them up after it finishes if they were generated during the run. This is the approach I took for cspell:

https://github.com/jameswilson/ddev-drupal-contrib/blob/cspell/commands/web/cspell#L32-L34

jameswilson avatar Jul 07 '25 12:07 jameswilson

Thanks for this command, ddev phpstan is really handy for contrib work!

I agree with the expectation here: running ddev phpstan shouldn’t create new files (or leave the repo dirty), especially when there is no phpstan.neon or phpstan.neon.dist yet.

What I’d expect instead is roughly:

  • If phpstan.neon OR phpstan.neon.dist exists, use them.
  • If neither exists, fail with a clear error message, e.g.

    “No PHPStan config found. Create phpstan.neon.dist and commit it to your project (you can copy it to phpstan.neon locally for overrides).”

That keeps ddev phpstan from generating untracked files, while still encouraging the common pattern of committing phpstan.neon.dist and optionally ignoring phpstan.neon for local tweaks.

Sorry if I’m wrong in thinking phpstan.neon.dist is the one we should be committing, but this problem is affecting me especially because I think this.

joelpittet avatar Nov 14 '25 18:11 joelpittet